OLD | NEW |
---|---|
(Empty) | |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | |
2 // Use of this source code is governed by a BSD-style license that can be | |
3 // found in the LICENSE file. | |
4 | |
5 // Chromium settings and storage represent user-selected preferences and | |
6 // information and MUST not be extracted, overwritten or modified except | |
7 // through Chromium defined APIs. | |
8 | |
9 #ifndef CHROME_BROWSER_WEBDATA_WEB_DATABASE_SERVICE_H_ | |
10 #define CHROME_BROWSER_WEBDATA_WEB_DATABASE_SERVICE_H_ | |
11 | |
12 #include "base/basictypes.h" | |
13 #include "base/callback_forward.h" | |
14 #include "base/compiler_specific.h" | |
15 #include "base/files/file_path.h" | |
16 #include "base/memory/ref_counted.h" | |
17 #include "base/memory/scoped_ptr.h" | |
18 #include "chrome/browser/api/webdata/web_data_service_base.h" | |
19 #include "chrome/browser/webdata/web_database.h" | |
20 | |
21 class WebDatabaseServiceInternal; | |
22 class WebDataRequestManager; | |
23 | |
24 namespace content { | |
25 class BrowserContext; | |
26 } | |
27 | |
28 namespace tracked_objects { | |
29 class Location; | |
30 } | |
31 | |
32 class WDTypedResult; | |
33 class WebDataServiceConsumer; | |
34 | |
35 | |
36 //////////////////////////////////////////////////////////////////////////////// | |
37 // | |
38 // WebDatabaseService defines the interface to a generic data repository | |
39 // responsible for controlling access to the web database (metadata associated | |
40 // with web pages). | |
41 // | |
42 //////////////////////////////////////////////////////////////////////////////// | |
43 | |
44 class WebDatabaseService { | |
45 public: | |
46 typedef base::Callback<scoped_ptr<WDTypedResult>(WebDatabase*)> ReadTask; | |
47 typedef base::Callback<WebDatabase::State(WebDatabase*)> WriteTask; | |
48 typedef base::Callback<void(sql::InitStatus)> InitCallback; | |
49 | |
50 // Takes the path to the WebDatabase file. | |
51 explicit WebDatabaseService(const base::FilePath& path); | |
52 | |
53 virtual ~WebDatabaseService(); | |
54 | |
55 // Initializes the web database service. Takes a callback which will return | |
56 // the status of the DB after the init. | |
57 virtual void LoadDatabase(const InitCallback& callback); | |
58 | |
59 // Unloads the database without actually shutting down the service. This can | |
60 // be used to temporarily reduce the browser process' memory footprint. | |
61 virtual void UnloadDatabase(); | |
62 | |
63 // Unloads database and will not reload. | |
64 virtual void ShutdownDatabase(); | |
65 | |
66 // Gets a ptr to the WebDatabase (owned by WebDatabaseService). | |
67 // TODO(caitkp): remove this method once SyncServices no longer depend on it. | |
68 virtual WebDatabase* GetDatabaseOnDB() const; | |
69 | |
70 // Schedule an update/write task on the DB thread. | |
71 virtual void ScheduleDBTask( | |
72 const tracked_objects::Location& from_here, | |
73 const WriteTask& task); | |
74 | |
75 // Schedule a read task on the DB thread. | |
76 virtual WebDataServiceBase::Handle ScheduleDBTaskWithResult( | |
77 const tracked_objects::Location& from_here, | |
78 const ReadTask& task, | |
79 WebDataServiceConsumer* consumer); | |
80 | |
81 // Cancel an existing request for a task on the DB thread. | |
82 // TODO(caitkp): Think about moving the definition of the Handle type to | |
83 // somewhere else. | |
84 virtual void CancelRequest(WebDataServiceBase::Handle h); | |
85 | |
86 private: | |
87 base::FilePath path_; | |
88 | |
89 // The primary owner is |WebDatabaseService| but is refcounted because | |
90 // PostTask on DB thread may outlive us. | |
91 scoped_refptr<WebDatabaseServiceInternal> wdbs_internal_; | |
dhollowa
2013/03/15 23:50:31
Sorry to be going off on naming here. But "WebDat
Cait (Slow)
2013/03/16 21:34:22
Done.
| |
92 }; | |
93 | |
94 #endif // CHROME_BROWSER_WEBDATA_WEB_DATABASE_SERVICE_H_ | |
OLD | NEW |