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

Side by Side Diff: chrome/browser/webdata/web_database_service.h

Issue 13392014: Move c/b/webdata/ code to components/webdata/ (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Pure merge Created 7 years, 8 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 | Annotate | Revision Log
OLDNEW
(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 WebDataServiceBackend;
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 base::RefCountedThreadSafe<
46 WebDatabaseService,
47 content::BrowserThread::DeleteOnUIThread> {
48 public:
49 typedef base::Callback<scoped_ptr<WDTypedResult>(WebDatabase*)> ReadTask;
50 typedef base::Callback<WebDatabase::State(WebDatabase*)> WriteTask;
51 typedef base::Callback<void(sql::InitStatus)> InitCallback;
52
53 // Takes the path to the WebDatabase file.
54 explicit WebDatabaseService(const base::FilePath& path);
55
56 // Adds |table| as a WebDatabaseTable that will participate in
57 // managing the database, transferring ownership. All calls to this
58 // method must be made before |LoadDatabase| is called.
59 virtual void AddTable(scoped_ptr<WebDatabaseTable> table);
60
61 // Initializes the web database service. Takes a callback which will return
62 // the status of the DB after the init.
63 virtual void LoadDatabase(const InitCallback& callback);
64
65 // Unloads the database without actually shutting down the service. This can
66 // be used to temporarily reduce the browser process' memory footprint.
67 virtual void UnloadDatabase();
68
69 // Unloads database and will not reload.
70 virtual void ShutdownDatabase();
71
72 // Gets a ptr to the WebDatabase (owned by WebDatabaseService).
73 // TODO(caitkp): remove this method once SyncServices no longer depend on it.
74 virtual WebDatabase* GetDatabaseOnDB() const;
75
76 // Schedule an update/write task on the DB thread.
77 virtual void ScheduleDBTask(
78 const tracked_objects::Location& from_here,
79 const WriteTask& task);
80
81 // Schedule a read task on the DB thread.
82 virtual WebDataServiceBase::Handle ScheduleDBTaskWithResult(
83 const tracked_objects::Location& from_here,
84 const ReadTask& task,
85 WebDataServiceConsumer* consumer);
86
87 // Cancel an existing request for a task on the DB thread.
88 // TODO(caitkp): Think about moving the definition of the Handle type to
89 // somewhere else.
90 virtual void CancelRequest(WebDataServiceBase::Handle h);
91
92 private:
93 friend struct content::BrowserThread::DeleteOnThread<
94 content::BrowserThread::UI>;
95 friend class base::DeleteHelper<WebDatabaseService>;
96
97 virtual ~WebDatabaseService();
98
99 base::FilePath path_;
100
101 // The primary owner is |WebDatabaseService| but is refcounted because
102 // PostTask on DB thread may outlive us.
103 scoped_refptr<WebDataServiceBackend> wds_backend_;
104 };
105
106 #endif // CHROME_BROWSER_WEBDATA_WEB_DATABASE_SERVICE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698