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(
13 MockBrowsingDataFileSystemHelper::~MockBrowsingDataFileSystemHelper() {
16 void MockBrowsingDataFileSystemHelper::StartFetching(
17 const base::Callback
<void(const std::list
<FileSystemInfo
>&)>& callback
) {
21 void MockBrowsingDataFileSystemHelper::DeleteFileSystemOrigin(
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
,
32 BrowsingDataFileSystemHelper::FileSystemInfo
info(origin
);
34 info
.usage_map
[fileapi::kFileSystemTypePersistent
] = 0;
36 info
.usage_map
[fileapi::kFileSystemTypeTemporary
] = 0;
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
)
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
) {