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

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