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

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

Issue 22569006: tmp Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 7 years, 4 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_URL_DATABASE_H_ 5 #ifndef CHROME_BROWSER_HISTORY_URL_DATABASE_H_
6 #define CHROME_BROWSER_HISTORY_URL_DATABASE_H_ 6 #define CHROME_BROWSER_HISTORY_URL_DATABASE_H_
7 7
8 #include "base/basictypes.h" 8 #include "base/basictypes.h"
9 #include "base/observer_list.h"
9 #include "chrome/browser/history/history_types.h" 10 #include "chrome/browser/history/history_types.h"
10 #include "chrome/browser/history/query_parser.h" 11 #include "chrome/browser/history/query_parser.h"
11 #include "chrome/browser/search_engines/template_url_id.h" 12 #include "chrome/browser/search_engines/template_url_id.h"
12 #include "sql/statement.h" 13 #include "sql/statement.h"
13 14
14 class GURL; 15 class GURL;
15 16
16 namespace sql { 17 namespace sql {
17 class Connection; 18 class Connection;
18 } 19 }
19 20
20 namespace history { 21 namespace history {
21 22
22 class VisitDatabase; // For friend statement. 23 class VisitDatabase; // For friend statement.
24 class URLDatabaseObserver;
23 25
24 // Encapsulates an SQL database that holds URL info. This is a subset of the 26 // Encapsulates an SQL database that holds URL info. This is a subset of the
25 // full history data. We split this class' functionality out from the larger 27 // full history data. We split this class' functionality out from the larger
26 // HistoryDatabase class to support maintaining separate databases of URLs with 28 // HistoryDatabase class to support maintaining separate databases of URLs with
27 // different capabilities (for example, in-memory, or archived). 29 // different capabilities (for example, in-memory, or archived).
28 // 30 //
29 // This is refcounted to support calling InvokeLater() with some of its methods 31 // This is refcounted to support calling InvokeLater() with some of its methods
30 // (necessary to maintain ordering of DB operations). 32 // (necessary to maintain ordering of DB operations).
31 class URLDatabase { 33 class URLDatabase {
32 public: 34 public:
(...skipping 199 matching lines...) Expand 10 before | Expand all | Expand 10 after
232 // Do to a bug we were setting the favicon of about:blank. This forces 234 // Do to a bug we were setting the favicon of about:blank. This forces
233 // about:blank to have no icon or title. Returns true on success, false if 235 // about:blank to have no icon or title. Returns true on success, false if
234 // the favicon couldn't be updated. 236 // the favicon couldn't be updated.
235 bool MigrateFromVersion11ToVersion12(); 237 bool MigrateFromVersion11ToVersion12();
236 238
237 // Initializes the given enumerator to enumerator all URL and icon mappings 239 // Initializes the given enumerator to enumerator all URL and icon mappings
238 // in the database. Only used for icon mapping migration. 240 // in the database. Only used for icon mapping migration.
239 bool InitIconMappingEnumeratorForEverything( 241 bool InitIconMappingEnumeratorForEverything(
240 IconMappingEnumerator* enumerator); 242 IconMappingEnumerator* enumerator);
241 243
244 void AddObserver(URLDatabaseObserver* observer);
245 void RemoveObserver(URLDatabaseObserver* observer);
246
242 protected: 247 protected:
243 friend class VisitDatabase; 248 friend class VisitDatabase;
244 249
245 // See HISTORY_URL_ROW_FIELDS below. 250 // See HISTORY_URL_ROW_FIELDS below.
246 static const char kURLRowFields[]; 251 static const char kURLRowFields[];
247 252
248 // The number of fiends in kURLRowFields. If callers need additional 253 // The number of fiends in kURLRowFields. If callers need additional
249 // fields, they can add their 0-based index to this value to get the index of 254 // fields, they can add their 0-based index to this value to get the index of
250 // fields following kURLRowFields. 255 // fields following kURLRowFields.
251 static const int kNumURLRowFields; 256 static const int kNumURLRowFields;
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
289 294
290 // Returns the database for the functions in this interface. The decendent of 295 // Returns the database for the functions in this interface. The decendent of
291 // this class implements these functions to return its objects. 296 // this class implements these functions to return its objects.
292 virtual sql::Connection& GetDB() = 0; 297 virtual sql::Connection& GetDB() = 0;
293 298
294 private: 299 private:
295 // True if InitKeywordSearchTermsTable() has been invoked. Not all subclasses 300 // True if InitKeywordSearchTermsTable() has been invoked. Not all subclasses
296 // have keyword search terms. 301 // have keyword search terms.
297 bool has_keyword_search_terms_; 302 bool has_keyword_search_terms_;
298 303
304 ObserverList<URLDatabaseObserver> observers_;
305
299 QueryParser query_parser_; 306 QueryParser query_parser_;
300 307
301 DISALLOW_COPY_AND_ASSIGN(URLDatabase); 308 DISALLOW_COPY_AND_ASSIGN(URLDatabase);
302 }; 309 };
303 310
304 // The fields and order expected by FillURLRow(). ID is guaranteed to be first 311 // The fields and order expected by FillURLRow(). ID is guaranteed to be first
305 // so that DISTINCT can be prepended to get distinct URLs. 312 // so that DISTINCT can be prepended to get distinct URLs.
306 // 313 //
307 // This is available BOTH as a macro and a static string (kURLRowFields). Use 314 // This is available BOTH as a macro and a static string (kURLRowFields). Use
308 // the macro if you want to put this in the middle of an otherwise constant 315 // the macro if you want to put this in the middle of an otherwise constant
309 // string, it will save time doing string appends. If you have to build a SQL 316 // string, it will save time doing string appends. If you have to build a SQL
310 // string dynamically anyway, use the constant, it will save space. 317 // string dynamically anyway, use the constant, it will save space.
311 #define HISTORY_URL_ROW_FIELDS \ 318 #define HISTORY_URL_ROW_FIELDS \
312 " urls.id, urls.url, urls.title, urls.visit_count, urls.typed_count, " \ 319 " urls.id, urls.url, urls.title, urls.visit_count, urls.typed_count, " \
313 "urls.last_visit_time, urls.hidden " 320 "urls.last_visit_time, urls.hidden "
314 321
315 } // namespace history 322 } // namespace history
316 323
317 #endif // CHROME_BROWSER_HISTORY_URL_DATABASE_H_ 324 #endif // CHROME_BROWSER_HISTORY_URL_DATABASE_H_
OLDNEW
« no previous file with comments | « chrome/browser/history/history_database_delegate.cc ('k') | chrome/browser/history/url_database.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698