[safe-browsing] Database full hash matches like prefix match.
[chromium-blink-merge.git] / chrome / browser / browsing_data / mock_browsing_data_file_system_helper.cc
blob26d81852253721a7bde2167a3a4f018d39e716da
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #include "base/callback.h"
6 #include "base/logging.h"
7 #include "chrome/browser/browsing_data/mock_browsing_data_file_system_helper.h"
9 MockBrowsingDataFileSystemHelper::MockBrowsingDataFileSystemHelper(
10 Profile* profile) {
13 MockBrowsingDataFileSystemHelper::~MockBrowsingDataFileSystemHelper() {
16 void MockBrowsingDataFileSystemHelper::StartFetching(
17 const base::Callback<void(const std::list<FileSystemInfo>&)>& callback) {
18 callback_ = callback;
21 void MockBrowsingDataFileSystemHelper::DeleteFileSystemOrigin(
22 const GURL& origin) {
23 std::string key = origin.spec();
24 CHECK(file_systems_.find(key) != file_systems_.end());
25 last_deleted_origin_ = origin;
26 file_systems_[key] = false;
29 void MockBrowsingDataFileSystemHelper::AddFileSystem(
30 const GURL& origin, bool has_persistent, bool has_temporary,
31 bool has_syncable) {
32 BrowsingDataFileSystemHelper::FileSystemInfo info(origin);
33 if (has_persistent)
34 info.usage_map[fileapi::kFileSystemTypePersistent] = 0;
35 if (has_temporary)
36 info.usage_map[fileapi::kFileSystemTypeTemporary] = 0;
37 if (has_syncable)
38 info.usage_map[fileapi::kFileSystemTypeSyncable] = 0;
39 response_.push_back(info);
40 file_systems_[origin.spec()] = true;
43 void MockBrowsingDataFileSystemHelper::AddFileSystemSamples() {
44 AddFileSystem(GURL("http://fshost1:1/"), false, true, false);
45 AddFileSystem(GURL("http://fshost2:2/"), true, false, true);
46 AddFileSystem(GURL("http://fshost3:3/"), true, true, true);
49 void MockBrowsingDataFileSystemHelper::Notify() {
50 CHECK_EQ(false, callback_.is_null());
51 callback_.Run(response_);
54 void MockBrowsingDataFileSystemHelper::Reset() {
55 for (std::map<const std::string, bool>::iterator i = file_systems_.begin();
56 i != file_systems_.end(); ++i)
57 i->second = true;
60 bool MockBrowsingDataFileSystemHelper::AllDeleted() {
61 for (std::map<const std::string, bool>::const_iterator i =
62 file_systems_.begin();
63 i != file_systems_.end(); ++i) {
64 if (i->second)
65 return false;
67 return true;