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

Side by Side Diff: content/child/indexed_db/webidbfactory_impl.cc

Issue 2642943002: Allow closing IndexedDB database before deleting (Closed)
Patch Set: Fixed compilation errors in tests 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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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/child/indexed_db/webidbfactory_impl.h" 5 #include "content/child/indexed_db/webidbfactory_impl.h"
6 6
7 #include "base/memory/ptr_util.h" 7 #include "base/memory/ptr_util.h"
8 #include "content/child/indexed_db/indexed_db_callbacks_impl.h" 8 #include "content/child/indexed_db/indexed_db_callbacks_impl.h"
9 #include "content/child/indexed_db/indexed_db_database_callbacks_impl.h" 9 #include "content/child/indexed_db/indexed_db_database_callbacks_impl.h"
10 #include "content/child/storage_util.h" 10 #include "content/child/storage_util.h"
(...skipping 27 matching lines...) Expand all
38 void GetDatabaseNames(std::unique_ptr<IndexedDBCallbacksImpl> callbacks, 38 void GetDatabaseNames(std::unique_ptr<IndexedDBCallbacksImpl> callbacks,
39 const url::Origin& origin); 39 const url::Origin& origin);
40 void Open(const base::string16& name, 40 void Open(const base::string16& name,
41 int64_t version, 41 int64_t version,
42 int64_t transaction_id, 42 int64_t transaction_id,
43 std::unique_ptr<IndexedDBCallbacksImpl> callbacks, 43 std::unique_ptr<IndexedDBCallbacksImpl> callbacks,
44 std::unique_ptr<IndexedDBDatabaseCallbacksImpl> database_callbacks, 44 std::unique_ptr<IndexedDBDatabaseCallbacksImpl> database_callbacks,
45 const url::Origin& origin); 45 const url::Origin& origin);
46 void DeleteDatabase(const base::string16& name, 46 void DeleteDatabase(const base::string16& name,
47 std::unique_ptr<IndexedDBCallbacksImpl> callbacks, 47 std::unique_ptr<IndexedDBCallbacksImpl> callbacks,
48 const url::Origin& origin); 48 const url::Origin& origin,
49 bool force_close);
49 50
50 private: 51 private:
51 scoped_refptr<IPC::SyncMessageFilter> sync_message_filter_; 52 scoped_refptr<IPC::SyncMessageFilter> sync_message_filter_;
52 FactoryAssociatedPtr service_; 53 FactoryAssociatedPtr service_;
53 54
54 DISALLOW_COPY_AND_ASSIGN(IOThreadHelper); 55 DISALLOW_COPY_AND_ASSIGN(IOThreadHelper);
55 }; 56 };
56 57
57 WebIDBFactoryImpl::WebIDBFactoryImpl( 58 WebIDBFactoryImpl::WebIDBFactoryImpl(
58 scoped_refptr<IPC::SyncMessageFilter> sync_message_filter, 59 scoped_refptr<IPC::SyncMessageFilter> sync_message_filter,
(...skipping 30 matching lines...) Expand all
89 io_runner_->PostTask( 90 io_runner_->PostTask(
90 FROM_HERE, 91 FROM_HERE,
91 base::Bind(&IOThreadHelper::Open, base::Unretained(io_helper_), 92 base::Bind(&IOThreadHelper::Open, base::Unretained(io_helper_),
92 name.utf16(), version, transaction_id, 93 name.utf16(), version, transaction_id,
93 base::Passed(&callbacks_impl), 94 base::Passed(&callbacks_impl),
94 base::Passed(&database_callbacks_impl), url::Origin(origin))); 95 base::Passed(&database_callbacks_impl), url::Origin(origin)));
95 } 96 }
96 97
97 void WebIDBFactoryImpl::deleteDatabase(const WebString& name, 98 void WebIDBFactoryImpl::deleteDatabase(const WebString& name,
98 WebIDBCallbacks* callbacks, 99 WebIDBCallbacks* callbacks,
99 const WebSecurityOrigin& origin) { 100 const WebSecurityOrigin& origin,
101 bool force_close) {
100 auto callbacks_impl = base::MakeUnique<IndexedDBCallbacksImpl>( 102 auto callbacks_impl = base::MakeUnique<IndexedDBCallbacksImpl>(
101 base::WrapUnique(callbacks), IndexedDBCallbacksImpl::kNoTransaction, 103 base::WrapUnique(callbacks), IndexedDBCallbacksImpl::kNoTransaction,
102 nullptr, io_runner_); 104 nullptr, io_runner_);
103 io_runner_->PostTask( 105 io_runner_->PostTask(
104 FROM_HERE, 106 FROM_HERE,
105 base::Bind(&IOThreadHelper::DeleteDatabase, base::Unretained(io_helper_), 107 base::Bind(&IOThreadHelper::DeleteDatabase, base::Unretained(io_helper_),
106 name.utf16(), base::Passed(&callbacks_impl), 108 name.utf16(), base::Passed(&callbacks_impl),
107 url::Origin(origin))); 109 url::Origin(origin), force_close));
108 } 110 }
109 111
110 WebIDBFactoryImpl::IOThreadHelper::IOThreadHelper( 112 WebIDBFactoryImpl::IOThreadHelper::IOThreadHelper(
111 scoped_refptr<IPC::SyncMessageFilter> sync_message_filter) 113 scoped_refptr<IPC::SyncMessageFilter> sync_message_filter)
112 : sync_message_filter_(std::move(sync_message_filter)) {} 114 : sync_message_filter_(std::move(sync_message_filter)) {}
113 115
114 WebIDBFactoryImpl::IOThreadHelper::~IOThreadHelper() {} 116 WebIDBFactoryImpl::IOThreadHelper::~IOThreadHelper() {}
115 117
116 FactoryAssociatedPtr& WebIDBFactoryImpl::IOThreadHelper::GetService() { 118 FactoryAssociatedPtr& WebIDBFactoryImpl::IOThreadHelper::GetService() {
117 if (!service_) 119 if (!service_)
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
155 std::unique_ptr<IndexedDBDatabaseCallbacksImpl> database_callbacks, 157 std::unique_ptr<IndexedDBDatabaseCallbacksImpl> database_callbacks,
156 const url::Origin& origin) { 158 const url::Origin& origin) {
157 GetService()->Open(GetCallbacksProxy(std::move(callbacks)), 159 GetService()->Open(GetCallbacksProxy(std::move(callbacks)),
158 GetDatabaseCallbacksProxy(std::move(database_callbacks)), 160 GetDatabaseCallbacksProxy(std::move(database_callbacks)),
159 origin, name, version, transaction_id); 161 origin, name, version, transaction_id);
160 } 162 }
161 163
162 void WebIDBFactoryImpl::IOThreadHelper::DeleteDatabase( 164 void WebIDBFactoryImpl::IOThreadHelper::DeleteDatabase(
163 const base::string16& name, 165 const base::string16& name,
164 std::unique_ptr<IndexedDBCallbacksImpl> callbacks, 166 std::unique_ptr<IndexedDBCallbacksImpl> callbacks,
165 const url::Origin& origin) { 167 const url::Origin& origin,
168 bool force_close) {
166 GetService()->DeleteDatabase(GetCallbacksProxy(std::move(callbacks)), origin, 169 GetService()->DeleteDatabase(GetCallbacksProxy(std::move(callbacks)), origin,
167 name); 170 name, force_close);
168 } 171 }
169 172
170 } // namespace content 173 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698