OLD | NEW |
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_API_WEBDATA_WEB_DATA_SERVICE_BASE_H_ | 5 #ifndef CHROME_BROWSER_API_WEBDATA_WEB_DATA_SERVICE_BASE_H_ |
6 #define CHROME_BROWSER_API_WEBDATA_WEB_DATA_SERVICE_BASE_H_ | 6 #define CHROME_BROWSER_API_WEBDATA_WEB_DATA_SERVICE_BASE_H_ |
7 | 7 |
8 #include "base/callback_forward.h" | 8 #include "base/callback_forward.h" |
9 #include "base/files/file_path.h" | 9 #include "base/files/file_path.h" |
10 #include "base/memory/ref_counted.h" | 10 #include "base/memory/ref_counted.h" |
11 #include "base/memory/scoped_ptr.h" | 11 #include "base/memory/scoped_ptr.h" |
12 #include "base/supports_user_data.h" | 12 #include "base/supports_user_data.h" |
13 #include "content/public/browser/browser_thread.h" | 13 #include "content/public/browser/browser_thread.h" |
14 #include "content/public/browser/notification_source.h" | 14 #include "content/public/browser/notification_source.h" |
15 #include "sql/init_status.h" | 15 #include "sql/init_status.h" |
16 | 16 |
17 class WebDatabase; | 17 class WebDatabase; |
18 class WebDatabaseService; | 18 class WebDatabaseService; |
| 19 class WebDatabaseTable; |
19 | 20 |
20 namespace base { | 21 namespace base { |
21 class Thread; | 22 class Thread; |
22 } | 23 } |
23 | 24 |
24 // Base for WebDataService class hierarchy. | 25 // Base for WebDataService class hierarchy. |
25 class WebDataServiceBase | 26 class WebDataServiceBase |
26 : public base::RefCountedThreadSafe<WebDataServiceBase, | 27 : public base::RefCountedThreadSafe<WebDataServiceBase, |
27 content::BrowserThread::DeleteOnUIThread> { | 28 content::BrowserThread::DeleteOnUIThread> { |
28 public: | 29 public: |
(...skipping 16 matching lines...) Expand all Loading... |
45 virtual void CancelRequest(Handle h); | 46 virtual void CancelRequest(Handle h); |
46 | 47 |
47 // Returns the notification source for this service. This may use a | 48 // Returns the notification source for this service. This may use a |
48 // pointer other than this object's |this| pointer. | 49 // pointer other than this object's |this| pointer. |
49 virtual content::NotificationSource GetNotificationSource(); | 50 virtual content::NotificationSource GetNotificationSource(); |
50 | 51 |
51 // Shutdown the web data service. The service can no longer be used after this | 52 // Shutdown the web data service. The service can no longer be used after this |
52 // call. | 53 // call. |
53 virtual void ShutdownOnUIThread(); | 54 virtual void ShutdownOnUIThread(); |
54 | 55 |
| 56 // Adds the given table to the database. Passes ownership. Must be |
| 57 // called for all tables before Init. |
| 58 // |
| 59 // TODO(joi): This method is duplicated a couple of layers deep; |
| 60 // once we have a single object creating the WebDatabaseService as |
| 61 // well as all the XyzWebDataService objects, we should be able to |
| 62 // simplify. |
| 63 void AddTable(scoped_ptr<WebDatabaseTable> table); |
| 64 |
55 // Initializes the web data service. | 65 // Initializes the web data service. |
56 virtual void Init(const base::FilePath& path); | 66 virtual void Init(const base::FilePath& path); |
57 | 67 |
58 // Unloads the database without actually shutting down the service. This can | 68 // Unloads the database without actually shutting down the service. This can |
59 // be used to temporarily reduce the browser process' memory footprint. | 69 // be used to temporarily reduce the browser process' memory footprint. |
60 void UnloadDatabase(); | 70 void UnloadDatabase(); |
61 | 71 |
62 // Unloads the database permanently and shuts down service. | 72 // Unloads the database permanently and shuts down service. |
63 void ShutdownDatabase(); | 73 void ShutdownDatabase(); |
64 | 74 |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
110 // be used e.g. for SyncableService subclasses that need to be owned | 120 // be used e.g. for SyncableService subclasses that need to be owned |
111 // by this object. Is created on first call to |GetDBUserData()|. | 121 // by this object. Is created on first call to |GetDBUserData()|. |
112 scoped_ptr<SupportsUserDataAggregatable> db_thread_user_data_; | 122 scoped_ptr<SupportsUserDataAggregatable> db_thread_user_data_; |
113 | 123 |
114 void DBInitFailed(sql::InitStatus sql_status); | 124 void DBInitFailed(sql::InitStatus sql_status); |
115 void NotifyDatabaseLoadedOnUIThread(); | 125 void NotifyDatabaseLoadedOnUIThread(); |
116 void DatabaseInitOnDB(sql::InitStatus status); | 126 void DatabaseInitOnDB(sql::InitStatus status); |
117 }; | 127 }; |
118 | 128 |
119 #endif // CHROME_BROWSER_API_WEBDATA_WEB_DATA_SERVICE_BASE_H_ | 129 #endif // CHROME_BROWSER_API_WEBDATA_WEB_DATA_SERVICE_BASE_H_ |
OLD | NEW |