| 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 14 matching lines...) Expand all Loading... |
| 25 #include "base/supports_user_data.h" | 25 #include "base/supports_user_data.h" |
| 26 #include "base/task/cancelable_task_tracker.h" | 26 #include "base/task/cancelable_task_tracker.h" |
| 27 #include "build/build_config.h" | 27 #include "build/build_config.h" |
| 28 #include "components/favicon_base/favicon_usage_data.h" | 28 #include "components/favicon_base/favicon_usage_data.h" |
| 29 #include "components/history/core/browser/expire_history_backend.h" | 29 #include "components/history/core/browser/expire_history_backend.h" |
| 30 #include "components/history/core/browser/history_backend_notifier.h" | 30 #include "components/history/core/browser/history_backend_notifier.h" |
| 31 #include "components/history/core/browser/history_types.h" | 31 #include "components/history/core/browser/history_types.h" |
| 32 #include "components/history/core/browser/keyword_id.h" | 32 #include "components/history/core/browser/keyword_id.h" |
| 33 #include "components/history/core/browser/thumbnail_database.h" | 33 #include "components/history/core/browser/thumbnail_database.h" |
| 34 #include "components/history/core/browser/visit_tracker.h" | 34 #include "components/history/core/browser/visit_tracker.h" |
| 35 #include "components/memory_coordinator/common/memory_coordinator_client.h" | |
| 36 #include "sql/init_status.h" | 35 #include "sql/init_status.h" |
| 37 | 36 |
| 38 class HistoryURLProvider; | 37 class HistoryURLProvider; |
| 39 struct HistoryURLProviderParams; | 38 struct HistoryURLProviderParams; |
| 40 class SkBitmap; | 39 class SkBitmap; |
| 41 class TestingProfile; | 40 class TestingProfile; |
| 42 struct ThumbnailScore; | 41 struct ThumbnailScore; |
| 43 | 42 |
| 44 namespace base { | 43 namespace base { |
| 45 class MessageLoop; | 44 class MessageLoop; |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 96 // Internal history implementation which does most of the work of the history | 95 // Internal history implementation which does most of the work of the history |
| 97 // system. This runs on a background thread (to not block the browser when we | 96 // system. This runs on a background thread (to not block the browser when we |
| 98 // do expensive operations) and is NOT threadsafe, so it must only be called | 97 // do expensive operations) and is NOT threadsafe, so it must only be called |
| 99 // from message handlers on the background thread. Invoking on another thread | 98 // from message handlers on the background thread. Invoking on another thread |
| 100 // requires threadsafe refcounting. | 99 // requires threadsafe refcounting. |
| 101 // | 100 // |
| 102 // Most functions here are just the implementations of the corresponding | 101 // Most functions here are just the implementations of the corresponding |
| 103 // functions in the history service. These functions are not documented | 102 // functions in the history service. These functions are not documented |
| 104 // here, see the history service for behavior. | 103 // here, see the history service for behavior. |
| 105 class HistoryBackend : public base::RefCountedThreadSafe<HistoryBackend>, | 104 class HistoryBackend : public base::RefCountedThreadSafe<HistoryBackend>, |
| 106 public HistoryBackendNotifier, | 105 public HistoryBackendNotifier { |
| 107 public memory_coordinator::MemoryCoordinatorClient { | |
| 108 public: | 106 public: |
| 109 // Interface implemented by the owner of the HistoryBackend object. Normally, | 107 // Interface implemented by the owner of the HistoryBackend object. Normally, |
| 110 // the history service implements this to send stuff back to the main thread. | 108 // the history service implements this to send stuff back to the main thread. |
| 111 // The unit tests can provide a different implementation if they don't have | 109 // The unit tests can provide a different implementation if they don't have |
| 112 // a history service object. | 110 // a history service object. |
| 113 class Delegate { | 111 class Delegate { |
| 114 public: | 112 public: |
| 115 virtual ~Delegate() {} | 113 virtual ~Delegate() {} |
| 116 | 114 |
| 117 // Called when the database cannot be read correctly for some reason. | 115 // Called when the database cannot be read correctly for some reason. |
| (...skipping 355 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 473 | 471 |
| 474 ExpireHistoryBackend* expire_backend() { return &expirer_; } | 472 ExpireHistoryBackend* expire_backend() { return &expirer_; } |
| 475 #endif | 473 #endif |
| 476 | 474 |
| 477 // Returns true if the passed visit time is already expired (used by the sync | 475 // Returns true if the passed visit time is already expired (used by the sync |
| 478 // code to avoid syncing visits that would immediately be expired). | 476 // code to avoid syncing visits that would immediately be expired). |
| 479 virtual bool IsExpiredVisitTime(const base::Time& time); | 477 virtual bool IsExpiredVisitTime(const base::Time& time); |
| 480 | 478 |
| 481 base::Time GetFirstRecordedTimeForTest() { return first_recorded_time_; } | 479 base::Time GetFirstRecordedTimeForTest() { return first_recorded_time_; } |
| 482 | 480 |
| 483 // memory_coordinator::MemoryCoordinatorClient implementation: | |
| 484 void OnMemoryStateChange(memory_coordinator::MemoryState state) override; | |
| 485 | |
| 486 protected: | 481 protected: |
| 487 ~HistoryBackend() override; | 482 ~HistoryBackend() override; |
| 488 | 483 |
| 489 private: | 484 private: |
| 490 friend class base::RefCountedThreadSafe<HistoryBackend>; | 485 friend class base::RefCountedThreadSafe<HistoryBackend>; |
| 491 friend class CommitLaterTask; // The commit task needs to call Commit(). | 486 friend class CommitLaterTask; // The commit task needs to call Commit(). |
| 492 friend class HistoryBackendTest; | 487 friend class HistoryBackendTest; |
| 493 friend class HistoryBackendDBBaseTest; // So the unit tests can poke our | 488 friend class HistoryBackendDBBaseTest; // So the unit tests can poke our |
| 494 // innards. | 489 // innards. |
| 495 FRIEND_TEST_ALL_PREFIXES(HistoryBackendTest, DeleteAll); | 490 FRIEND_TEST_ALL_PREFIXES(HistoryBackendTest, DeleteAll); |
| (...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 577 // Returns the name of the Favicons database. This is the new name | 572 // Returns the name of the Favicons database. This is the new name |
| 578 // of the Thumbnails database. | 573 // of the Thumbnails database. |
| 579 base::FilePath GetFaviconsFileName() const; | 574 base::FilePath GetFaviconsFileName() const; |
| 580 | 575 |
| 581 class URLQuerier; | 576 class URLQuerier; |
| 582 friend class URLQuerier; | 577 friend class URLQuerier; |
| 583 | 578 |
| 584 // Does the work of Init. | 579 // Does the work of Init. |
| 585 void InitImpl(const HistoryDatabaseParams& history_database_params); | 580 void InitImpl(const HistoryDatabaseParams& history_database_params); |
| 586 | 581 |
| 587 // Asks database to trim memory. | |
| 588 void TrimMemory(bool trim_aggressively); | |
| 589 | |
| 590 // Called when the system is under memory pressure. | 582 // Called when the system is under memory pressure. |
| 591 void OnMemoryPressure( | 583 void OnMemoryPressure( |
| 592 base::MemoryPressureListener::MemoryPressureLevel memory_pressure_level); | 584 base::MemoryPressureListener::MemoryPressureLevel memory_pressure_level); |
| 593 | 585 |
| 594 // Closes all databases managed by HistoryBackend. Commits any pending | 586 // Closes all databases managed by HistoryBackend. Commits any pending |
| 595 // transactions. | 587 // transactions. |
| 596 void CloseAllDatabases(); | 588 void CloseAllDatabases(); |
| 597 | 589 |
| 598 // Adds a single visit to the database, updating the URL information such | 590 // Adds a single visit to the database, updating the URL information such |
| 599 // as visit and typed count. The visit ID of the added visit and the URL ID | 591 // as visit and typed count. The visit ID of the added visit and the URL ID |
| (...skipping 300 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 900 | 892 |
| 901 // List of observers | 893 // List of observers |
| 902 base::ObserverList<HistoryBackendObserver> observers_; | 894 base::ObserverList<HistoryBackendObserver> observers_; |
| 903 | 895 |
| 904 DISALLOW_COPY_AND_ASSIGN(HistoryBackend); | 896 DISALLOW_COPY_AND_ASSIGN(HistoryBackend); |
| 905 }; | 897 }; |
| 906 | 898 |
| 907 } // namespace history | 899 } // namespace history |
| 908 | 900 |
| 909 #endif // COMPONENTS_HISTORY_CORE_BROWSER_HISTORY_BACKEND_H_ | 901 #endif // COMPONENTS_HISTORY_CORE_BROWSER_HISTORY_BACKEND_H_ |
| OLD | NEW |