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

Side by Side Diff: content/browser/in_process_webkit/indexed_db_callbacks.h

Issue 7692006: IndexedDB API cleanup. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Copyright presubmit Created 9 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | content/browser/in_process_webkit/indexed_db_callbacks.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) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 CONTENT_BROWSER_IN_PROCESS_WEBKIT_INDEXED_DB_CALLBACKS_H_ 5 #ifndef CONTENT_BROWSER_IN_PROCESS_WEBKIT_INDEXED_DB_CALLBACKS_H_
6 #define CONTENT_BROWSER_IN_PROCESS_WEBKIT_INDEXED_DB_CALLBACKS_H_ 6 #define CONTENT_BROWSER_IN_PROCESS_WEBKIT_INDEXED_DB_CALLBACKS_H_
7 #pragma once 7 #pragma once
8 8
9 #include "base/basictypes.h" 9 #include "base/basictypes.h"
10 #include "base/memory/ref_counted.h" 10 #include "base/memory/ref_counted.h"
11 #include "content/browser/in_process_webkit/indexed_db_dispatcher_host.h" 11 #include "content/browser/in_process_webkit/indexed_db_dispatcher_host.h"
12 #include "googleurl/src/gurl.h" 12 #include "googleurl/src/gurl.h"
13 #include "third_party/WebKit/Source/WebKit/chromium/public/WebIDBCallbacks.h" 13 #include "third_party/WebKit/Source/WebKit/chromium/public/WebIDBCallbacks.h"
14 #include "third_party/WebKit/Source/WebKit/chromium/public/WebIDBCursor.h" 14 #include "third_party/WebKit/Source/WebKit/chromium/public/WebIDBCursor.h"
15 #include "third_party/WebKit/Source/WebKit/chromium/public/WebIDBDatabaseError.h " 15 #include "third_party/WebKit/Source/WebKit/chromium/public/WebIDBDatabaseError.h "
16 #include "third_party/WebKit/Source/WebKit/chromium/public/WebIDBTransaction.h" 16 #include "third_party/WebKit/Source/WebKit/chromium/public/WebIDBTransaction.h"
17 #include "third_party/WebKit/Source/WebKit/chromium/public/WebString.h" 17 #include "third_party/WebKit/Source/WebKit/chromium/public/WebString.h"
18 18
19 class IndexedDBMsg_CallbacksSuccessIDBIndex; 19 class IndexedDBMsg_CallbacksSuccessIDBDatabase;
20 class IndexedDBMsg_CallbacksSuccessIDBTransaction; 20 class IndexedDBMsg_CallbacksSuccessIDBTransaction;
21 21
22 // Template magic to figure out what message to send to the renderer based on 22 // Template magic to figure out what message to send to the renderer based on
23 // which (overloaded) onSuccess method we expect to be called. 23 // which (overloaded) onSuccess method we expect to be called.
24 template <class Type> struct WebIDBToMsgHelper { }; 24 template <class Type> struct WebIDBToMsgHelper { };
25 template <> struct WebIDBToMsgHelper<WebKit::WebIDBIndex> { 25 template <> struct WebIDBToMsgHelper<WebKit::WebIDBDatabase> {
26 typedef IndexedDBMsg_CallbacksSuccessIDBIndex MsgType; 26 typedef IndexedDBMsg_CallbacksSuccessIDBDatabase MsgType;
27 };
28 template <> struct WebIDBToMsgHelper<WebKit::WebIDBTransaction> {
29 typedef IndexedDBMsg_CallbacksSuccessIDBTransaction MsgType;
27 }; 30 };
28 31
29 // The code the following two classes share. 32 // The code the following two classes share.
30 class IndexedDBCallbacksBase : public WebKit::WebIDBCallbacks { 33 class IndexedDBCallbacksBase : public WebKit::WebIDBCallbacks {
31 public: 34 public:
32 IndexedDBCallbacksBase(IndexedDBDispatcherHost* dispatcher_host, 35 IndexedDBCallbacksBase(IndexedDBDispatcherHost* dispatcher_host,
33 int32 response_id); 36 int32 response_id);
34 37
35 virtual ~IndexedDBCallbacksBase(); 38 virtual ~IndexedDBCallbacksBase();
36 39
(...skipping 11 matching lines...) Expand all
48 int32 response_id_; 51 int32 response_id_;
49 52
50 DISALLOW_IMPLICIT_CONSTRUCTORS(IndexedDBCallbacksBase); 53 DISALLOW_IMPLICIT_CONSTRUCTORS(IndexedDBCallbacksBase);
51 }; 54 };
52 55
53 // A WebIDBCallbacks implementation that returns an object of WebObjectType. 56 // A WebIDBCallbacks implementation that returns an object of WebObjectType.
54 template <class WebObjectType> 57 template <class WebObjectType>
55 class IndexedDBCallbacks : public IndexedDBCallbacksBase { 58 class IndexedDBCallbacks : public IndexedDBCallbacksBase {
56 public: 59 public:
57 IndexedDBCallbacks( 60 IndexedDBCallbacks(
58 IndexedDBDispatcherHost* dispatcher_host, int32 response_id)
59 : IndexedDBCallbacksBase(dispatcher_host, response_id) { }
60
61 virtual void onSuccess(WebObjectType* idb_object) {
62 int32 object_id = dispatcher_host()->Add(idb_object);
63 dispatcher_host()->Send(
64 new typename WebIDBToMsgHelper<WebObjectType>::MsgType(response_id(),
65 object_id));
66 }
67
68 private:
69 DISALLOW_IMPLICIT_CONSTRUCTORS(IndexedDBCallbacks);
70 };
71
72 template <>
73 class IndexedDBCallbacks<WebKit::WebIDBTransaction>
74 : public IndexedDBCallbacksBase {
75 public:
76 IndexedDBCallbacks(
77 IndexedDBDispatcherHost* dispatcher_host, int32 response_id, 61 IndexedDBDispatcherHost* dispatcher_host, int32 response_id,
78 const GURL& origin_url) 62 const GURL& origin_url)
79 : IndexedDBCallbacksBase(dispatcher_host, response_id), 63 : IndexedDBCallbacksBase(dispatcher_host, response_id),
80 origin_url_(origin_url) { 64 origin_url_(origin_url) {
81 } 65 }
82 66
83 virtual void onSuccess(WebKit::WebIDBTransaction* idb_object); 67 virtual void onSuccess(WebObjectType* idb_object) {
84 const GURL& origin_url() const { return origin_url_; } 68 int32 object_id = dispatcher_host()->Add(idb_object, origin_url_);
85 69 dispatcher_host()->Send(
86 private: 70 new typename WebIDBToMsgHelper<WebObjectType>::MsgType(response_id(),
87 const GURL& origin_url_; 71 object_id));
88 DISALLOW_IMPLICIT_CONSTRUCTORS(IndexedDBCallbacks);
89 };
90
91 template <>
92 class IndexedDBCallbacks<WebKit::WebIDBDatabase>
93 : public IndexedDBCallbacksBase {
94 public:
95 IndexedDBCallbacks(
96 IndexedDBDispatcherHost* dispatcher_host, int32 response_id,
97 const GURL& origin_url)
98 : IndexedDBCallbacksBase(dispatcher_host, response_id),
99 origin_url_(origin_url) {
100 } 72 }
101 73
102 virtual void onSuccess(WebKit::WebIDBDatabase* idb_object);
103 const GURL& origin_url() const { return origin_url_; }
104
105 private: 74 private:
106 GURL origin_url_; 75 GURL origin_url_;
107 DISALLOW_IMPLICIT_CONSTRUCTORS(IndexedDBCallbacks); 76 DISALLOW_IMPLICIT_CONSTRUCTORS(IndexedDBCallbacks);
108 }; 77 };
109 78
110 // WebIDBCursor uses onSuccess(WebIDBCursor*) to indicate it has data, and 79 // WebIDBCursor uses onSuccess(WebIDBCursor*) to indicate it has data, and
111 // onSuccess() without params to indicate it does not contain any data, i.e., 80 // onSuccess() without params to indicate it does not contain any data, i.e.,
112 // there is no key within the key range, or it has reached the end. 81 // there is no key within the key range, or it has reached the end.
113 template <> 82 template <>
114 class IndexedDBCallbacks<WebKit::WebIDBCursor> 83 class IndexedDBCallbacks<WebKit::WebIDBCursor>
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
153 IndexedDBDispatcherHost* dispatcher_host, int32 response_id) 122 IndexedDBDispatcherHost* dispatcher_host, int32 response_id)
154 : IndexedDBCallbacksBase(dispatcher_host, response_id) { } 123 : IndexedDBCallbacksBase(dispatcher_host, response_id) { }
155 124
156 virtual void onSuccess(const WebKit::WebSerializedScriptValue& value); 125 virtual void onSuccess(const WebKit::WebSerializedScriptValue& value);
157 126
158 private: 127 private:
159 DISALLOW_IMPLICIT_CONSTRUCTORS(IndexedDBCallbacks); 128 DISALLOW_IMPLICIT_CONSTRUCTORS(IndexedDBCallbacks);
160 }; 129 };
161 130
162 #endif // CONTENT_BROWSER_IN_PROCESS_WEBKIT_INDEXED_DB_CALLBACKS_H_ 131 #endif // CONTENT_BROWSER_IN_PROCESS_WEBKIT_INDEXED_DB_CALLBACKS_H_
OLDNEW
« no previous file with comments | « no previous file | content/browser/in_process_webkit/indexed_db_callbacks.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698