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 "chrome/browser/browsing_data/mock_browsing_data_file_system_helper.h" | 5 #include "chrome/browser/browsing_data/mock_browsing_data_file_system_helper.h" |
6 | 6 |
7 #include "base/callback.h" | 7 #include "base/callback.h" |
8 #include "base/logging.h" | 8 #include "base/logging.h" |
9 #include "base/stl_util.h" | 9 #include "base/stl_util.h" |
10 #include "testing/gtest/include/gtest/gtest.h" | 10 #include "testing/gtest/include/gtest/gtest.h" |
(...skipping 16 matching lines...) Expand all Loading... |
27 const GURL& origin) { | 27 const GURL& origin) { |
28 ASSERT_FALSE(callback_.is_null()); | 28 ASSERT_FALSE(callback_.is_null()); |
29 std::string key = origin.spec(); | 29 std::string key = origin.spec(); |
30 ASSERT_TRUE(ContainsKey(file_systems_, key)); | 30 ASSERT_TRUE(ContainsKey(file_systems_, key)); |
31 last_deleted_origin_ = origin; | 31 last_deleted_origin_ = origin; |
32 file_systems_[key] = false; | 32 file_systems_[key] = false; |
33 } | 33 } |
34 | 34 |
35 void MockBrowsingDataFileSystemHelper::AddFileSystem( | 35 void MockBrowsingDataFileSystemHelper::AddFileSystem( |
36 const GURL& origin, bool has_persistent, bool has_temporary, | 36 const GURL& origin, bool has_persistent, bool has_temporary, |
37 bool has_syncable) { | 37 bool has_syncable, int64_t size_persistent, int64_t size_temporary, |
| 38 int64_t size_syncable) { |
38 BrowsingDataFileSystemHelper::FileSystemInfo info(origin); | 39 BrowsingDataFileSystemHelper::FileSystemInfo info(origin); |
39 if (has_persistent) | 40 if (has_persistent) |
40 info.usage_map[storage::kFileSystemTypePersistent] = 0; | 41 info.usage_map[storage::kFileSystemTypePersistent] = size_persistent; |
41 if (has_temporary) | 42 if (has_temporary) |
42 info.usage_map[storage::kFileSystemTypeTemporary] = 0; | 43 info.usage_map[storage::kFileSystemTypeTemporary] = size_temporary; |
43 if (has_syncable) | 44 if (has_syncable) |
44 info.usage_map[storage::kFileSystemTypeSyncable] = 0; | 45 info.usage_map[storage::kFileSystemTypeSyncable] = size_syncable; |
45 response_.push_back(info); | 46 response_.push_back(info); |
46 file_systems_[origin.spec()] = true; | 47 file_systems_[origin.spec()] = true; |
47 } | 48 } |
48 | 49 |
49 void MockBrowsingDataFileSystemHelper::AddFileSystemSamples() { | 50 void MockBrowsingDataFileSystemHelper::AddFileSystemSamples() { |
50 AddFileSystem(GURL("http://fshost1:1/"), false, true, false); | 51 AddFileSystem(GURL("http://fshost1:1/"), false, true, false, 0, 1, 0); |
51 AddFileSystem(GURL("http://fshost2:2/"), true, false, true); | 52 AddFileSystem(GURL("http://fshost2:2/"), true, false, true, 2, 0, 2); |
52 AddFileSystem(GURL("http://fshost3:3/"), true, true, true); | 53 AddFileSystem(GURL("http://fshost3:3/"), true, true, true, 3, 3, 3); |
53 } | 54 } |
54 | 55 |
55 void MockBrowsingDataFileSystemHelper::Notify() { | 56 void MockBrowsingDataFileSystemHelper::Notify() { |
56 callback_.Run(response_); | 57 callback_.Run(response_); |
57 } | 58 } |
58 | 59 |
59 void MockBrowsingDataFileSystemHelper::Reset() { | 60 void MockBrowsingDataFileSystemHelper::Reset() { |
60 for (auto& pair : file_systems_) | 61 for (auto& pair : file_systems_) |
61 pair.second = true; | 62 pair.second = true; |
62 } | 63 } |
63 | 64 |
64 bool MockBrowsingDataFileSystemHelper::AllDeleted() { | 65 bool MockBrowsingDataFileSystemHelper::AllDeleted() { |
65 for (const auto& pair : file_systems_) { | 66 for (const auto& pair : file_systems_) { |
66 if (pair.second) | 67 if (pair.second) |
67 return false; | 68 return false; |
68 } | 69 } |
69 return true; | 70 return true; |
70 } | 71 } |
OLD | NEW |