OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "base/callback.h" | 5 #include "base/callback.h" |
6 #include "base/logging.h" | 6 #include "base/logging.h" |
7 #include "chrome/browser/browsing_data/mock_browsing_data_file_system_helper.h" | 7 #include "chrome/browser/browsing_data/mock_browsing_data_file_system_helper.h" |
8 | 8 |
9 MockBrowsingDataFileSystemHelper::MockBrowsingDataFileSystemHelper( | 9 MockBrowsingDataFileSystemHelper::MockBrowsingDataFileSystemHelper( |
10 Profile* profile) { | 10 Profile* profile) { |
11 } | 11 } |
12 | 12 |
13 MockBrowsingDataFileSystemHelper::~MockBrowsingDataFileSystemHelper() { | 13 MockBrowsingDataFileSystemHelper::~MockBrowsingDataFileSystemHelper() { |
14 } | 14 } |
15 | 15 |
16 void MockBrowsingDataFileSystemHelper::StartFetching( | 16 void MockBrowsingDataFileSystemHelper::StartFetching( |
17 const base::Callback<void(const std::list<FileSystemInfo>&)>& callback) { | 17 const base::Callback<void(const std::list<FileSystemInfo>&)>& callback) { |
18 callback_ = callback; | 18 callback_ = callback; |
19 } | 19 } |
20 | 20 |
21 void MockBrowsingDataFileSystemHelper::DeleteFileSystemOrigin( | 21 void MockBrowsingDataFileSystemHelper::DeleteFileSystemOrigin( |
22 const GURL& origin) { | 22 const GURL& origin) { |
23 std::string key = origin.spec(); | 23 std::string key = origin.spec(); |
24 CHECK(file_systems_.find(key) != file_systems_.end()); | 24 CHECK(file_systems_.find(key) != file_systems_.end()); |
25 last_deleted_origin_ = origin; | 25 last_deleted_origin_ = origin; |
26 file_systems_[key] = false; | 26 file_systems_[key] = false; |
27 } | 27 } |
28 | 28 |
29 void MockBrowsingDataFileSystemHelper::AddFileSystem( | 29 void MockBrowsingDataFileSystemHelper::AddFileSystem( |
30 const GURL& origin, bool has_persistent, bool has_temporary) { | 30 const GURL& origin, bool has_persistent, bool has_temporary, |
| 31 bool has_syncable) { |
31 response_.push_back(BrowsingDataFileSystemHelper::FileSystemInfo( | 32 response_.push_back(BrowsingDataFileSystemHelper::FileSystemInfo( |
32 origin, has_persistent, has_temporary, 0, 0)); | 33 origin, has_persistent, has_temporary, has_syncable, 0, 0, 0)); |
33 file_systems_[origin.spec()] = true; | 34 file_systems_[origin.spec()] = true; |
34 } | 35 } |
35 | 36 |
36 void MockBrowsingDataFileSystemHelper::AddFileSystemSamples() { | 37 void MockBrowsingDataFileSystemHelper::AddFileSystemSamples() { |
37 AddFileSystem(GURL("http://fshost1:1/"), false, true); | 38 AddFileSystem(GURL("http://fshost1:1/"), false, true, false); |
38 AddFileSystem(GURL("http://fshost2:2/"), true, false); | 39 AddFileSystem(GURL("http://fshost2:2/"), true, false, true); |
39 AddFileSystem(GURL("http://fshost3:3/"), true, true); | 40 AddFileSystem(GURL("http://fshost3:3/"), true, true, true); |
40 } | 41 } |
41 | 42 |
42 void MockBrowsingDataFileSystemHelper::Notify() { | 43 void MockBrowsingDataFileSystemHelper::Notify() { |
43 CHECK_EQ(false, callback_.is_null()); | 44 CHECK_EQ(false, callback_.is_null()); |
44 callback_.Run(response_); | 45 callback_.Run(response_); |
45 } | 46 } |
46 | 47 |
47 void MockBrowsingDataFileSystemHelper::Reset() { | 48 void MockBrowsingDataFileSystemHelper::Reset() { |
48 for (std::map<const std::string, bool>::iterator i = file_systems_.begin(); | 49 for (std::map<const std::string, bool>::iterator i = file_systems_.begin(); |
49 i != file_systems_.end(); ++i) | 50 i != file_systems_.end(); ++i) |
50 i->second = true; | 51 i->second = true; |
51 } | 52 } |
52 | 53 |
53 bool MockBrowsingDataFileSystemHelper::AllDeleted() { | 54 bool MockBrowsingDataFileSystemHelper::AllDeleted() { |
54 for (std::map<const std::string, bool>::const_iterator i = | 55 for (std::map<const std::string, bool>::const_iterator i = |
55 file_systems_.begin(); | 56 file_systems_.begin(); |
56 i != file_systems_.end(); ++i) { | 57 i != file_systems_.end(); ++i) { |
57 if (i->second) | 58 if (i->second) |
58 return false; | 59 return false; |
59 } | 60 } |
60 return true; | 61 return true; |
61 } | 62 } |
OLD | NEW |