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

Side by Side Diff: components/webdata/common/web_data_service_base.h

Issue 17760007: components/webdata: Cleanup callback usage in WebDatabaseService. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: disallow Created 7 years, 6 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
« no previous file with comments | « no previous file | components/webdata/common/web_data_service_base.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 COMPONENTS_WEBDATA_COMMON_WEB_DATA_SERVICE_BASE_H_ 5 #ifndef COMPONENTS_WEBDATA_COMMON_WEB_DATA_SERVICE_BASE_H_
6 #define COMPONENTS_WEBDATA_COMMON_WEB_DATA_SERVICE_BASE_H_ 6 #define COMPONENTS_WEBDATA_COMMON_WEB_DATA_SERVICE_BASE_H_
7 7
8 #include "base/callback.h" 8 #include "base/callback.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"
(...skipping 18 matching lines...) Expand all
29 // All requests return an opaque handle of the following type. 29 // All requests return an opaque handle of the following type.
30 typedef int Handle; 30 typedef int Handle;
31 31
32 // Users of this class may provide a callback to handle errors 32 // Users of this class may provide a callback to handle errors
33 // (e.g. by showing a UI). The callback is called only on error, and 33 // (e.g. by showing a UI). The callback is called only on error, and
34 // takes a single parameter, the sql::InitStatus value from trying 34 // takes a single parameter, the sql::InitStatus value from trying
35 // to open the database. 35 // to open the database.
36 // TODO(joi): Should we combine this with WebDatabaseService::InitCallback? 36 // TODO(joi): Should we combine this with WebDatabaseService::InitCallback?
37 typedef base::Callback<void(sql::InitStatus)> ProfileErrorCallback; 37 typedef base::Callback<void(sql::InitStatus)> ProfileErrorCallback;
38 38
39 typedef base::Closure DBLoadedCallback;
40
39 // |callback| will only be invoked on error, and only if 41 // |callback| will only be invoked on error, and only if
40 // |callback.is_null()| evaluates to false. 42 // |callback.is_null()| evaluates to false.
41 // 43 //
42 // The ownership of |wdbs| is shared, with the primary owner being the 44 // The ownership of |wdbs| is shared, with the primary owner being the
43 // WebDataServiceWrapper, and secondary owners being subclasses of 45 // WebDataServiceWrapper, and secondary owners being subclasses of
44 // WebDataServiceBase, which receive |wdbs| upon construction. The 46 // WebDataServiceBase, which receive |wdbs| upon construction. The
45 // WebDataServiceWrapper handles the initializing and shutting down and of 47 // WebDataServiceWrapper handles the initializing and shutting down and of
46 // the |wdbs| object. 48 // the |wdbs| object.
47 // WebDataServiceBase is destroyed on |ui_thread|. 49 // WebDataServiceBase is destroyed on |ui_thread|.
48 WebDataServiceBase(scoped_refptr<WebDatabaseService> wdbs, 50 WebDataServiceBase(scoped_refptr<WebDatabaseService> wdbs,
(...skipping 16 matching lines...) Expand all
65 void UnloadDatabase(); 67 void UnloadDatabase();
66 68
67 // Unloads the database permanently and shuts down service. 69 // Unloads the database permanently and shuts down service.
68 void ShutdownDatabase(); 70 void ShutdownDatabase();
69 71
70 // Register a callback to be notified that the database has loaded. Multiple 72 // Register a callback to be notified that the database has loaded. Multiple
71 // callbacks may be registered, and each will be called at most once 73 // callbacks may be registered, and each will be called at most once
72 // (following a successful database load), then cleared. 74 // (following a successful database load), then cleared.
73 // Note: if the database load is already complete, then the callback will NOT 75 // Note: if the database load is already complete, then the callback will NOT
74 // be stored or called. 76 // be stored or called.
75 virtual void RegisterDBLoadedCallback( 77 virtual void RegisterDBLoadedCallback(const DBLoadedCallback& callback);
76 const base::Callback<void(void)>& callback);
77 78
78 // Returns true if the database load has completetd successfully, and 79 // Returns true if the database load has completetd successfully, and
79 // ShutdownOnUIThread has not yet been called. 80 // ShutdownOnUIThread has not yet been called.
80 virtual bool IsDatabaseLoaded(); 81 virtual bool IsDatabaseLoaded();
81 82
82 // Returns a pointer to the DB (used by SyncableServices). May return NULL if 83 // Returns a pointer to the DB (used by SyncableServices). May return NULL if
83 // the database is not loaded or otherwise unavailable. Must be called on 84 // the database is not loaded or otherwise unavailable. Must be called on
84 // DBThread. 85 // DBThread.
85 virtual WebDatabase* GetDatabase(); 86 virtual WebDatabase* GetDatabase();
86 87
87 protected: 88 protected:
88 friend class base::RefCountedDeleteOnMessageLoop<WebDataServiceBase>; 89 friend class base::RefCountedDeleteOnMessageLoop<WebDataServiceBase>;
89 friend class base::DeleteHelper<WebDataServiceBase>; 90 friend class base::DeleteHelper<WebDataServiceBase>;
90 91
91 virtual ~WebDataServiceBase(); 92 virtual ~WebDataServiceBase();
92 93
93 // Our database service. 94 // Our database service.
94 scoped_refptr<WebDatabaseService> wdbs_; 95 scoped_refptr<WebDatabaseService> wdbs_;
95 96
96 private: 97 private:
97 ProfileErrorCallback profile_error_callback_; 98 ProfileErrorCallback profile_error_callback_;
99
100 DISALLOW_COPY_AND_ASSIGN(WebDataServiceBase);
98 }; 101 };
99 102
100 #endif // COMPONENTS_WEBDATA_COMMON_WEB_DATA_SERVICE_BASE_H_ 103 #endif // COMPONENTS_WEBDATA_COMMON_WEB_DATA_SERVICE_BASE_H_
OLDNEW
« no previous file with comments | « no previous file | components/webdata/common/web_data_service_base.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698