| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 <set> | 5 #include <set> |
| 6 #include <vector> | 6 #include <vector> |
| 7 | 7 |
| 8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
| 9 #include "base/file_path.h" | 9 #include "base/file_path.h" |
| 10 #include "base/file_util.h" | 10 #include "base/file_util.h" |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 48 class HistoryBackendTest; | 48 class HistoryBackendTest; |
| 49 | 49 |
| 50 // This must be a separate object since HistoryBackend manages its lifetime. | 50 // This must be a separate object since HistoryBackend manages its lifetime. |
| 51 // This just forwards the messages we're interested in to the test object. | 51 // This just forwards the messages we're interested in to the test object. |
| 52 class HistoryBackendTestDelegate : public HistoryBackend::Delegate { | 52 class HistoryBackendTestDelegate : public HistoryBackend::Delegate { |
| 53 public: | 53 public: |
| 54 explicit HistoryBackendTestDelegate(HistoryBackendTest* test) : test_(test) {} | 54 explicit HistoryBackendTestDelegate(HistoryBackendTest* test) : test_(test) {} |
| 55 | 55 |
| 56 virtual void NotifyProfileError(sql::InitStatus init_status) OVERRIDE {} | 56 virtual void NotifyProfileError(sql::InitStatus init_status) OVERRIDE {} |
| 57 virtual void SetInMemoryBackend(InMemoryHistoryBackend* backend) OVERRIDE; | 57 virtual void SetInMemoryBackend(InMemoryHistoryBackend* backend) OVERRIDE; |
| 58 virtual void BroadcastNotifications(NotificationType type, | 58 virtual void BroadcastNotifications(int type, |
| 59 HistoryDetails* details) OVERRIDE; | 59 HistoryDetails* details) OVERRIDE; |
| 60 virtual void DBLoaded() OVERRIDE; | 60 virtual void DBLoaded() OVERRIDE; |
| 61 virtual void StartTopSitesMigration() OVERRIDE; | 61 virtual void StartTopSitesMigration() OVERRIDE; |
| 62 | 62 |
| 63 private: | 63 private: |
| 64 // Not owned by us. | 64 // Not owned by us. |
| 65 HistoryBackendTest* test_; | 65 HistoryBackendTest* test_; |
| 66 | 66 |
| 67 DISALLOW_COPY_AND_ASSIGN(HistoryBackendTestDelegate); | 67 DISALLOW_COPY_AND_ASSIGN(HistoryBackendTestDelegate); |
| 68 }; | 68 }; |
| (...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 162 backend_->Closing(); | 162 backend_->Closing(); |
| 163 backend_ = NULL; | 163 backend_ = NULL; |
| 164 mem_backend_.reset(); | 164 mem_backend_.reset(); |
| 165 file_util::Delete(test_dir_, true); | 165 file_util::Delete(test_dir_, true); |
| 166 } | 166 } |
| 167 | 167 |
| 168 void SetInMemoryBackend(InMemoryHistoryBackend* backend) { | 168 void SetInMemoryBackend(InMemoryHistoryBackend* backend) { |
| 169 mem_backend_.reset(backend); | 169 mem_backend_.reset(backend); |
| 170 } | 170 } |
| 171 | 171 |
| 172 void BroadcastNotifications(NotificationType type, | 172 void BroadcastNotifications(int type, |
| 173 HistoryDetails* details) { | 173 HistoryDetails* details) { |
| 174 // Send the notifications directly to the in-memory database. | 174 // Send the notifications directly to the in-memory database. |
| 175 Details<HistoryDetails> det(details); | 175 Details<HistoryDetails> det(details); |
| 176 mem_backend_->Observe(type, Source<HistoryBackendTest>(NULL), det); | 176 mem_backend_->Observe(type, Source<HistoryBackendTest>(NULL), det); |
| 177 | 177 |
| 178 // The backend passes ownership of the details pointer to us. | 178 // The backend passes ownership of the details pointer to us. |
| 179 delete details; | 179 delete details; |
| 180 } | 180 } |
| 181 | 181 |
| 182 MessageLoop message_loop_; | 182 MessageLoop message_loop_; |
| 183 FilePath test_dir_; | 183 FilePath test_dir_; |
| 184 }; | 184 }; |
| 185 | 185 |
| 186 void HistoryBackendTestDelegate::SetInMemoryBackend( | 186 void HistoryBackendTestDelegate::SetInMemoryBackend( |
| 187 InMemoryHistoryBackend* backend) { | 187 InMemoryHistoryBackend* backend) { |
| 188 test_->SetInMemoryBackend(backend); | 188 test_->SetInMemoryBackend(backend); |
| 189 } | 189 } |
| 190 | 190 |
| 191 void HistoryBackendTestDelegate::BroadcastNotifications( | 191 void HistoryBackendTestDelegate::BroadcastNotifications( |
| 192 NotificationType type, | 192 int type, |
| 193 HistoryDetails* details) { | 193 HistoryDetails* details) { |
| 194 test_->BroadcastNotifications(type, details); | 194 test_->BroadcastNotifications(type, details); |
| 195 } | 195 } |
| 196 | 196 |
| 197 void HistoryBackendTestDelegate::DBLoaded() { | 197 void HistoryBackendTestDelegate::DBLoaded() { |
| 198 test_->loaded_ = true; | 198 test_->loaded_ = true; |
| 199 } | 199 } |
| 200 | 200 |
| 201 void HistoryBackendTestDelegate::StartTopSitesMigration() { | 201 void HistoryBackendTestDelegate::StartTopSitesMigration() { |
| 202 test_->backend_->MigrateThumbnailsDatabase(); | 202 test_->backend_->MigrateThumbnailsDatabase(); |
| (...skipping 775 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 978 url, icon_id, FAVICON, &replaced)); | 978 url, icon_id, FAVICON, &replaced)); |
| 979 EXPECT_EQ(0, replaced); | 979 EXPECT_EQ(0, replaced); |
| 980 | 980 |
| 981 std::vector<IconMapping> icon_mapping; | 981 std::vector<IconMapping> icon_mapping; |
| 982 EXPECT_TRUE(backend_->thumbnail_db_->GetIconMappingsForPageURL( | 982 EXPECT_TRUE(backend_->thumbnail_db_->GetIconMappingsForPageURL( |
| 983 url, &icon_mapping)); | 983 url, &icon_mapping)); |
| 984 EXPECT_EQ(1u, icon_mapping.size()); | 984 EXPECT_EQ(1u, icon_mapping.size()); |
| 985 } | 985 } |
| 986 | 986 |
| 987 } // namespace history | 987 } // namespace history |
| OLD | NEW |