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

Side by Side Diff: chrome/browser/history/history_service.h

Issue 305443004: Introduce HistoryClient interface (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@371825
Patch Set: Introduce chrome_history_client Created 6 years, 6 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 CHROME_BROWSER_HISTORY_HISTORY_SERVICE_H_ 5 #ifndef CHROME_BROWSER_HISTORY_HISTORY_SERVICE_H_
6 #define CHROME_BROWSER_HISTORY_HISTORY_SERVICE_H_ 6 #define CHROME_BROWSER_HISTORY_HISTORY_SERVICE_H_
7 7
8 #include <set> 8 #include <set>
9 #include <vector> 9 #include <vector>
10 10
(...skipping 23 matching lines...) Expand all
34 #include "content/public/browser/notification_observer.h" 34 #include "content/public/browser/notification_observer.h"
35 #include "content/public/browser/notification_registrar.h" 35 #include "content/public/browser/notification_registrar.h"
36 #include "content/public/common/page_transition_types.h" 36 #include "content/public/common/page_transition_types.h"
37 #include "sql/init_status.h" 37 #include "sql/init_status.h"
38 #include "sync/api/syncable_service.h" 38 #include "sync/api/syncable_service.h"
39 #include "ui/base/layout.h" 39 #include "ui/base/layout.h"
40 40
41 #if defined(OS_ANDROID) 41 #if defined(OS_ANDROID)
42 class AndroidHistoryProviderService; 42 class AndroidHistoryProviderService;
43 #endif 43 #endif
44
44 class BookmarkService; 45 class BookmarkService;
45 class GURL; 46 class GURL;
46 class HistoryURLProvider; 47 class HistoryURLProvider;
47 class PageUsageData; 48 class PageUsageData;
48 class PageUsageRequest; 49 class PageUsageRequest;
49 class Profile; 50 class Profile;
50 struct HistoryURLProviderParams; 51 struct HistoryURLProviderParams;
51 struct ImportedFaviconUsage; 52 struct ImportedFaviconUsage;
52 53
53 namespace base { 54 namespace base {
54 class FilePath; 55 class FilePath;
55 class Thread; 56 class Thread;
56 } 57 }
57 58
58 namespace visitedlink { 59 namespace visitedlink {
59 class VisitedLinkMaster; 60 class VisitedLinkMaster;
60 } 61 }
61 62
62 namespace history { 63 namespace history {
63 64
64 class HistoryBackend; 65 class HistoryBackend;
66 class HistoryClient;
65 class HistoryDatabase; 67 class HistoryDatabase;
66 class HistoryDBTask; 68 class HistoryDBTask;
67 class HistoryQueryTest; 69 class HistoryQueryTest;
68 class InMemoryHistoryBackend; 70 class InMemoryHistoryBackend;
69 class InMemoryURLIndex; 71 class InMemoryURLIndex;
70 class InMemoryURLIndexTest; 72 class InMemoryURLIndexTest;
71 class URLDatabase; 73 class URLDatabase;
72 class VisitDatabaseObserver; 74 class VisitDatabaseObserver;
73 class VisitFilter; 75 class VisitFilter;
74 struct DownloadRow; 76 struct DownloadRow;
75 struct HistoryAddPageArgs; 77 struct HistoryAddPageArgs;
76 struct HistoryDetails; 78 struct HistoryDetails;
77 79
78 } // namespace history 80 } // namespace history
79 81
80 // The history service records page titles, and visit times, as well as 82 // The history service records page titles, and visit times, as well as
81 // (eventually) information about autocomplete. 83 // (eventually) information about autocomplete.
82 // 84 //
83 // This service is thread safe. Each request callback is invoked in the 85 // This service is thread safe. Each request callback is invoked in the
84 // thread that made the request. 86 // thread that made the request.
85 class HistoryService : public CancelableRequestProvider, 87 class HistoryService : public CancelableRequestProvider,
86 public content::NotificationObserver, 88 public content::NotificationObserver,
87 public syncer::SyncableService, 89 public syncer::SyncableService,
88 public KeyedService, 90 public KeyedService,
89 public visitedlink::VisitedLinkDelegate { 91 public visitedlink::VisitedLinkDelegate {
90 public: 92 public:
91 // Miscellaneous commonly-used types. 93 // Miscellaneous commonly-used types.
92 typedef std::vector<PageUsageData*> PageUsageDataList; 94 typedef std::vector<PageUsageData*> PageUsageDataList;
93 95
94 // Must call Init after construction. 96 // Must call Init after construction. The |history::HistoryClient| object
95 explicit HistoryService(Profile* profile); 97 // must be valid for the whole life time of |HistoryService|.
98 explicit HistoryService(history::HistoryClient* client, Profile* profile);
96 // The empty constructor is provided only for testing. 99 // The empty constructor is provided only for testing.
97 HistoryService(); 100 HistoryService();
98 101
99 virtual ~HistoryService(); 102 virtual ~HistoryService();
100 103
101 // Initializes the history service, returning true on success. On false, do 104 // Initializes the history service, returning true on success. On false, do
102 // not call any other functions. The given directory will be used for storing 105 // not call any other functions. The given directory will be used for storing
103 // the history files. The BookmarkService is used when deleting URLs to 106 // the history files. The BookmarkService is used when deleting URLs to
104 // test if a URL is bookmarked; it may be NULL during testing. 107 // test if a URL is bookmarked; it may be NULL during testing.
105 bool Init(const base::FilePath& history_dir, BookmarkService* bookmark_service ) { 108 bool Init(const base::FilePath& history_dir, BookmarkService* bookmark_service ) {
(...skipping 449 matching lines...) Expand 10 before | Expand all | Expand 10 after
555 history::VisitSource visit_source); 558 history::VisitSource visit_source);
556 559
557 // The same as AddPageWithDetails() but takes a vector. 560 // The same as AddPageWithDetails() but takes a vector.
558 void AddPagesWithDetails(const history::URLRows& info, 561 void AddPagesWithDetails(const history::URLRows& info,
559 history::VisitSource visit_source); 562 history::VisitSource visit_source);
560 563
561 // Returns true if this looks like the type of URL we want to add to the 564 // Returns true if this looks like the type of URL we want to add to the
562 // history. We filter out some URLs such as JavaScript. 565 // history. We filter out some URLs such as JavaScript.
563 static bool CanAddURL(const GURL& url); 566 static bool CanAddURL(const GURL& url);
564 567
568 // Returns the HistoryClient.
569 history::HistoryClient* history_client() { return history_client_; }
570
565 base::WeakPtr<HistoryService> AsWeakPtr(); 571 base::WeakPtr<HistoryService> AsWeakPtr();
566 572
567 // syncer::SyncableService implementation. 573 // syncer::SyncableService implementation.
568 virtual syncer::SyncMergeResult MergeDataAndStartSyncing( 574 virtual syncer::SyncMergeResult MergeDataAndStartSyncing(
569 syncer::ModelType type, 575 syncer::ModelType type,
570 const syncer::SyncDataList& initial_sync_data, 576 const syncer::SyncDataList& initial_sync_data,
571 scoped_ptr<syncer::SyncChangeProcessor> sync_processor, 577 scoped_ptr<syncer::SyncChangeProcessor> sync_processor,
572 scoped_ptr<syncer::SyncErrorFactory> error_handler) OVERRIDE; 578 scoped_ptr<syncer::SyncErrorFactory> error_handler) OVERRIDE;
573 virtual void StopSyncing(syncer::ModelType type) OVERRIDE; 579 virtual void StopSyncing(syncer::ModelType type) OVERRIDE;
574 virtual syncer::SyncDataList GetAllSyncData( 580 virtual syncer::SyncDataList GetAllSyncData(
(...skipping 437 matching lines...) Expand 10 before | Expand all | Expand 10 after
1012 // This pointer will be NULL once Cleanup() has been called, meaning no 1018 // This pointer will be NULL once Cleanup() has been called, meaning no
1013 // more calls should be made to the history thread. 1019 // more calls should be made to the history thread.
1014 scoped_refptr<history::HistoryBackend> history_backend_; 1020 scoped_refptr<history::HistoryBackend> history_backend_;
1015 1021
1016 // A cache of the user-typed URLs kept in memory that is used by the 1022 // A cache of the user-typed URLs kept in memory that is used by the
1017 // autocomplete system. This will be NULL until the database has been created 1023 // autocomplete system. This will be NULL until the database has been created
1018 // on the background thread. 1024 // on the background thread.
1019 // TODO(mrossetti): Consider changing ownership. See http://crbug.com/138321 1025 // TODO(mrossetti): Consider changing ownership. See http://crbug.com/138321
1020 scoped_ptr<history::InMemoryHistoryBackend> in_memory_backend_; 1026 scoped_ptr<history::InMemoryHistoryBackend> in_memory_backend_;
1021 1027
1028 // The history client, may be null when testing. The object should outlive
blundell 2014/05/30 12:19:04 s/should/should otherwise
sdefresne 2014/05/30 12:42:15 Done.
1029 // |HistoryService|.
1030 history::HistoryClient* history_client_;
1031
1022 // The profile, may be null when testing. 1032 // The profile, may be null when testing.
1023 Profile* profile_; 1033 Profile* profile_;
1024 1034
1025 // Used for propagating link highlighting data across renderers. May be null 1035 // Used for propagating link highlighting data across renderers. May be null
1026 // in tests. 1036 // in tests.
1027 scoped_ptr<visitedlink::VisitedLinkMaster> visitedlink_master_; 1037 scoped_ptr<visitedlink::VisitedLinkMaster> visitedlink_master_;
1028 1038
1029 // Has the backend finished loading? The backend is loaded once Init has 1039 // Has the backend finished loading? The backend is loaded once Init has
1030 // completed. 1040 // completed.
1031 bool backend_loaded_; 1041 bool backend_loaded_;
1032 1042
1033 // Cached values from Init(), used whenever we need to reload the backend. 1043 // Cached values from Init(), used whenever we need to reload the backend.
1034 base::FilePath history_dir_; 1044 base::FilePath history_dir_;
1035 BookmarkService* bookmark_service_; 1045 BookmarkService* bookmark_service_;
1036 bool no_db_; 1046 bool no_db_;
1037 1047
1038 // The index used for quick history lookups. 1048 // The index used for quick history lookups.
1039 // TODO(mrossetti): Move in_memory_url_index out of history_service. 1049 // TODO(mrossetti): Move in_memory_url_index out of history_service.
1040 // See http://crbug.com/138321 1050 // See http://crbug.com/138321
1041 scoped_ptr<history::InMemoryURLIndex> in_memory_url_index_; 1051 scoped_ptr<history::InMemoryURLIndex> in_memory_url_index_;
1042 1052
1043 ObserverList<history::VisitDatabaseObserver> visit_database_observers_; 1053 ObserverList<history::VisitDatabaseObserver> visit_database_observers_;
1044 1054
1045 history::DeleteDirectiveHandler delete_directive_handler_; 1055 history::DeleteDirectiveHandler delete_directive_handler_;
1046 1056
1047 DISALLOW_COPY_AND_ASSIGN(HistoryService); 1057 DISALLOW_COPY_AND_ASSIGN(HistoryService);
1048 }; 1058 };
1049 1059
1050 #endif // CHROME_BROWSER_HISTORY_HISTORY_SERVICE_H_ 1060 #endif // CHROME_BROWSER_HISTORY_HISTORY_SERVICE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698