OLD | NEW |
| (Empty) |
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. | |
4 | |
5 #include "base/callback.h" | |
6 #include "base/logging.h" | |
7 #include "chrome/browser/mock_browsing_data_file_system_helper.h" | |
8 | |
9 MockBrowsingDataFileSystemHelper::MockBrowsingDataFileSystemHelper( | |
10 Profile* profile) { | |
11 } | |
12 | |
13 MockBrowsingDataFileSystemHelper::~MockBrowsingDataFileSystemHelper() { | |
14 } | |
15 | |
16 void MockBrowsingDataFileSystemHelper::StartFetching( | |
17 const base::Callback<void(const std::list<FileSystemInfo>&)>& callback) { | |
18 callback_ = callback; | |
19 } | |
20 | |
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; | |
27 } | |
28 | |
29 void MockBrowsingDataFileSystemHelper::AddFileSystem( | |
30 const GURL& origin, bool has_persistent, bool has_temporary) { | |
31 response_.push_back(BrowsingDataFileSystemHelper::FileSystemInfo( | |
32 origin, has_persistent, has_temporary, 0, 0)); | |
33 file_systems_[origin.spec()] = true; | |
34 } | |
35 | |
36 void MockBrowsingDataFileSystemHelper::AddFileSystemSamples() { | |
37 AddFileSystem(GURL("http://fshost1:1/"), false, true); | |
38 AddFileSystem(GURL("http://fshost2:2/"), true, false); | |
39 AddFileSystem(GURL("http://fshost3:3/"), true, true); | |
40 } | |
41 | |
42 void MockBrowsingDataFileSystemHelper::Notify() { | |
43 CHECK_EQ(false, callback_.is_null()); | |
44 callback_.Run(response_); | |
45 } | |
46 | |
47 void MockBrowsingDataFileSystemHelper::Reset() { | |
48 for (std::map<const std::string, bool>::iterator i = file_systems_.begin(); | |
49 i != file_systems_.end(); ++i) | |
50 i->second = true; | |
51 } | |
52 | |
53 bool MockBrowsingDataFileSystemHelper::AllDeleted() { | |
54 for (std::map<const std::string, bool>::const_iterator i = | |
55 file_systems_.begin(); | |
56 i != file_systems_.end(); ++i) { | |
57 if (i->second) | |
58 return false; | |
59 } | |
60 return true; | |
61 } | |
OLD | NEW |