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

Side by Side Diff: content/browser/indexed_db/indexed_db_callbacks.cc

Issue 2601983002: [IndexedDB] Adding transaction and value support to observers (Closed)
Patch Set: rebase Created 3 years, 11 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
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 #include "content/browser/indexed_db/indexed_db_callbacks.h" 5 #include "content/browser/indexed_db/indexed_db_callbacks.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include <algorithm> 9 #include <algorithm>
10 #include <utility> 10 #include <utility>
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
69 if (value->primary_key.IsValid()) { 69 if (value->primary_key.IsValid()) {
70 mojo_value->primary_key = value->primary_key; 70 mojo_value->primary_key = value->primary_key;
71 mojo_value->key_path = value->key_path; 71 mojo_value->key_path = value->key_path;
72 } 72 }
73 if (!value->empty()) 73 if (!value->empty())
74 swap(mojo_value->value->bits, value->bits); 74 swap(mojo_value->value->bits, value->bits);
75 ConvertBlobInfo(value->blob_info, &mojo_value->value->blob_or_file_info); 75 ConvertBlobInfo(value->blob_info, &mojo_value->value->blob_or_file_info);
76 return mojo_value; 76 return mojo_value;
77 } 77 }
78 78
79 // Destructively converts an IndexedDBValue to a Mojo Value.
80 ::indexed_db::mojom::ValuePtr ConvertValue(IndexedDBValue* value) {
81 auto mojo_value = ::indexed_db::mojom::Value::New();
82 if (!value->empty())
83 swap(mojo_value->bits, value->bits);
84 ConvertBlobInfo(value->blob_info, &mojo_value->blob_or_file_info);
85 return mojo_value;
86 }
87
88 } // namespace 79 } // namespace
89 80
90 class IndexedDBCallbacks::IOThreadHelper { 81 class IndexedDBCallbacks::IOThreadHelper {
91 public: 82 public:
92 IOThreadHelper(CallbacksAssociatedPtrInfo callbacks_info, 83 IOThreadHelper(CallbacksAssociatedPtrInfo callbacks_info,
93 scoped_refptr<IndexedDBDispatcherHost> dispatcher_host); 84 scoped_refptr<IndexedDBDispatcherHost> dispatcher_host);
94 ~IOThreadHelper(); 85 ~IOThreadHelper();
95 86
96 void SendError(const IndexedDBDatabaseError& error); 87 void SendError(const IndexedDBDatabaseError& error);
97 void SendSuccessStringList(const std::vector<base::string16>& value); 88 void SendSuccessStringList(const std::vector<base::string16>& value);
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
133 std::vector<::indexed_db::mojom::BlobInfoPtr>* blob_or_file_info); 124 std::vector<::indexed_db::mojom::BlobInfoPtr>* blob_or_file_info);
134 void OnConnectionError(); 125 void OnConnectionError();
135 126
136 private: 127 private:
137 scoped_refptr<IndexedDBDispatcherHost> dispatcher_host_; 128 scoped_refptr<IndexedDBDispatcherHost> dispatcher_host_;
138 ::indexed_db::mojom::CallbacksAssociatedPtr callbacks_; 129 ::indexed_db::mojom::CallbacksAssociatedPtr callbacks_;
139 130
140 DISALLOW_COPY_AND_ASSIGN(IOThreadHelper); 131 DISALLOW_COPY_AND_ASSIGN(IOThreadHelper);
141 }; 132 };
142 133
134 // static
135 ::indexed_db::mojom::ValuePtr IndexedDBCallbacks::ConvertValue(
136 IndexedDBValue* value) {
137 auto mojo_value = ::indexed_db::mojom::Value::New();
138 if (!value->empty())
139 swap(mojo_value->bits, value->bits);
140 ConvertBlobInfo(value->blob_info, &mojo_value->blob_or_file_info);
141 return mojo_value;
142 }
143
143 IndexedDBCallbacks::IndexedDBCallbacks( 144 IndexedDBCallbacks::IndexedDBCallbacks(
144 scoped_refptr<IndexedDBDispatcherHost> dispatcher_host, 145 scoped_refptr<IndexedDBDispatcherHost> dispatcher_host,
145 const url::Origin& origin, 146 const url::Origin& origin,
146 ::indexed_db::mojom::CallbacksAssociatedPtrInfo callbacks_info) 147 ::indexed_db::mojom::CallbacksAssociatedPtrInfo callbacks_info)
147 : dispatcher_host_(std::move(dispatcher_host)), 148 : dispatcher_host_(std::move(dispatcher_host)),
148 origin_(origin), 149 origin_(origin),
149 data_loss_(blink::WebIDBDataLossNone), 150 data_loss_(blink::WebIDBDataLossNone),
150 sent_blocked_(false), 151 sent_blocked_(false),
151 io_helper_( 152 io_helper_(
152 new IOThreadHelper(std::move(callbacks_info), dispatcher_host_)) { 153 new IOThreadHelper(std::move(callbacks_info), dispatcher_host_)) {
(...skipping 474 matching lines...) Expand 10 before | Expand all | Expand 10 after
627 (*blob_or_file_info)[i]->uuid = CreateBlobData(blob_info[i]); 628 (*blob_or_file_info)[i]->uuid = CreateBlobData(blob_info[i]);
628 return true; 629 return true;
629 } 630 }
630 631
631 void IndexedDBCallbacks::IOThreadHelper::OnConnectionError() { 632 void IndexedDBCallbacks::IOThreadHelper::OnConnectionError() {
632 callbacks_.reset(); 633 callbacks_.reset();
633 dispatcher_host_ = nullptr; 634 dispatcher_host_ = nullptr;
634 } 635 }
635 636
636 } // namespace content 637 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698