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

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

Issue 642623004: Rename VisitDatabaseObserver to HistoryServiceObserver (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@373326
Patch Set: Created 6 years, 2 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 // The InMemoryHistoryBackend is a wrapper around the in-memory URL database. 5 // The InMemoryHistoryBackend is a wrapper around the in-memory URL database.
6 // It maintains an in-memory cache of a subset of history that is required for 6 // It maintains an in-memory cache of a subset of history that is required for
7 // low-latency operations, such as in-line autocomplete. 7 // low-latency operations, such as in-line autocomplete.
8 // 8 //
9 // The in-memory cache provides the following guarantees: 9 // The in-memory cache provides the following guarantees:
10 // (1.) It will always contain URLRows that either have a |typed_count| > 0; or 10 // (1.) It will always contain URLRows that either have a |typed_count| > 0; or
11 // that have a corresponding search term, in which case information about 11 // that have a corresponding search term, in which case information about
12 // the search term is also stored. 12 // the search term is also stored.
13 // (2.) It will be an actual subset, i.e., it will contain verbatim data, and 13 // (2.) It will be an actual subset, i.e., it will contain verbatim data, and
14 // will never contain more data that can be found in the main database. 14 // will never contain more data that can be found in the main database.
15 // 15 //
16 // The InMemoryHistoryBackend is created on the history thread and passed to the 16 // The InMemoryHistoryBackend is created on the history thread and passed to the
17 // main thread where operations can be completed synchronously. It listens for 17 // main thread where operations can be completed synchronously. It listens for
18 // notifications from the "regular" history backend and keeps itself in sync. 18 // notifications from the "regular" history backend and keeps itself in sync.
19 19
20 #ifndef CHROME_BROWSER_HISTORY_IN_MEMORY_HISTORY_BACKEND_H_ 20 #ifndef CHROME_BROWSER_HISTORY_IN_MEMORY_HISTORY_BACKEND_H_
21 #define CHROME_BROWSER_HISTORY_IN_MEMORY_HISTORY_BACKEND_H_ 21 #define CHROME_BROWSER_HISTORY_IN_MEMORY_HISTORY_BACKEND_H_
22 22
23 #include <string> 23 #include <string>
24 24
25 #include "base/basictypes.h" 25 #include "base/basictypes.h"
26 #include "base/gtest_prod_util.h" 26 #include "base/gtest_prod_util.h"
27 #include "base/memory/scoped_ptr.h" 27 #include "base/memory/scoped_ptr.h"
28 #include "components/history/core/browser/history_service_observer.h" 28 #include "chrome/browser/history/history_service.h"
29 #include "components/history/core/browser/keyword_id.h" 29 #include "components/history/core/browser/keyword_id.h"
30 #include "content/public/browser/notification_observer.h" 30 #include "content/public/browser/notification_observer.h"
31 #include "content/public/browser/notification_registrar.h" 31 #include "content/public/browser/notification_registrar.h"
32 32
33 class HistoryService;
34 class Profile; 33 class Profile;
35 34
36 namespace base { 35 namespace base {
37 class FilePath; 36 class FilePath;
38 } 37 }
39 38
40 namespace history { 39 namespace history {
41 40
42 class InMemoryDatabase; 41 class InMemoryDatabase;
43 struct KeywordSearchUpdatedDetails; 42 struct KeywordSearchUpdatedDetails;
44 struct KeywordSearchDeletedDetails; 43 struct KeywordSearchDeletedDetails;
45 class URLDatabase; 44 class URLDatabase;
46 class URLRow; 45 class URLRow;
47 struct URLsDeletedDetails; 46 struct URLsDeletedDetails;
48 struct URLsModifiedDetails; 47 struct URLsModifiedDetails;
49 48
50 class InMemoryHistoryBackend : public HistoryServiceObserver, 49 class InMemoryHistoryBackend : public HistoryService::Observer,
51 public content::NotificationObserver { 50 public content::NotificationObserver {
52 public: 51 public:
53 InMemoryHistoryBackend(); 52 InMemoryHistoryBackend();
54 virtual ~InMemoryHistoryBackend(); 53 virtual ~InMemoryHistoryBackend();
55 54
56 // Initializes the backend from the history database pointed to by the 55 // Initializes the backend from the history database pointed to by the
57 // full path in |history_filename|. 56 // full path in |history_filename|.
58 bool Init(const base::FilePath& history_filename); 57 bool Init(const base::FilePath& history_filename);
59 58
60 // Does initialization work when this object is attached to the history 59 // Does initialization work when this object is attached to the history
61 // system on the main thread. The argument is the profile with which the 60 // system on the main thread. The argument is the profile with which the
62 // attached history service is under. 61 // attached history service is under.
63 void AttachToHistoryService(Profile* profile, 62 void AttachToHistoryService(Profile* profile,
64 HistoryService* history_service); 63 HistoryService* history_service);
65 64
66 // Deletes all search terms for the specified keyword. 65 // Deletes all search terms for the specified keyword.
67 void DeleteAllSearchTermsForKeyword(KeywordID keyword_id); 66 void DeleteAllSearchTermsForKeyword(KeywordID keyword_id);
68 67
69 // Returns the underlying database associated with this backend. The current 68 // Returns the underlying database associated with this backend. The current
70 // autocomplete code was written fro this, but it should probably be removed 69 // autocomplete code was written fro this, but it should probably be removed
71 // so that it can deal directly with this object, rather than the DB. 70 // so that it can deal directly with this object, rather than the DB.
72 InMemoryDatabase* db() const { 71 InMemoryDatabase* db() const {
73 return db_.get(); 72 return db_.get();
74 } 73 }
75 74
76 // HistoryServiceObserver: 75 // HistoryService::Observer:
77 virtual void OnURLVisited(ui::PageTransition transition, 76 virtual void OnURLVisited(ui::PageTransition transition,
78 const URLRow& row, 77 const URLRow& row,
79 const RedirectList& redirects, 78 const RedirectList& redirects,
80 base::Time visit_time) OVERRIDE; 79 base::Time visit_time) OVERRIDE;
81 80
82 // Notification callback. 81 // Notification callback.
83 virtual void Observe(int type, 82 virtual void Observe(int type,
84 const content::NotificationSource& source, 83 const content::NotificationSource& source,
85 const content::NotificationDetails& details) OVERRIDE; 84 const content::NotificationDetails& details) OVERRIDE;
86 85
(...skipping 20 matching lines...) Expand all
107 // initialization. 106 // initialization.
108 Profile* profile_; 107 Profile* profile_;
109 HistoryService* history_service_; 108 HistoryService* history_service_;
110 109
111 DISALLOW_COPY_AND_ASSIGN(InMemoryHistoryBackend); 110 DISALLOW_COPY_AND_ASSIGN(InMemoryHistoryBackend);
112 }; 111 };
113 112
114 } // namespace history 113 } // namespace history
115 114
116 #endif // CHROME_BROWSER_HISTORY_IN_MEMORY_HISTORY_BACKEND_H_ 115 #endif // CHROME_BROWSER_HISTORY_IN_MEMORY_HISTORY_BACKEND_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698