Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(115)

Side by Side Diff: components/history/core/browser/history_backend.h

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

Powered by Google App Engine
This is Rietveld 408576698