OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/files/file.h" | 5 #include "base/files/file.h" |
6 #include "base/files/file_path.h" | 6 #include "base/files/file_path.h" |
7 #include "base/files/file_util.h" | 7 #include "base/files/file_util.h" |
8 #include "base/files/scoped_temp_dir.h" | 8 #include "base/files/scoped_temp_dir.h" |
9 #include "base/memory/scoped_ptr.h" | 9 #include "base/memory/scoped_ptr.h" |
10 #include "base/message_loop/message_loop.h" | 10 #include "base/message_loop/message_loop.h" |
(...skipping 28 matching lines...) Expand all Loading... |
39 } | 39 } |
40 TestObserver(bool observe_size_changes, bool observe_scheduled_deletions) | 40 TestObserver(bool observe_size_changes, bool observe_scheduled_deletions) |
41 : new_notification_received_(false), | 41 : new_notification_received_(false), |
42 observe_size_changes_(observe_size_changes), | 42 observe_size_changes_(observe_size_changes), |
43 observe_scheduled_deletions_(observe_scheduled_deletions) { | 43 observe_scheduled_deletions_(observe_scheduled_deletions) { |
44 } | 44 } |
45 | 45 |
46 virtual ~TestObserver() {} | 46 virtual ~TestObserver() {} |
47 virtual void OnDatabaseSizeChanged(const std::string& origin_identifier, | 47 virtual void OnDatabaseSizeChanged(const std::string& origin_identifier, |
48 const base::string16& database_name, | 48 const base::string16& database_name, |
49 int64 database_size) OVERRIDE { | 49 int64 database_size) override { |
50 if (!observe_size_changes_) | 50 if (!observe_size_changes_) |
51 return; | 51 return; |
52 new_notification_received_ = true; | 52 new_notification_received_ = true; |
53 origin_identifier_ = origin_identifier; | 53 origin_identifier_ = origin_identifier; |
54 database_name_ = database_name; | 54 database_name_ = database_name; |
55 database_size_ = database_size; | 55 database_size_ = database_size; |
56 } | 56 } |
57 virtual void OnDatabaseScheduledForDeletion( | 57 virtual void OnDatabaseScheduledForDeletion( |
58 const std::string& origin_identifier, | 58 const std::string& origin_identifier, |
59 const base::string16& database_name) OVERRIDE { | 59 const base::string16& database_name) override { |
60 if (!observe_scheduled_deletions_) | 60 if (!observe_scheduled_deletions_) |
61 return; | 61 return; |
62 new_notification_received_ = true; | 62 new_notification_received_ = true; |
63 origin_identifier_ = origin_identifier; | 63 origin_identifier_ = origin_identifier; |
64 database_name_ = database_name; | 64 database_name_ = database_name; |
65 } | 65 } |
66 bool DidReceiveNewNotification() { | 66 bool DidReceiveNewNotification() { |
67 bool temp_new_notification_received = new_notification_received_; | 67 bool temp_new_notification_received = new_notification_received_; |
68 new_notification_received_ = false; | 68 new_notification_received_ = false; |
69 return temp_new_notification_received; | 69 return temp_new_notification_received; |
(...skipping 26 matching lines...) Expand all Loading... |
96 observer->GetNotificationDatabaseSize()); | 96 observer->GetNotificationDatabaseSize()); |
97 } | 97 } |
98 | 98 |
99 class TestQuotaManagerProxy : public storage::QuotaManagerProxy { | 99 class TestQuotaManagerProxy : public storage::QuotaManagerProxy { |
100 public: | 100 public: |
101 TestQuotaManagerProxy() | 101 TestQuotaManagerProxy() |
102 : QuotaManagerProxy(NULL, NULL), | 102 : QuotaManagerProxy(NULL, NULL), |
103 registered_client_(NULL) { | 103 registered_client_(NULL) { |
104 } | 104 } |
105 | 105 |
106 virtual void RegisterClient(storage::QuotaClient* client) OVERRIDE { | 106 virtual void RegisterClient(storage::QuotaClient* client) override { |
107 EXPECT_FALSE(registered_client_); | 107 EXPECT_FALSE(registered_client_); |
108 registered_client_ = client; | 108 registered_client_ = client; |
109 } | 109 } |
110 | 110 |
111 virtual void NotifyStorageAccessed(storage::QuotaClient::ID client_id, | 111 virtual void NotifyStorageAccessed(storage::QuotaClient::ID client_id, |
112 const GURL& origin, | 112 const GURL& origin, |
113 storage::StorageType type) OVERRIDE { | 113 storage::StorageType type) override { |
114 EXPECT_EQ(storage::QuotaClient::kDatabase, client_id); | 114 EXPECT_EQ(storage::QuotaClient::kDatabase, client_id); |
115 EXPECT_EQ(storage::kStorageTypeTemporary, type); | 115 EXPECT_EQ(storage::kStorageTypeTemporary, type); |
116 accesses_[origin] += 1; | 116 accesses_[origin] += 1; |
117 } | 117 } |
118 | 118 |
119 virtual void NotifyStorageModified(storage::QuotaClient::ID client_id, | 119 virtual void NotifyStorageModified(storage::QuotaClient::ID client_id, |
120 const GURL& origin, | 120 const GURL& origin, |
121 storage::StorageType type, | 121 storage::StorageType type, |
122 int64 delta) OVERRIDE { | 122 int64 delta) override { |
123 EXPECT_EQ(storage::QuotaClient::kDatabase, client_id); | 123 EXPECT_EQ(storage::QuotaClient::kDatabase, client_id); |
124 EXPECT_EQ(storage::kStorageTypeTemporary, type); | 124 EXPECT_EQ(storage::kStorageTypeTemporary, type); |
125 modifications_[origin].first += 1; | 125 modifications_[origin].first += 1; |
126 modifications_[origin].second += delta; | 126 modifications_[origin].second += delta; |
127 } | 127 } |
128 | 128 |
129 // Not needed for our tests. | 129 // Not needed for our tests. |
130 virtual void NotifyOriginInUse(const GURL& origin) OVERRIDE {} | 130 virtual void NotifyOriginInUse(const GURL& origin) override {} |
131 virtual void NotifyOriginNoLongerInUse(const GURL& origin) OVERRIDE {} | 131 virtual void NotifyOriginNoLongerInUse(const GURL& origin) override {} |
132 virtual void SetUsageCacheEnabled(storage::QuotaClient::ID client_id, | 132 virtual void SetUsageCacheEnabled(storage::QuotaClient::ID client_id, |
133 const GURL& origin, | 133 const GURL& origin, |
134 storage::StorageType type, | 134 storage::StorageType type, |
135 bool enabled) OVERRIDE {} | 135 bool enabled) override {} |
136 virtual void GetUsageAndQuota( | 136 virtual void GetUsageAndQuota( |
137 base::SequencedTaskRunner* original_task_runner, | 137 base::SequencedTaskRunner* original_task_runner, |
138 const GURL& origin, | 138 const GURL& origin, |
139 storage::StorageType type, | 139 storage::StorageType type, |
140 const GetUsageAndQuotaCallback& callback) OVERRIDE {} | 140 const GetUsageAndQuotaCallback& callback) override {} |
141 | 141 |
142 void SimulateQuotaManagerDestroyed() { | 142 void SimulateQuotaManagerDestroyed() { |
143 if (registered_client_) { | 143 if (registered_client_) { |
144 registered_client_->OnQuotaManagerDestroyed(); | 144 registered_client_->OnQuotaManagerDestroyed(); |
145 registered_client_ = NULL; | 145 registered_client_ = NULL; |
146 } | 146 } |
147 } | 147 } |
148 | 148 |
149 bool WasAccessNotified(const GURL& origin) { | 149 bool WasAccessNotified(const GURL& origin) { |
150 return accesses_[origin] != 0; | 150 return accesses_[origin] != 0; |
(...skipping 712 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
863 | 863 |
864 TEST(DatabaseTrackerTest, EmptyDatabaseNameIsValid) { | 864 TEST(DatabaseTrackerTest, EmptyDatabaseNameIsValid) { |
865 DatabaseTracker_TestHelper_Test::EmptyDatabaseNameIsValid(); | 865 DatabaseTracker_TestHelper_Test::EmptyDatabaseNameIsValid(); |
866 } | 866 } |
867 | 867 |
868 TEST(DatabaseTrackerTest, HandleSqliteError) { | 868 TEST(DatabaseTrackerTest, HandleSqliteError) { |
869 DatabaseTracker_TestHelper_Test::HandleSqliteError(); | 869 DatabaseTracker_TestHelper_Test::HandleSqliteError(); |
870 } | 870 } |
871 | 871 |
872 } // namespace content | 872 } // namespace content |
OLD | NEW |