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 <stddef.h> |
| 6 #include <stdint.h> |
| 7 |
5 #include "base/files/file.h" | 8 #include "base/files/file.h" |
6 #include "base/files/file_path.h" | 9 #include "base/files/file_path.h" |
7 #include "base/files/file_util.h" | 10 #include "base/files/file_util.h" |
8 #include "base/files/scoped_temp_dir.h" | 11 #include "base/files/scoped_temp_dir.h" |
9 #include "base/memory/scoped_ptr.h" | 12 #include "base/memory/scoped_ptr.h" |
10 #include "base/message_loop/message_loop.h" | 13 #include "base/message_loop/message_loop.h" |
11 #include "base/strings/utf_string_conversions.h" | 14 #include "base/strings/utf_string_conversions.h" |
12 #include "base/thread_task_runner_handle.h" | 15 #include "base/thread_task_runner_handle.h" |
13 #include "base/time/time.h" | 16 #include "base/time/time.h" |
14 #include "content/public/test/mock_special_storage_policy.h" | 17 #include "content/public/test/mock_special_storage_policy.h" |
(...skipping 24 matching lines...) Expand all Loading... |
39 } | 42 } |
40 TestObserver(bool observe_size_changes, bool observe_scheduled_deletions) | 43 TestObserver(bool observe_size_changes, bool observe_scheduled_deletions) |
41 : new_notification_received_(false), | 44 : new_notification_received_(false), |
42 observe_size_changes_(observe_size_changes), | 45 observe_size_changes_(observe_size_changes), |
43 observe_scheduled_deletions_(observe_scheduled_deletions) { | 46 observe_scheduled_deletions_(observe_scheduled_deletions) { |
44 } | 47 } |
45 | 48 |
46 ~TestObserver() override {} | 49 ~TestObserver() override {} |
47 void OnDatabaseSizeChanged(const std::string& origin_identifier, | 50 void OnDatabaseSizeChanged(const std::string& origin_identifier, |
48 const base::string16& database_name, | 51 const base::string16& database_name, |
49 int64 database_size) override { | 52 int64_t database_size) override { |
50 if (!observe_size_changes_) | 53 if (!observe_size_changes_) |
51 return; | 54 return; |
52 new_notification_received_ = true; | 55 new_notification_received_ = true; |
53 origin_identifier_ = origin_identifier; | 56 origin_identifier_ = origin_identifier; |
54 database_name_ = database_name; | 57 database_name_ = database_name; |
55 database_size_ = database_size; | 58 database_size_ = database_size; |
56 } | 59 } |
57 void OnDatabaseScheduledForDeletion( | 60 void OnDatabaseScheduledForDeletion( |
58 const std::string& origin_identifier, | 61 const std::string& origin_identifier, |
59 const base::string16& database_name) override { | 62 const base::string16& database_name) override { |
60 if (!observe_scheduled_deletions_) | 63 if (!observe_scheduled_deletions_) |
61 return; | 64 return; |
62 new_notification_received_ = true; | 65 new_notification_received_ = true; |
63 origin_identifier_ = origin_identifier; | 66 origin_identifier_ = origin_identifier; |
64 database_name_ = database_name; | 67 database_name_ = database_name; |
65 } | 68 } |
66 bool DidReceiveNewNotification() { | 69 bool DidReceiveNewNotification() { |
67 bool temp_new_notification_received = new_notification_received_; | 70 bool temp_new_notification_received = new_notification_received_; |
68 new_notification_received_ = false; | 71 new_notification_received_ = false; |
69 return temp_new_notification_received; | 72 return temp_new_notification_received; |
70 } | 73 } |
71 std::string GetNotificationOriginIdentifier() { | 74 std::string GetNotificationOriginIdentifier() { |
72 return origin_identifier_; | 75 return origin_identifier_; |
73 } | 76 } |
74 base::string16 GetNotificationDatabaseName() { return database_name_; } | 77 base::string16 GetNotificationDatabaseName() { return database_name_; } |
75 int64 GetNotificationDatabaseSize() { return database_size_; } | 78 int64_t GetNotificationDatabaseSize() { return database_size_; } |
76 | 79 |
77 private: | 80 private: |
78 bool new_notification_received_; | 81 bool new_notification_received_; |
79 bool observe_size_changes_; | 82 bool observe_size_changes_; |
80 bool observe_scheduled_deletions_; | 83 bool observe_scheduled_deletions_; |
81 std::string origin_identifier_; | 84 std::string origin_identifier_; |
82 base::string16 database_name_; | 85 base::string16 database_name_; |
83 int64 database_size_; | 86 int64_t database_size_; |
84 }; | 87 }; |
85 | 88 |
86 void CheckNotificationReceived(TestObserver* observer, | 89 void CheckNotificationReceived(TestObserver* observer, |
87 const std::string& expected_origin_identifier, | 90 const std::string& expected_origin_identifier, |
88 const base::string16& expected_database_name, | 91 const base::string16& expected_database_name, |
89 int64 expected_database_size) { | 92 int64_t expected_database_size) { |
90 EXPECT_TRUE(observer->DidReceiveNewNotification()); | 93 EXPECT_TRUE(observer->DidReceiveNewNotification()); |
91 EXPECT_EQ(expected_origin_identifier, | 94 EXPECT_EQ(expected_origin_identifier, |
92 observer->GetNotificationOriginIdentifier()); | 95 observer->GetNotificationOriginIdentifier()); |
93 EXPECT_EQ(expected_database_name, | 96 EXPECT_EQ(expected_database_name, |
94 observer->GetNotificationDatabaseName()); | 97 observer->GetNotificationDatabaseName()); |
95 EXPECT_EQ(expected_database_size, | 98 EXPECT_EQ(expected_database_size, |
96 observer->GetNotificationDatabaseSize()); | 99 observer->GetNotificationDatabaseSize()); |
97 } | 100 } |
98 | 101 |
99 class TestQuotaManagerProxy : public storage::QuotaManagerProxy { | 102 class TestQuotaManagerProxy : public storage::QuotaManagerProxy { |
(...skipping 12 matching lines...) Expand all Loading... |
112 const GURL& origin, | 115 const GURL& origin, |
113 storage::StorageType type) override { | 116 storage::StorageType type) override { |
114 EXPECT_EQ(storage::QuotaClient::kDatabase, client_id); | 117 EXPECT_EQ(storage::QuotaClient::kDatabase, client_id); |
115 EXPECT_EQ(storage::kStorageTypeTemporary, type); | 118 EXPECT_EQ(storage::kStorageTypeTemporary, type); |
116 accesses_[origin] += 1; | 119 accesses_[origin] += 1; |
117 } | 120 } |
118 | 121 |
119 void NotifyStorageModified(storage::QuotaClient::ID client_id, | 122 void NotifyStorageModified(storage::QuotaClient::ID client_id, |
120 const GURL& origin, | 123 const GURL& origin, |
121 storage::StorageType type, | 124 storage::StorageType type, |
122 int64 delta) override { | 125 int64_t delta) override { |
123 EXPECT_EQ(storage::QuotaClient::kDatabase, client_id); | 126 EXPECT_EQ(storage::QuotaClient::kDatabase, client_id); |
124 EXPECT_EQ(storage::kStorageTypeTemporary, type); | 127 EXPECT_EQ(storage::kStorageTypeTemporary, type); |
125 modifications_[origin].first += 1; | 128 modifications_[origin].first += 1; |
126 modifications_[origin].second += delta; | 129 modifications_[origin].second += delta; |
127 } | 130 } |
128 | 131 |
129 // Not needed for our tests. | 132 // Not needed for our tests. |
130 void NotifyOriginInUse(const GURL& origin) override {} | 133 void NotifyOriginInUse(const GURL& origin) override {} |
131 void NotifyOriginNoLongerInUse(const GURL& origin) override {} | 134 void NotifyOriginNoLongerInUse(const GURL& origin) override {} |
132 void SetUsageCacheEnabled(storage::QuotaClient::ID client_id, | 135 void SetUsageCacheEnabled(storage::QuotaClient::ID client_id, |
133 const GURL& origin, | 136 const GURL& origin, |
134 storage::StorageType type, | 137 storage::StorageType type, |
135 bool enabled) override {} | 138 bool enabled) override {} |
136 void GetUsageAndQuota(base::SequencedTaskRunner* original_task_runner, | 139 void GetUsageAndQuota(base::SequencedTaskRunner* original_task_runner, |
137 const GURL& origin, | 140 const GURL& origin, |
138 storage::StorageType type, | 141 storage::StorageType type, |
139 const GetUsageAndQuotaCallback& callback) override {} | 142 const GetUsageAndQuotaCallback& callback) override {} |
140 | 143 |
141 void SimulateQuotaManagerDestroyed() { | 144 void SimulateQuotaManagerDestroyed() { |
142 if (registered_client_) { | 145 if (registered_client_) { |
143 registered_client_->OnQuotaManagerDestroyed(); | 146 registered_client_->OnQuotaManagerDestroyed(); |
144 registered_client_ = NULL; | 147 registered_client_ = NULL; |
145 } | 148 } |
146 } | 149 } |
147 | 150 |
148 bool WasAccessNotified(const GURL& origin) { | 151 bool WasAccessNotified(const GURL& origin) { |
149 return accesses_[origin] != 0; | 152 return accesses_[origin] != 0; |
150 } | 153 } |
151 | 154 |
152 bool WasModificationNotified(const GURL& origin, int64 amount) { | 155 bool WasModificationNotified(const GURL& origin, int64_t amount) { |
153 return modifications_[origin].first != 0 && | 156 return modifications_[origin].first != 0 && |
154 modifications_[origin].second == amount; | 157 modifications_[origin].second == amount; |
155 } | 158 } |
156 | 159 |
157 void reset() { | 160 void reset() { |
158 accesses_.clear(); | 161 accesses_.clear(); |
159 modifications_.clear(); | 162 modifications_.clear(); |
160 } | 163 } |
161 | 164 |
162 storage::QuotaClient* registered_client_; | 165 storage::QuotaClient* registered_client_; |
163 | 166 |
164 // Map from origin to count of access notifications. | 167 // Map from origin to count of access notifications. |
165 std::map<GURL, int> accesses_; | 168 std::map<GURL, int> accesses_; |
166 | 169 |
167 // Map from origin to <count, sum of deltas> | 170 // Map from origin to <count, sum of deltas> |
168 std::map<GURL, std::pair<int, int64> > modifications_; | 171 std::map<GURL, std::pair<int, int64_t>> modifications_; |
169 | 172 |
170 protected: | 173 protected: |
171 ~TestQuotaManagerProxy() override { EXPECT_FALSE(registered_client_); } | 174 ~TestQuotaManagerProxy() override { EXPECT_FALSE(registered_client_); } |
172 }; | 175 }; |
173 | 176 |
174 | 177 bool EnsureFileOfSize(const base::FilePath& file_path, int64_t length) { |
175 bool EnsureFileOfSize(const base::FilePath& file_path, int64 length) { | |
176 base::File file(file_path, | 178 base::File file(file_path, |
177 base::File::FLAG_OPEN_ALWAYS | base::File::FLAG_WRITE); | 179 base::File::FLAG_OPEN_ALWAYS | base::File::FLAG_WRITE); |
178 if (!file.IsValid()) | 180 if (!file.IsValid()) |
179 return false; | 181 return false; |
180 return file.SetLength(length); | 182 return file.SetLength(length); |
181 } | 183 } |
182 | 184 |
183 } // namespace | 185 } // namespace |
184 | 186 |
185 namespace content { | 187 namespace content { |
(...skipping 13 matching lines...) Expand all Loading... |
199 new MockSpecialStoragePolicy; | 201 new MockSpecialStoragePolicy; |
200 special_storage_policy->AddProtected(GURL(kOrigin2Url)); | 202 special_storage_policy->AddProtected(GURL(kOrigin2Url)); |
201 scoped_refptr<DatabaseTracker> tracker( | 203 scoped_refptr<DatabaseTracker> tracker( |
202 new DatabaseTracker(temp_dir.path(), | 204 new DatabaseTracker(temp_dir.path(), |
203 incognito_mode, | 205 incognito_mode, |
204 special_storage_policy.get(), | 206 special_storage_policy.get(), |
205 NULL, | 207 NULL, |
206 NULL)); | 208 NULL)); |
207 | 209 |
208 // Create and open three databases. | 210 // Create and open three databases. |
209 int64 database_size = 0; | 211 int64_t database_size = 0; |
210 const std::string kOrigin1 = | 212 const std::string kOrigin1 = |
211 storage::GetIdentifierFromOrigin(GURL(kOrigin1Url)); | 213 storage::GetIdentifierFromOrigin(GURL(kOrigin1Url)); |
212 const std::string kOrigin2 = | 214 const std::string kOrigin2 = |
213 storage::GetIdentifierFromOrigin(GURL(kOrigin2Url)); | 215 storage::GetIdentifierFromOrigin(GURL(kOrigin2Url)); |
214 const base::string16 kDB1 = ASCIIToUTF16("db1"); | 216 const base::string16 kDB1 = ASCIIToUTF16("db1"); |
215 const base::string16 kDB2 = ASCIIToUTF16("db2"); | 217 const base::string16 kDB2 = ASCIIToUTF16("db2"); |
216 const base::string16 kDB3 = ASCIIToUTF16("db3"); | 218 const base::string16 kDB3 = ASCIIToUTF16("db3"); |
217 const base::string16 kDescription = ASCIIToUTF16("database_description"); | 219 const base::string16 kDescription = ASCIIToUTF16("database_description"); |
218 | 220 |
219 tracker->DatabaseOpened(kOrigin1, kDB1, kDescription, 0, | 221 tracker->DatabaseOpened(kOrigin1, kDB1, kDescription, 0, |
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
313 NULL, | 315 NULL, |
314 NULL)); | 316 NULL)); |
315 | 317 |
316 // Add two observers. | 318 // Add two observers. |
317 TestObserver observer1; | 319 TestObserver observer1; |
318 TestObserver observer2; | 320 TestObserver observer2; |
319 tracker->AddObserver(&observer1); | 321 tracker->AddObserver(&observer1); |
320 tracker->AddObserver(&observer2); | 322 tracker->AddObserver(&observer2); |
321 | 323 |
322 // Open three new databases. | 324 // Open three new databases. |
323 int64 database_size = 0; | 325 int64_t database_size = 0; |
324 const std::string kOrigin1 = | 326 const std::string kOrigin1 = |
325 storage::GetIdentifierFromOrigin(GURL(kOrigin1Url)); | 327 storage::GetIdentifierFromOrigin(GURL(kOrigin1Url)); |
326 const std::string kOrigin2 = | 328 const std::string kOrigin2 = |
327 storage::GetIdentifierFromOrigin(GURL(kOrigin2Url)); | 329 storage::GetIdentifierFromOrigin(GURL(kOrigin2Url)); |
328 const base::string16 kDB1 = ASCIIToUTF16("db1"); | 330 const base::string16 kDB1 = ASCIIToUTF16("db1"); |
329 const base::string16 kDB2 = ASCIIToUTF16("db2"); | 331 const base::string16 kDB2 = ASCIIToUTF16("db2"); |
330 const base::string16 kDB3 = ASCIIToUTF16("db3"); | 332 const base::string16 kDB3 = ASCIIToUTF16("db3"); |
331 const base::string16 kDescription = ASCIIToUTF16("database_description"); | 333 const base::string16 kDescription = ASCIIToUTF16("database_description"); |
332 | 334 |
333 // Get the info for kOrigin1 and kOrigin2 | 335 // Get the info for kOrigin1 and kOrigin2 |
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
463 new DatabaseTracker(temp_dir.path(), | 465 new DatabaseTracker(temp_dir.path(), |
464 false /* incognito */, | 466 false /* incognito */, |
465 NULL, | 467 NULL, |
466 test_quota_proxy.get(), | 468 test_quota_proxy.get(), |
467 NULL)); | 469 NULL)); |
468 EXPECT_TRUE(test_quota_proxy->registered_client_); | 470 EXPECT_TRUE(test_quota_proxy->registered_client_); |
469 | 471 |
470 // Create a database and modify it a couple of times, close it, | 472 // Create a database and modify it a couple of times, close it, |
471 // then delete it. Observe the tracker notifies accordingly. | 473 // then delete it. Observe the tracker notifies accordingly. |
472 | 474 |
473 int64 database_size = 0; | 475 int64_t database_size = 0; |
474 tracker->DatabaseOpened(kOriginId, kName, kDescription, 0, | 476 tracker->DatabaseOpened(kOriginId, kName, kDescription, 0, |
475 &database_size); | 477 &database_size); |
476 EXPECT_TRUE(test_quota_proxy->WasAccessNotified(kOrigin)); | 478 EXPECT_TRUE(test_quota_proxy->WasAccessNotified(kOrigin)); |
477 test_quota_proxy->reset(); | 479 test_quota_proxy->reset(); |
478 | 480 |
479 base::FilePath db_file(tracker->GetFullDBFilePath(kOriginId, kName)); | 481 base::FilePath db_file(tracker->GetFullDBFilePath(kOriginId, kName)); |
480 EXPECT_TRUE(base::CreateDirectory(db_file.DirName())); | 482 EXPECT_TRUE(base::CreateDirectory(db_file.DirName())); |
481 EXPECT_TRUE(EnsureFileOfSize(db_file, 10)); | 483 EXPECT_TRUE(EnsureFileOfSize(db_file, 10)); |
482 tracker->DatabaseModified(kOriginId, kName); | 484 tracker->DatabaseModified(kOriginId, kName); |
483 EXPECT_TRUE(test_quota_proxy->WasModificationNotified(kOrigin, 10)); | 485 EXPECT_TRUE(test_quota_proxy->WasModificationNotified(kOrigin, 10)); |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
538 EXPECT_FALSE(test_quota_proxy->WasModificationNotified(kOrigin, 100)); | 540 EXPECT_FALSE(test_quota_proxy->WasModificationNotified(kOrigin, 100)); |
539 tracker->CloseDatabases(crashed_renderer_connections); | 541 tracker->CloseDatabases(crashed_renderer_connections); |
540 EXPECT_TRUE(test_quota_proxy->WasModificationNotified(kOrigin, 100)); | 542 EXPECT_TRUE(test_quota_proxy->WasModificationNotified(kOrigin, 100)); |
541 | 543 |
542 // Cleanup. | 544 // Cleanup. |
543 crashed_renderer_connections.RemoveAllConnections(); | 545 crashed_renderer_connections.RemoveAllConnections(); |
544 test_quota_proxy->SimulateQuotaManagerDestroyed(); | 546 test_quota_proxy->SimulateQuotaManagerDestroyed(); |
545 } | 547 } |
546 | 548 |
547 static void DatabaseTrackerClearSessionOnlyDatabasesOnExit() { | 549 static void DatabaseTrackerClearSessionOnlyDatabasesOnExit() { |
548 int64 database_size = 0; | 550 int64_t database_size = 0; |
549 const std::string kOrigin1 = | 551 const std::string kOrigin1 = |
550 storage::GetIdentifierFromOrigin(GURL(kOrigin1Url)); | 552 storage::GetIdentifierFromOrigin(GURL(kOrigin1Url)); |
551 const std::string kOrigin2 = | 553 const std::string kOrigin2 = |
552 storage::GetIdentifierFromOrigin(GURL(kOrigin2Url)); | 554 storage::GetIdentifierFromOrigin(GURL(kOrigin2Url)); |
553 const base::string16 kDB1 = ASCIIToUTF16("db1"); | 555 const base::string16 kDB1 = ASCIIToUTF16("db1"); |
554 const base::string16 kDB2 = ASCIIToUTF16("db2"); | 556 const base::string16 kDB2 = ASCIIToUTF16("db2"); |
555 const base::string16 kDescription = ASCIIToUTF16("database_description"); | 557 const base::string16 kDescription = ASCIIToUTF16("database_description"); |
556 | 558 |
557 // Initialize the tracker database. | 559 // Initialize the tracker database. |
558 base::MessageLoop message_loop; | 560 base::MessageLoop message_loop; |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
615 base::PathExists(tracker->GetFullDBFilePath(kOrigin1, kDB1))); | 617 base::PathExists(tracker->GetFullDBFilePath(kOrigin1, kDB1))); |
616 EXPECT_EQ(base::FilePath(), tracker->GetFullDBFilePath(kOrigin2, kDB2)); | 618 EXPECT_EQ(base::FilePath(), tracker->GetFullDBFilePath(kOrigin2, kDB2)); |
617 | 619 |
618 // The origin directory of kOrigin1 remains, but the origin directory of | 620 // The origin directory of kOrigin1 remains, but the origin directory of |
619 // kOrigin2 is deleted. | 621 // kOrigin2 is deleted. |
620 EXPECT_TRUE(base::PathExists(origin1_db_dir)); | 622 EXPECT_TRUE(base::PathExists(origin1_db_dir)); |
621 EXPECT_FALSE(base::PathExists(origin2_db_dir)); | 623 EXPECT_FALSE(base::PathExists(origin2_db_dir)); |
622 } | 624 } |
623 | 625 |
624 static void DatabaseTrackerSetForceKeepSessionState() { | 626 static void DatabaseTrackerSetForceKeepSessionState() { |
625 int64 database_size = 0; | 627 int64_t database_size = 0; |
626 const std::string kOrigin1 = | 628 const std::string kOrigin1 = |
627 storage::GetIdentifierFromOrigin(GURL(kOrigin1Url)); | 629 storage::GetIdentifierFromOrigin(GURL(kOrigin1Url)); |
628 const std::string kOrigin2 = | 630 const std::string kOrigin2 = |
629 storage::GetIdentifierFromOrigin(GURL(kOrigin2Url)); | 631 storage::GetIdentifierFromOrigin(GURL(kOrigin2Url)); |
630 const base::string16 kDB1 = ASCIIToUTF16("db1"); | 632 const base::string16 kDB1 = ASCIIToUTF16("db1"); |
631 const base::string16 kDB2 = ASCIIToUTF16("db2"); | 633 const base::string16 kDB2 = ASCIIToUTF16("db2"); |
632 const base::string16 kDescription = ASCIIToUTF16("database_description"); | 634 const base::string16 kDescription = ASCIIToUTF16("database_description"); |
633 | 635 |
634 // Initialize the tracker database. | 636 // Initialize the tracker database. |
635 base::MessageLoop message_loop; | 637 base::MessageLoop message_loop; |
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
711 scoped_refptr<DatabaseTracker> tracker( | 713 scoped_refptr<DatabaseTracker> tracker( |
712 new DatabaseTracker(temp_dir.path(), kUseInMemoryTrackerDatabase, | 714 new DatabaseTracker(temp_dir.path(), kUseInMemoryTrackerDatabase, |
713 NULL, NULL, NULL)); | 715 NULL, NULL, NULL)); |
714 | 716 |
715 // Starts off with no databases. | 717 // Starts off with no databases. |
716 std::vector<OriginInfo> infos; | 718 std::vector<OriginInfo> infos; |
717 EXPECT_TRUE(tracker->GetAllOriginsInfo(&infos)); | 719 EXPECT_TRUE(tracker->GetAllOriginsInfo(&infos)); |
718 EXPECT_TRUE(infos.empty()); | 720 EXPECT_TRUE(infos.empty()); |
719 | 721 |
720 // Create a db with an empty name. | 722 // Create a db with an empty name. |
721 int64 database_size = -1; | 723 int64_t database_size = -1; |
722 tracker->DatabaseOpened(kOriginId, kEmptyName, kDescription, 0, | 724 tracker->DatabaseOpened(kOriginId, kEmptyName, kDescription, 0, |
723 &database_size); | 725 &database_size); |
724 EXPECT_EQ(0, database_size); | 726 EXPECT_EQ(0, database_size); |
725 tracker->DatabaseModified(kOriginId, kEmptyName); | 727 tracker->DatabaseModified(kOriginId, kEmptyName); |
726 EXPECT_TRUE(tracker->GetAllOriginsInfo(&infos)); | 728 EXPECT_TRUE(tracker->GetAllOriginsInfo(&infos)); |
727 EXPECT_EQ(1u, infos.size()); | 729 EXPECT_EQ(1u, infos.size()); |
728 EXPECT_EQ(kDescription, infos[0].GetDatabaseDescription(kEmptyName)); | 730 EXPECT_EQ(kDescription, infos[0].GetDatabaseDescription(kEmptyName)); |
729 EXPECT_FALSE(tracker->GetFullDBFilePath(kOriginId, kEmptyName).empty()); | 731 EXPECT_FALSE(tracker->GetFullDBFilePath(kOriginId, kEmptyName).empty()); |
730 tracker->DatabaseOpened(kOriginId, kEmptyName, kChangedDescription, 0, | 732 tracker->DatabaseOpened(kOriginId, kEmptyName, kChangedDescription, 0, |
731 &database_size); | 733 &database_size); |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
763 tracker->AddObserver(&observer); | 765 tracker->AddObserver(&observer); |
764 | 766 |
765 // Verify does no harm when there is no such database. | 767 // Verify does no harm when there is no such database. |
766 tracker->HandleSqliteError(kOriginId, kName, SQLITE_CORRUPT); | 768 tracker->HandleSqliteError(kOriginId, kName, SQLITE_CORRUPT); |
767 EXPECT_FALSE(tracker->IsDatabaseScheduledForDeletion(kOriginId, kName)); | 769 EXPECT_FALSE(tracker->IsDatabaseScheduledForDeletion(kOriginId, kName)); |
768 EXPECT_FALSE(observer.DidReceiveNewNotification()); | 770 EXPECT_FALSE(observer.DidReceiveNewNotification()); |
769 | 771 |
770 // -------------------------------------------------------- | 772 // -------------------------------------------------------- |
771 // Create a record of a database in the tracker db and create | 773 // Create a record of a database in the tracker db and create |
772 // a spoof_db_file on disk in the expected location. | 774 // a spoof_db_file on disk in the expected location. |
773 int64 database_size = 0; | 775 int64_t database_size = 0; |
774 tracker->DatabaseOpened(kOriginId, kName, kDescription, 0, | 776 tracker->DatabaseOpened(kOriginId, kName, kDescription, 0, |
775 &database_size); | 777 &database_size); |
776 base::FilePath spoof_db_file = tracker->GetFullDBFilePath(kOriginId, kName); | 778 base::FilePath spoof_db_file = tracker->GetFullDBFilePath(kOriginId, kName); |
777 EXPECT_FALSE(tracker->GetFullDBFilePath(kOriginId, kName).empty()); | 779 EXPECT_FALSE(tracker->GetFullDBFilePath(kOriginId, kName).empty()); |
778 EXPECT_TRUE(base::CreateDirectory(spoof_db_file.DirName())); | 780 EXPECT_TRUE(base::CreateDirectory(spoof_db_file.DirName())); |
779 EXPECT_TRUE(EnsureFileOfSize(spoof_db_file, 1)); | 781 EXPECT_TRUE(EnsureFileOfSize(spoof_db_file, 1)); |
780 | 782 |
781 // Verify does no harm with a non-error is reported. | 783 // Verify does no harm with a non-error is reported. |
782 tracker->HandleSqliteError(kOriginId, kName, SQLITE_OK); | 784 tracker->HandleSqliteError(kOriginId, kName, SQLITE_OK); |
783 EXPECT_FALSE(tracker->IsDatabaseScheduledForDeletion(kOriginId, kName)); | 785 EXPECT_FALSE(tracker->IsDatabaseScheduledForDeletion(kOriginId, kName)); |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
854 | 856 |
855 TEST(DatabaseTrackerTest, EmptyDatabaseNameIsValid) { | 857 TEST(DatabaseTrackerTest, EmptyDatabaseNameIsValid) { |
856 DatabaseTracker_TestHelper_Test::EmptyDatabaseNameIsValid(); | 858 DatabaseTracker_TestHelper_Test::EmptyDatabaseNameIsValid(); |
857 } | 859 } |
858 | 860 |
859 TEST(DatabaseTrackerTest, HandleSqliteError) { | 861 TEST(DatabaseTrackerTest, HandleSqliteError) { |
860 DatabaseTracker_TestHelper_Test::HandleSqliteError(); | 862 DatabaseTracker_TestHelper_Test::HandleSqliteError(); |
861 } | 863 } |
862 | 864 |
863 } // namespace content | 865 } // namespace content |
OLD | NEW |