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

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

Issue 2672753002: Refactor History's CommitLaterTask with CancelableCallback (Closed)
Patch Set: Explicitly close TestHistoryBackend. Created 3 years, 10 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
« no previous file with comments | « no previous file | components/history/core/browser/history_backend.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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
11 #include <memory> 11 #include <memory>
12 #include <set> 12 #include <set>
13 #include <string> 13 #include <string>
14 #include <utility> 14 #include <utility>
15 #include <vector> 15 #include <vector>
16 16
17 #include "base/cancelable_callback.h"
17 #include "base/containers/hash_tables.h" 18 #include "base/containers/hash_tables.h"
18 #include "base/containers/mru_cache.h" 19 #include "base/containers/mru_cache.h"
19 #include "base/files/file_path.h" 20 #include "base/files/file_path.h"
20 #include "base/gtest_prod_util.h" 21 #include "base/gtest_prod_util.h"
21 #include "base/macros.h" 22 #include "base/macros.h"
22 #include "base/memory/memory_pressure_listener.h" 23 #include "base/memory/memory_pressure_listener.h"
23 #include "base/observer_list.h" 24 #include "base/observer_list.h"
24 #include "base/single_thread_task_runner.h" 25 #include "base/single_thread_task_runner.h"
25 #include "base/supports_user_data.h" 26 #include "base/supports_user_data.h"
26 #include "base/task/cancelable_task_tracker.h" 27 #include "base/task/cancelable_task_tracker.h"
27 #include "build/build_config.h" 28 #include "build/build_config.h"
28 #include "components/favicon_base/favicon_usage_data.h" 29 #include "components/favicon_base/favicon_usage_data.h"
29 #include "components/history/core/browser/expire_history_backend.h" 30 #include "components/history/core/browser/expire_history_backend.h"
30 #include "components/history/core/browser/history_backend_notifier.h" 31 #include "components/history/core/browser/history_backend_notifier.h"
31 #include "components/history/core/browser/history_types.h" 32 #include "components/history/core/browser/history_types.h"
32 #include "components/history/core/browser/keyword_id.h" 33 #include "components/history/core/browser/keyword_id.h"
33 #include "components/history/core/browser/thumbnail_database.h" 34 #include "components/history/core/browser/thumbnail_database.h"
34 #include "components/history/core/browser/visit_tracker.h" 35 #include "components/history/core/browser/visit_tracker.h"
35 #include "sql/init_status.h" 36 #include "sql/init_status.h"
36 37
37 class SkBitmap; 38 class SkBitmap;
38 class TestingProfile; 39 class TestingProfile;
39 40
40 namespace base { 41 namespace base {
41 class SingleThreadTaskRunner; 42 class SingleThreadTaskRunner;
42 } 43 }
43 44
44 namespace history { 45 namespace history {
45 class CommitLaterTask;
46 struct DownloadRow; 46 struct DownloadRow;
47 class HistoryBackendClient; 47 class HistoryBackendClient;
48 class HistoryBackendDBBaseTest; 48 class HistoryBackendDBBaseTest;
49 class HistoryBackendObserver; 49 class HistoryBackendObserver;
50 class HistoryBackendTest; 50 class HistoryBackendTest;
51 class HistoryDatabase; 51 class HistoryDatabase;
52 struct HistoryDatabaseParams; 52 struct HistoryDatabaseParams;
53 class HistoryDBTask; 53 class HistoryDBTask;
54 class InMemoryHistoryBackend; 54 class InMemoryHistoryBackend;
55 class TypedUrlSyncableService; 55 class TypedUrlSyncableService;
(...skipping 417 matching lines...) Expand 10 before | Expand all | Expand 10 after
473 // code to avoid syncing visits that would immediately be expired). 473 // code to avoid syncing visits that would immediately be expired).
474 virtual bool IsExpiredVisitTime(const base::Time& time); 474 virtual bool IsExpiredVisitTime(const base::Time& time);
475 475
476 base::Time GetFirstRecordedTimeForTest() { return first_recorded_time_; } 476 base::Time GetFirstRecordedTimeForTest() { return first_recorded_time_; }
477 477
478 protected: 478 protected:
479 ~HistoryBackend() override; 479 ~HistoryBackend() override;
480 480
481 private: 481 private:
482 friend class base::RefCountedThreadSafe<HistoryBackend>; 482 friend class base::RefCountedThreadSafe<HistoryBackend>;
483 friend class CommitLaterTask; // The commit task needs to call Commit().
484 friend class HistoryBackendTest; 483 friend class HistoryBackendTest;
485 friend class HistoryBackendDBBaseTest; // So the unit tests can poke our 484 friend class HistoryBackendDBBaseTest; // So the unit tests can poke our
486 // innards. 485 // innards.
487 FRIEND_TEST_ALL_PREFIXES(HistoryBackendTest, DeleteAll); 486 FRIEND_TEST_ALL_PREFIXES(HistoryBackendTest, DeleteAll);
488 FRIEND_TEST_ALL_PREFIXES(HistoryBackendTest, DeleteAllURLPreviouslyDeleted); 487 FRIEND_TEST_ALL_PREFIXES(HistoryBackendTest, DeleteAllURLPreviouslyDeleted);
489 FRIEND_TEST_ALL_PREFIXES(HistoryBackendTest, DeleteAllThenAddData); 488 FRIEND_TEST_ALL_PREFIXES(HistoryBackendTest, DeleteAllThenAddData);
490 FRIEND_TEST_ALL_PREFIXES(HistoryBackendTest, AddPagesWithDetails); 489 FRIEND_TEST_ALL_PREFIXES(HistoryBackendTest, AddPagesWithDetails);
491 FRIEND_TEST_ALL_PREFIXES(HistoryBackendTest, UpdateURLs); 490 FRIEND_TEST_ALL_PREFIXES(HistoryBackendTest, UpdateURLs);
492 FRIEND_TEST_ALL_PREFIXES(HistoryBackendTest, ImportedFaviconsTest); 491 FRIEND_TEST_ALL_PREFIXES(HistoryBackendTest, ImportedFaviconsTest);
493 FRIEND_TEST_ALL_PREFIXES(HistoryBackendTest, URLsNoLongerBookmarked); 492 FRIEND_TEST_ALL_PREFIXES(HistoryBackendTest, URLsNoLongerBookmarked);
(...skipping 327 matching lines...) Expand 10 before | Expand all | Expand 10 after
821 // if it is. The thumbnail DB may be null when the history one isn't, but not 820 // if it is. The thumbnail DB may be null when the history one isn't, but not
822 // vice-versa. 821 // vice-versa.
823 std::unique_ptr<HistoryDatabase> db_; 822 std::unique_ptr<HistoryDatabase> db_;
824 bool scheduled_kill_db_; // Database is being killed due to error. 823 bool scheduled_kill_db_; // Database is being killed due to error.
825 std::unique_ptr<ThumbnailDatabase> thumbnail_db_; 824 std::unique_ptr<ThumbnailDatabase> thumbnail_db_;
826 825
827 // Manages expiration between the various databases. 826 // Manages expiration between the various databases.
828 ExpireHistoryBackend expirer_; 827 ExpireHistoryBackend expirer_;
829 828
830 // A commit has been scheduled to occur sometime in the future. We can check 829 // A commit has been scheduled to occur sometime in the future. We can check
831 // non-null-ness to see if there is a commit scheduled in the future, and we 830 // !IsCancelled() to see if there is a commit scheduled in the future (note
832 // can use the pointer to cancel the scheduled commit. There can be only one 831 // that CancelableClosure starts cancelled with the default constructor), and
832 // we can use Cancel() to cancel the scheduled commit. There can be only one
833 // scheduled commit at a time (see ScheduleCommit). 833 // scheduled commit at a time (see ScheduleCommit).
834 scoped_refptr<CommitLaterTask> scheduled_commit_; 834 base::CancelableClosure scheduled_commit_;
835 835
836 // Maps recent redirect destination pages to the chain of redirects that 836 // Maps recent redirect destination pages to the chain of redirects that
837 // brought us to there. Pages that did not have redirects or were not the 837 // brought us to there. Pages that did not have redirects or were not the
838 // final redirect in a chain will not be in this list, as well as pages that 838 // final redirect in a chain will not be in this list, as well as pages that
839 // redirected "too long" ago (as determined by ExpireOldRedirects above). 839 // redirected "too long" ago (as determined by ExpireOldRedirects above).
840 // It is used to set titles & favicons for redirects to that of the 840 // It is used to set titles & favicons for redirects to that of the
841 // destination. 841 // destination.
842 // 842 //
843 // As with AddPage, the last item in the redirect chain will be the 843 // As with AddPage, the last item in the redirect chain will be the
844 // destination of the redirect (i.e., the key into recent_redirects_); 844 // destination of the redirect (i.e., the key into recent_redirects_);
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
889 889
890 // List of observers 890 // List of observers
891 base::ObserverList<HistoryBackendObserver> observers_; 891 base::ObserverList<HistoryBackendObserver> observers_;
892 892
893 DISALLOW_COPY_AND_ASSIGN(HistoryBackend); 893 DISALLOW_COPY_AND_ASSIGN(HistoryBackend);
894 }; 894 };
895 895
896 } // namespace history 896 } // namespace history
897 897
898 #endif // COMPONENTS_HISTORY_CORE_BROWSER_HISTORY_BACKEND_H_ 898 #endif // COMPONENTS_HISTORY_CORE_BROWSER_HISTORY_BACKEND_H_
OLDNEW
« no previous file with comments | « no previous file | components/history/core/browser/history_backend.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698