Chromium Code Reviews| 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 #ifndef COMPONENTS_HISTORY_CORE_BROWSER_HISTORY_BACKEND_H_ | 5 #ifndef COMPONENTS_HISTORY_CORE_BROWSER_HISTORY_BACKEND_H_ |
| 6 #define COMPONENTS_HISTORY_CORE_BROWSER_HISTORY_BACKEND_H_ | 6 #define COMPONENTS_HISTORY_CORE_BROWSER_HISTORY_BACKEND_H_ |
| 7 | 7 |
| 8 #include <stddef.h> | 8 #include <stddef.h> |
| 9 #include <stdint.h> | 9 #include <stdint.h> |
| 10 | 10 |
| (...skipping 15 matching lines...) Expand all Loading... | |
| 26 #include "base/supports_user_data.h" | 26 #include "base/supports_user_data.h" |
| 27 #include "base/task/cancelable_task_tracker.h" | 27 #include "base/task/cancelable_task_tracker.h" |
| 28 #include "build/build_config.h" | 28 #include "build/build_config.h" |
| 29 #include "components/favicon_base/favicon_usage_data.h" | 29 #include "components/favicon_base/favicon_usage_data.h" |
| 30 #include "components/history/core/browser/expire_history_backend.h" | 30 #include "components/history/core/browser/expire_history_backend.h" |
| 31 #include "components/history/core/browser/history_backend_notifier.h" | 31 #include "components/history/core/browser/history_backend_notifier.h" |
| 32 #include "components/history/core/browser/history_types.h" | 32 #include "components/history/core/browser/history_types.h" |
| 33 #include "components/history/core/browser/keyword_id.h" | 33 #include "components/history/core/browser/keyword_id.h" |
| 34 #include "components/history/core/browser/thumbnail_database.h" | 34 #include "components/history/core/browser/thumbnail_database.h" |
| 35 #include "components/history/core/browser/visit_tracker.h" | 35 #include "components/history/core/browser/visit_tracker.h" |
| 36 #include "components/sync/model/sync_metadata_store.h" | |
| 36 #include "sql/init_status.h" | 37 #include "sql/init_status.h" |
| 37 | 38 |
| 38 class SkBitmap; | 39 class SkBitmap; |
| 39 class TestingProfile; | 40 class TestingProfile; |
| 40 | 41 |
| 41 namespace base { | 42 namespace base { |
| 42 class SingleThreadTaskRunner; | 43 class SingleThreadTaskRunner; |
| 43 } | 44 } |
| 44 | 45 |
| 45 namespace history { | 46 namespace history { |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 92 // Internal history implementation which does most of the work of the history | 93 // Internal history implementation which does most of the work of the history |
| 93 // system. This runs on a background thread (to not block the browser when we | 94 // system. This runs on a background thread (to not block the browser when we |
| 94 // do expensive operations) and is NOT threadsafe, so it must only be called | 95 // do expensive operations) and is NOT threadsafe, so it must only be called |
| 95 // from message handlers on the background thread. Invoking on another thread | 96 // from message handlers on the background thread. Invoking on another thread |
| 96 // requires threadsafe refcounting. | 97 // requires threadsafe refcounting. |
| 97 // | 98 // |
| 98 // Most functions here are just the implementations of the corresponding | 99 // Most functions here are just the implementations of the corresponding |
| 99 // functions in the history service. These functions are not documented | 100 // functions in the history service. These functions are not documented |
| 100 // here, see the history service for behavior. | 101 // here, see the history service for behavior. |
| 101 class HistoryBackend : public base::RefCountedThreadSafe<HistoryBackend>, | 102 class HistoryBackend : public base::RefCountedThreadSafe<HistoryBackend>, |
| 102 public HistoryBackendNotifier { | 103 public HistoryBackendNotifier, |
| 104 public syncer::SyncMetadataStore { | |
|
pavely
2017/05/01 17:24:16
I don't really like exposing SyncMetadataStore to
| |
| 103 public: | 105 public: |
| 104 // Interface implemented by the owner of the HistoryBackend object. Normally, | 106 // Interface implemented by the owner of the HistoryBackend object. Normally, |
| 105 // the history service implements this to send stuff back to the main thread. | 107 // the history service implements this to send stuff back to the main thread. |
| 106 // The unit tests can provide a different implementation if they don't have | 108 // The unit tests can provide a different implementation if they don't have |
| 107 // a history service object. | 109 // a history service object. |
| 108 class Delegate { | 110 class Delegate { |
| 109 public: | 111 public: |
| 110 virtual ~Delegate() {} | 112 virtual ~Delegate() {} |
| 111 | 113 |
| 112 // Called when the database cannot be read correctly for some reason. | 114 // Called when the database cannot be read correctly for some reason. |
| (...skipping 364 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 477 | 479 |
| 478 ExpireHistoryBackend* expire_backend() { return &expirer_; } | 480 ExpireHistoryBackend* expire_backend() { return &expirer_; } |
| 479 #endif | 481 #endif |
| 480 | 482 |
| 481 // Returns true if the passed visit time is already expired (used by the sync | 483 // Returns true if the passed visit time is already expired (used by the sync |
| 482 // code to avoid syncing visits that would immediately be expired). | 484 // code to avoid syncing visits that would immediately be expired). |
| 483 virtual bool IsExpiredVisitTime(const base::Time& time); | 485 virtual bool IsExpiredVisitTime(const base::Time& time); |
| 484 | 486 |
| 485 base::Time GetFirstRecordedTimeForTest() { return first_recorded_time_; } | 487 base::Time GetFirstRecordedTimeForTest() { return first_recorded_time_; } |
| 486 | 488 |
| 489 // syncer::SyncMetadataStore implementation. | |
| 490 bool UpdateSyncMetadata(syncer::ModelType model_type, | |
| 491 const std::string& storage_key, | |
| 492 const sync_pb::EntityMetadata& metadata) override; | |
| 493 bool ClearSyncMetadata(syncer::ModelType model_type, | |
| 494 const std::string& storage_key) override; | |
| 495 bool UpdateModelTypeState( | |
| 496 syncer::ModelType model_type, | |
| 497 const sync_pb::ModelTypeState& model_type_state) override; | |
| 498 bool ClearModelTypeState(syncer::ModelType model_type) override; | |
| 499 | |
| 487 protected: | 500 protected: |
| 488 ~HistoryBackend() override; | 501 ~HistoryBackend() override; |
| 489 | 502 |
| 490 private: | 503 private: |
| 491 friend class base::RefCountedThreadSafe<HistoryBackend>; | 504 friend class base::RefCountedThreadSafe<HistoryBackend>; |
| 492 friend class HistoryBackendTest; | 505 friend class HistoryBackendTest; |
| 493 friend class HistoryBackendDBBaseTest; // So the unit tests can poke our | 506 friend class HistoryBackendDBBaseTest; // So the unit tests can poke our |
| 494 // innards. | 507 // innards. |
| 495 FRIEND_TEST_ALL_PREFIXES(HistoryBackendTest, DeleteAll); | 508 FRIEND_TEST_ALL_PREFIXES(HistoryBackendTest, DeleteAll); |
| 496 FRIEND_TEST_ALL_PREFIXES(HistoryBackendTest, DeleteAllURLPreviouslyDeleted); | 509 FRIEND_TEST_ALL_PREFIXES(HistoryBackendTest, DeleteAllURLPreviouslyDeleted); |
| (...skipping 422 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 919 // it unregisters itself as observer during destruction. | 932 // it unregisters itself as observer during destruction. |
| 920 std::unique_ptr<TypedUrlSyncableService> typed_url_syncable_service_; | 933 std::unique_ptr<TypedUrlSyncableService> typed_url_syncable_service_; |
| 921 std::unique_ptr<TypedURLSyncBridge> typed_url_sync_bridge_; | 934 std::unique_ptr<TypedURLSyncBridge> typed_url_sync_bridge_; |
| 922 | 935 |
| 923 DISALLOW_COPY_AND_ASSIGN(HistoryBackend); | 936 DISALLOW_COPY_AND_ASSIGN(HistoryBackend); |
| 924 }; | 937 }; |
| 925 | 938 |
| 926 } // namespace history | 939 } // namespace history |
| 927 | 940 |
| 928 #endif // COMPONENTS_HISTORY_CORE_BROWSER_HISTORY_BACKEND_H_ | 941 #endif // COMPONENTS_HISTORY_CORE_BROWSER_HISTORY_BACKEND_H_ |
| OLD | NEW |