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

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

Issue 10829013: Chrome side changes for integer versions (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: remove helper2 Created 8 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
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 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 7
8 #include "base/basictypes.h" 8 #include "base/basictypes.h"
9 #include "base/memory/ref_counted.h" 9 #include "base/memory/ref_counted.h"
10 #include "content/browser/in_process_webkit/indexed_db_dispatcher_host.h" 10 #include "content/browser/in_process_webkit/indexed_db_dispatcher_host.h"
11 #include "googleurl/src/gurl.h" 11 #include "googleurl/src/gurl.h"
12 #include "third_party/WebKit/Source/WebKit/chromium/public/WebIDBCallbacks.h" 12 #include "third_party/WebKit/Source/WebKit/chromium/public/WebIDBCallbacks.h"
13 #include "third_party/WebKit/Source/WebKit/chromium/public/WebIDBCursor.h" 13 #include "third_party/WebKit/Source/WebKit/chromium/public/WebIDBCursor.h"
14 #include "third_party/WebKit/Source/WebKit/chromium/public/WebIDBDatabaseError.h " 14 #include "third_party/WebKit/Source/WebKit/chromium/public/WebIDBDatabaseError.h "
15 #include "third_party/WebKit/Source/WebKit/chromium/public/WebIDBTransaction.h" 15 #include "third_party/WebKit/Source/WebKit/chromium/public/WebIDBTransaction.h"
16 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebString.h" 16 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebString.h"
17 17
18 class IndexedDBMsg_CallbacksSuccessIDBDatabase; 18 class IndexedDBMsg_CallbacksSuccessIDBDatabase;
19 class IndexedDBMsg_CallbacksSuccessIDBTransaction; 19 class IndexedDBMsg_CallbacksSuccessIDBTransaction;
20 class IndexedDBMsg_CallbacksUpgradeNeeded;
20 21
21 // 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
22 // which (overloaded) onSuccess method we expect to be called. 23 // which (overloaded) onSuccess method we expect to be called.
23 template <class Type> struct WebIDBToMsgHelper { }; 24 template <class Type> struct WebIDBToMsgHelper { };
24 template <> struct WebIDBToMsgHelper<WebKit::WebIDBDatabase> { 25 template <> struct WebIDBToMsgHelper<WebKit::WebIDBDatabase> {
25 typedef IndexedDBMsg_CallbacksSuccessIDBDatabase MsgType; 26 typedef IndexedDBMsg_CallbacksSuccessIDBDatabase MsgType;
26 }; 27 };
27 template <> struct WebIDBToMsgHelper<WebKit::WebIDBTransaction> { 28 template <> struct WebIDBToMsgHelper<WebKit::WebIDBTransaction> {
28 typedef IndexedDBMsg_CallbacksSuccessIDBTransaction MsgType; 29 typedef IndexedDBMsg_CallbacksSuccessIDBTransaction MsgType;
29 }; 30 };
30 31
32 namespace {
33 int32 kDatabaseNotAdded = -1;
34 }
35
31 // The code the following two classes share. 36 // The code the following two classes share.
32 class IndexedDBCallbacksBase : public WebKit::WebIDBCallbacks { 37 class IndexedDBCallbacksBase : public WebKit::WebIDBCallbacks {
33 public: 38 public:
34 IndexedDBCallbacksBase(IndexedDBDispatcherHost* dispatcher_host, 39 IndexedDBCallbacksBase(IndexedDBDispatcherHost* dispatcher_host,
35 int32 thread_id, 40 int32 thread_id,
36 int32 response_id); 41 int32 response_id);
37 42
38 virtual ~IndexedDBCallbacksBase(); 43 virtual ~IndexedDBCallbacksBase();
39 44
40 virtual void onError(const WebKit::WebIDBDatabaseError& error); 45 virtual void onError(const WebKit::WebIDBDatabaseError& error);
41 virtual void onBlocked(); 46 virtual void onBlocked();
47 virtual void onBlocked(long long old_version);
42 48
43 protected: 49 protected:
44 IndexedDBDispatcherHost* dispatcher_host() const { 50 IndexedDBDispatcherHost* dispatcher_host() const {
45 return dispatcher_host_.get(); 51 return dispatcher_host_.get();
46 } 52 }
47 int32 thread_id() const { return thread_id_; } 53 int32 thread_id() const { return thread_id_; }
48 int32 response_id() const { return response_id_; } 54 int32 response_id() const { return response_id_; }
49 55
50 private: 56 private:
51 scoped_refptr<IndexedDBDispatcherHost> dispatcher_host_; 57 scoped_refptr<IndexedDBDispatcherHost> dispatcher_host_;
52 int32 response_id_; 58 int32 response_id_;
53 int32 thread_id_; 59 int32 thread_id_;
54 60
55 DISALLOW_IMPLICIT_CONSTRUCTORS(IndexedDBCallbacksBase); 61 DISALLOW_IMPLICIT_CONSTRUCTORS(IndexedDBCallbacksBase);
56 }; 62 };
57 63
58 // A WebIDBCallbacks implementation that returns an object of WebObjectType. 64 // A WebIDBCallbacks implementation that returns an object of WebObjectType.
59 template <class WebObjectType> 65 template <class WebObjectType>
60 class IndexedDBCallbacks : public IndexedDBCallbacksBase { 66 class IndexedDBCallbacks : public IndexedDBCallbacksBase {
61 public: 67 public:
62 IndexedDBCallbacks( 68 IndexedDBCallbacks(
63 IndexedDBDispatcherHost* dispatcher_host, 69 IndexedDBDispatcherHost* dispatcher_host,
64 int32 thread_id, 70 int32 thread_id,
65 int32 response_id, 71 int32 response_id,
66 const GURL& origin_url) 72 const GURL& origin_url)
67 : IndexedDBCallbacksBase(dispatcher_host, thread_id, response_id), 73 : IndexedDBCallbacksBase(dispatcher_host, thread_id, response_id),
68 origin_url_(origin_url) { 74 origin_url_(origin_url),
75 database_id_(kDatabaseNotAdded) {
69 } 76 }
70 77
71 virtual void onSuccess(WebObjectType* idb_object) { 78 virtual void onSuccess(WebObjectType* idb_object) {
72 int32 object_id = dispatcher_host()->Add(idb_object, thread_id(), 79 int32 object_id = database_id_;
73 origin_url_); 80 if (object_id == kDatabaseNotAdded) {
81 object_id = dispatcher_host()->Add(idb_object, thread_id(), origin_url_);
82 } else {
83 // We already have this database and don't need a new copy of it.
84 delete idb_object;
dgrogan 2012/07/25 20:26:11 A better fix might be to add a map to IDBCallbacks
dgrogan 2012/07/25 20:27:09 That link to IDBCallbacksProxy doesn't actually im
85 }
86
74 dispatcher_host()->Send( 87 dispatcher_host()->Send(
75 new typename WebIDBToMsgHelper<WebObjectType>::MsgType(thread_id(), 88 new typename WebIDBToMsgHelper<WebObjectType>::MsgType(thread_id(),
76 response_id(), 89 response_id(),
77 object_id)); 90 object_id));
78 } 91 }
79 92
93 void onUpgradeNeeded(
94 long long old_version,
95 WebKit::WebIDBTransaction* transaction,
96 WebKit::WebIDBDatabase* database) {
97 NOTREACHED();
98 }
99
100
80 private: 101 private:
81 GURL origin_url_; 102 GURL origin_url_;
103 int32 database_id_;
82 DISALLOW_IMPLICIT_CONSTRUCTORS(IndexedDBCallbacks); 104 DISALLOW_IMPLICIT_CONSTRUCTORS(IndexedDBCallbacks);
83 }; 105 };
84 106
85 // WebIDBCursor uses onSuccess(WebIDBCursor*) when a cursor has been opened, 107 // WebIDBCursor uses onSuccess(WebIDBCursor*) when a cursor has been opened,
86 // onSuccessWithContinuation() when a continue() call has succeeded, or 108 // onSuccessWithContinuation() when a continue() call has succeeded, or
87 // onSuccess(SerializedScriptValue::nullValue()) to indicate it does 109 // onSuccess(SerializedScriptValue::nullValue()) to indicate it does
88 // not contain any data, i.e., there is no key within the key range, 110 // not contain any data, i.e., there is no key within the key range,
89 // or it has reached the end. 111 // or it has reached the end.
90 template <> 112 template <>
91 class IndexedDBCallbacks<WebKit::WebIDBCursor> 113 class IndexedDBCallbacks<WebKit::WebIDBCursor>
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
167 virtual void onSuccess(const WebKit::WebSerializedScriptValue& value); 189 virtual void onSuccess(const WebKit::WebSerializedScriptValue& value);
168 virtual void onSuccess(const WebKit::WebSerializedScriptValue& value, 190 virtual void onSuccess(const WebKit::WebSerializedScriptValue& value,
169 const WebKit::WebIDBKey& key, 191 const WebKit::WebIDBKey& key,
170 const WebKit::WebIDBKeyPath& keyPath); 192 const WebKit::WebIDBKeyPath& keyPath);
171 193
172 private: 194 private:
173 DISALLOW_IMPLICIT_CONSTRUCTORS(IndexedDBCallbacks); 195 DISALLOW_IMPLICIT_CONSTRUCTORS(IndexedDBCallbacks);
174 }; 196 };
175 197
176 #endif // CONTENT_BROWSER_IN_PROCESS_WEBKIT_INDEXED_DB_CALLBACKS_H_ 198 #endif // CONTENT_BROWSER_IN_PROCESS_WEBKIT_INDEXED_DB_CALLBACKS_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698