blob: c52259a95b8f062dc33c20173def3e542dbb6edb [file] [log] [blame]
// Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "chrome/browser/mock_browsing_data_local_storage_helper.h"
#include "base/callback.h"
#include "base/logging.h"
MockBrowsingDataLocalStorageHelper::MockBrowsingDataLocalStorageHelper(
Profile* profile)
: BrowsingDataLocalStorageHelper(profile),
profile_(profile) {
}
MockBrowsingDataLocalStorageHelper::~MockBrowsingDataLocalStorageHelper() {
}
void MockBrowsingDataLocalStorageHelper::StartFetching(
const base::Callback<void(const std::list<LocalStorageInfo>&)>& callback) {
callback_ = callback;
}
void MockBrowsingDataLocalStorageHelper::DeleteLocalStorageFile(
const FilePath& file_path) {
CHECK(files_.find(file_path.value()) != files_.end());
last_deleted_file_ = file_path;
files_[file_path.value()] = false;
}
void MockBrowsingDataLocalStorageHelper::AddLocalStorageSamples() {
response_.push_back(
BrowsingDataLocalStorageHelper::LocalStorageInfo(
"http", "host1", 1, "db1", "http://host1:1/",
FilePath(FILE_PATH_LITERAL("file1")), 1, base::Time()));
files_[FILE_PATH_LITERAL("file1")] = true;
response_.push_back(
BrowsingDataLocalStorageHelper::LocalStorageInfo(
"http", "host2", 2, "db2", "http://host2:2/",
FilePath(FILE_PATH_LITERAL("file2")), 2, base::Time()));
files_[FILE_PATH_LITERAL("file2")] = true;
}
void MockBrowsingDataLocalStorageHelper::Notify() {
CHECK_EQ(false, callback_.is_null());
callback_.Run(response_);
}
void MockBrowsingDataLocalStorageHelper::Reset() {
for (std::map<const FilePath::StringType, bool>::iterator i = files_.begin();
i != files_.end(); ++i)
i->second = true;
}
bool MockBrowsingDataLocalStorageHelper::AllDeleted() {
for (std::map<const FilePath::StringType, bool>::const_iterator i =
files_.begin(); i != files_.end(); ++i)
if (i->second)
return false;
return true;
}