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

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

Issue 8747002: Dispatch IndexedDB IPC messages to worker threads (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix clang-enforced style violations Created 9 years 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
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"
(...skipping 15 matching lines...) Expand all
26 typedef IndexedDBMsg_CallbacksSuccessIDBDatabase MsgType; 26 typedef IndexedDBMsg_CallbacksSuccessIDBDatabase MsgType;
27 }; 27 };
28 template <> struct WebIDBToMsgHelper<WebKit::WebIDBTransaction> { 28 template <> struct WebIDBToMsgHelper<WebKit::WebIDBTransaction> {
29 typedef IndexedDBMsg_CallbacksSuccessIDBTransaction MsgType; 29 typedef IndexedDBMsg_CallbacksSuccessIDBTransaction MsgType;
30 }; 30 };
31 31
32 // The code the following two classes share. 32 // The code the following two classes share.
33 class IndexedDBCallbacksBase : public WebKit::WebIDBCallbacks { 33 class IndexedDBCallbacksBase : public WebKit::WebIDBCallbacks {
34 public: 34 public:
35 IndexedDBCallbacksBase(IndexedDBDispatcherHost* dispatcher_host, 35 IndexedDBCallbacksBase(IndexedDBDispatcherHost* dispatcher_host,
36 int32 thread_id,
36 int32 response_id); 37 int32 response_id);
37 38
38 virtual ~IndexedDBCallbacksBase(); 39 virtual ~IndexedDBCallbacksBase();
39 40
40 virtual void onError(const WebKit::WebIDBDatabaseError& error); 41 virtual void onError(const WebKit::WebIDBDatabaseError& error);
41 virtual void onBlocked(); 42 virtual void onBlocked();
42 43
43 protected: 44 protected:
44 IndexedDBDispatcherHost* dispatcher_host() const { 45 IndexedDBDispatcherHost* dispatcher_host() const {
45 return dispatcher_host_.get(); 46 return dispatcher_host_.get();
46 } 47 }
48 int32 thread_id() const { return thread_id_; }
47 int32 response_id() const { return response_id_; } 49 int32 response_id() const { return response_id_; }
48 50
49 private: 51 private:
50 scoped_refptr<IndexedDBDispatcherHost> dispatcher_host_; 52 scoped_refptr<IndexedDBDispatcherHost> dispatcher_host_;
51 int32 response_id_; 53 int32 response_id_;
54 int32 thread_id_;
52 55
53 DISALLOW_IMPLICIT_CONSTRUCTORS(IndexedDBCallbacksBase); 56 DISALLOW_IMPLICIT_CONSTRUCTORS(IndexedDBCallbacksBase);
54 }; 57 };
55 58
56 // A WebIDBCallbacks implementation that returns an object of WebObjectType. 59 // A WebIDBCallbacks implementation that returns an object of WebObjectType.
57 template <class WebObjectType> 60 template <class WebObjectType>
58 class IndexedDBCallbacks : public IndexedDBCallbacksBase { 61 class IndexedDBCallbacks : public IndexedDBCallbacksBase {
59 public: 62 public:
60 IndexedDBCallbacks( 63 IndexedDBCallbacks(
61 IndexedDBDispatcherHost* dispatcher_host, int32 response_id, 64 IndexedDBDispatcherHost* dispatcher_host,
65 int32 thread_id,
66 int32 response_id,
62 const GURL& origin_url) 67 const GURL& origin_url)
63 : IndexedDBCallbacksBase(dispatcher_host, response_id), 68 : IndexedDBCallbacksBase(dispatcher_host, thread_id, response_id),
64 origin_url_(origin_url) { 69 origin_url_(origin_url) {
65 } 70 }
66 71
67 virtual void onSuccess(WebObjectType* idb_object) { 72 virtual void onSuccess(WebObjectType* idb_object) {
68 int32 object_id = dispatcher_host()->Add(idb_object, origin_url_); 73 int32 object_id = dispatcher_host()->Add(idb_object, thread_id(),
74 origin_url_);
69 dispatcher_host()->Send( 75 dispatcher_host()->Send(
70 new typename WebIDBToMsgHelper<WebObjectType>::MsgType(response_id(), 76 new typename WebIDBToMsgHelper<WebObjectType>::MsgType(thread_id(),
77 response_id(),
71 object_id)); 78 object_id));
72 } 79 }
73 80
74 private: 81 private:
75 GURL origin_url_; 82 GURL origin_url_;
76 DISALLOW_IMPLICIT_CONSTRUCTORS(IndexedDBCallbacks); 83 DISALLOW_IMPLICIT_CONSTRUCTORS(IndexedDBCallbacks);
77 }; 84 };
78 85
79 // WebIDBCursor uses onSuccess(WebIDBCursor*) when a cursor has been opened, 86 // WebIDBCursor uses onSuccess(WebIDBCursor*) when a cursor has been opened,
80 // onSuccessWithContinuation() when a continue() call has succeeded, or 87 // onSuccessWithContinuation() when a continue() call has succeeded, or
81 // onSuccess() without params to indicate it does not contain any data, i.e., 88 // onSuccess() without params to indicate it does not contain any data, i.e.,
82 // there is no key within the key range, or it has reached the end. 89 // there is no key within the key range, or it has reached the end.
83 template <> 90 template <>
84 class IndexedDBCallbacks<WebKit::WebIDBCursor> 91 class IndexedDBCallbacks<WebKit::WebIDBCursor>
85 : public IndexedDBCallbacksBase { 92 : public IndexedDBCallbacksBase {
86 public: 93 public:
87 IndexedDBCallbacks( 94 IndexedDBCallbacks(
88 IndexedDBDispatcherHost* dispatcher_host, int32 response_id, 95 IndexedDBDispatcherHost* dispatcher_host,
96 int32 thread_id,
97 int32 response_id,
89 int32 cursor_id) 98 int32 cursor_id)
90 : IndexedDBCallbacksBase(dispatcher_host, response_id), 99 : IndexedDBCallbacksBase(dispatcher_host, thread_id, response_id),
91 cursor_id_(cursor_id) { } 100 cursor_id_(cursor_id) { }
92 101
93 virtual void onSuccess(WebKit::WebIDBCursor* idb_object); 102 virtual void onSuccess(WebKit::WebIDBCursor* idb_object);
94 virtual void onSuccess(const WebKit::WebSerializedScriptValue& value); 103 virtual void onSuccess(const WebKit::WebSerializedScriptValue& value);
95 virtual void onSuccessWithContinuation(); 104 virtual void onSuccessWithContinuation();
96 virtual void onSuccessWithPrefetch( 105 virtual void onSuccessWithPrefetch(
97 const WebKit::WebVector<WebKit::WebIDBKey>& keys, 106 const WebKit::WebVector<WebKit::WebIDBKey>& keys,
98 const WebKit::WebVector<WebKit::WebIDBKey>& primaryKeys, 107 const WebKit::WebVector<WebKit::WebIDBKey>& primaryKeys,
99 const WebKit::WebVector<WebKit::WebSerializedScriptValue>& values); 108 const WebKit::WebVector<WebKit::WebSerializedScriptValue>& values);
100 109
101 private: 110 private:
102 // The id of the cursor this callback concerns, or -1 if the cursor 111 // The id of the cursor this callback concerns, or -1 if the cursor
103 // does not exist yet. 112 // does not exist yet.
104 int32 cursor_id_; 113 int32 cursor_id_;
105 114
106 DISALLOW_IMPLICIT_CONSTRUCTORS(IndexedDBCallbacks); 115 DISALLOW_IMPLICIT_CONSTRUCTORS(IndexedDBCallbacks);
107 }; 116 };
108 117
109 // WebIDBKey is implemented in WebKit as opposed to being an interface Chromium 118 // WebIDBKey is implemented in WebKit as opposed to being an interface Chromium
110 // implements. Thus we pass a const ___& version and thus we need this 119 // implements. Thus we pass a const ___& version and thus we need this
111 // specialization. 120 // specialization.
112 template <> 121 template <>
113 class IndexedDBCallbacks<WebKit::WebIDBKey> 122 class IndexedDBCallbacks<WebKit::WebIDBKey>
114 : public IndexedDBCallbacksBase { 123 : public IndexedDBCallbacksBase {
115 public: 124 public:
116 IndexedDBCallbacks( 125 IndexedDBCallbacks(IndexedDBDispatcherHost* dispatcher_host,
117 IndexedDBDispatcherHost* dispatcher_host, int32 response_id) 126 int32 thread_id,
118 : IndexedDBCallbacksBase(dispatcher_host, response_id) { } 127 int32 response_id)
128 : IndexedDBCallbacksBase(dispatcher_host, thread_id, response_id) { }
119 129
120 virtual void onSuccess(const WebKit::WebIDBKey& value); 130 virtual void onSuccess(const WebKit::WebIDBKey& value);
121 131
122 private: 132 private:
123 DISALLOW_IMPLICIT_CONSTRUCTORS(IndexedDBCallbacks); 133 DISALLOW_IMPLICIT_CONSTRUCTORS(IndexedDBCallbacks);
124 }; 134 };
125 135
126 // WebDOMStringList is implemented in WebKit as opposed to being an 136 // WebDOMStringList is implemented in WebKit as opposed to being an
127 // interface Chromium implements. Thus we pass a const ___& version and thus 137 // interface Chromium implements. Thus we pass a const ___& version and thus
128 // we need this specialization. 138 // we need this specialization.
129 template <> 139 template <>
130 class IndexedDBCallbacks<WebKit::WebDOMStringList> 140 class IndexedDBCallbacks<WebKit::WebDOMStringList>
131 : public IndexedDBCallbacksBase { 141 : public IndexedDBCallbacksBase {
132 public: 142 public:
133 IndexedDBCallbacks( 143 IndexedDBCallbacks(
134 IndexedDBDispatcherHost* dispatcher_host, int32 response_id) 144 IndexedDBDispatcherHost* dispatcher_host,
135 : IndexedDBCallbacksBase(dispatcher_host, response_id) { } 145 int32 thread_id,
146 int32 response_id)
147 : IndexedDBCallbacksBase(dispatcher_host, thread_id, response_id) { }
136 148
137 virtual void onSuccess(const WebKit::WebDOMStringList& value); 149 virtual void onSuccess(const WebKit::WebDOMStringList& value);
138 150
139 private: 151 private:
140 DISALLOW_IMPLICIT_CONSTRUCTORS(IndexedDBCallbacks); 152 DISALLOW_IMPLICIT_CONSTRUCTORS(IndexedDBCallbacks);
141 }; 153 };
142 154
143 // WebSerializedScriptValue is implemented in WebKit as opposed to being an 155 // WebSerializedScriptValue is implemented in WebKit as opposed to being an
144 // interface Chromium implements. Thus we pass a const ___& version and thus 156 // interface Chromium implements. Thus we pass a const ___& version and thus
145 // we need this specialization. 157 // we need this specialization.
146 template <> 158 template <>
147 class IndexedDBCallbacks<WebKit::WebSerializedScriptValue> 159 class IndexedDBCallbacks<WebKit::WebSerializedScriptValue>
148 : public IndexedDBCallbacksBase { 160 : public IndexedDBCallbacksBase {
149 public: 161 public:
150 IndexedDBCallbacks( 162 IndexedDBCallbacks(IndexedDBDispatcherHost* dispatcher_host,
151 IndexedDBDispatcherHost* dispatcher_host, int32 response_id) 163 int32 thread_id,
152 : IndexedDBCallbacksBase(dispatcher_host, response_id) { } 164 int32 response_id)
165 : IndexedDBCallbacksBase(dispatcher_host, thread_id, response_id) { }
153 166
154 virtual void onSuccess(const WebKit::WebSerializedScriptValue& value); 167 virtual void onSuccess(const WebKit::WebSerializedScriptValue& value);
155 168
156 private: 169 private:
157 DISALLOW_IMPLICIT_CONSTRUCTORS(IndexedDBCallbacks); 170 DISALLOW_IMPLICIT_CONSTRUCTORS(IndexedDBCallbacks);
158 }; 171 };
159 172
160 #endif // CONTENT_BROWSER_IN_PROCESS_WEBKIT_INDEXED_DB_CALLBACKS_H_ 173 #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') | content/renderer/indexed_db_dispatcher.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698