OLD | NEW |
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 #include "content/browser/in_process_webkit/indexed_db_key_utility_client.h" | 5 #include "content/browser/in_process_webkit/indexed_db_key_utility_client.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/lazy_instance.h" | 8 #include "base/lazy_instance.h" |
9 #include "base/synchronization/waitable_event.h" | 9 #include "base/synchronization/waitable_event.h" |
10 #include "content/browser/utility_process_host.h" | 10 #include "content/browser/utility_process_host.h" |
(...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
189 utility_process_host_(NULL) { | 189 utility_process_host_(NULL) { |
190 } | 190 } |
191 | 191 |
192 KeyUtilityClientImpl::~KeyUtilityClientImpl() { | 192 KeyUtilityClientImpl::~KeyUtilityClientImpl() { |
193 DCHECK(state_ == STATE_UNINITIALIZED || state_ == STATE_SHUTDOWN); | 193 DCHECK(state_ == STATE_UNINITIALIZED || state_ == STATE_SHUTDOWN); |
194 DCHECK(!utility_process_host_); | 194 DCHECK(!utility_process_host_); |
195 DCHECK(!client_.get()); | 195 DCHECK(!client_.get()); |
196 } | 196 } |
197 | 197 |
198 void KeyUtilityClientImpl::StartUtilityProcess() { | 198 void KeyUtilityClientImpl::StartUtilityProcess() { |
199 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::WEBKIT)); | 199 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::WEBKIT_DEPRECATED)); |
200 DCHECK(state_ == STATE_UNINITIALIZED); | 200 DCHECK(state_ == STATE_UNINITIALIZED); |
201 | 201 |
202 GetRDHAndStartUtilityProcess(); | 202 GetRDHAndStartUtilityProcess(); |
203 waitable_event_.Wait(); | 203 waitable_event_.Wait(); |
204 | 204 |
205 DCHECK(state_ == STATE_INITIALIZED); | 205 DCHECK(state_ == STATE_INITIALIZED); |
206 } | 206 } |
207 | 207 |
208 void KeyUtilityClientImpl::CreateIDBKeysFromSerializedValuesAndKeyPath( | 208 void KeyUtilityClientImpl::CreateIDBKeysFromSerializedValuesAndKeyPath( |
209 const std::vector<content::SerializedScriptValue>& values, | 209 const std::vector<content::SerializedScriptValue>& values, |
210 const string16& key_path, | 210 const string16& key_path, |
211 std::vector<IndexedDBKey>* keys) { | 211 std::vector<IndexedDBKey>* keys) { |
212 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::WEBKIT)); | 212 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::WEBKIT_DEPRECATED)); |
213 if (state_ == STATE_SHUTDOWN) { | 213 if (state_ == STATE_SHUTDOWN) { |
214 keys->clear(); | 214 keys->clear(); |
215 return; | 215 return; |
216 } | 216 } |
217 | 217 |
218 DCHECK(state_ == STATE_INITIALIZED); | 218 DCHECK(state_ == STATE_INITIALIZED); |
219 | 219 |
220 state_ = STATE_CREATING_KEYS; | 220 state_ = STATE_CREATING_KEYS; |
221 CallStartIDBKeyFromValueAndKeyPathFromIOThread(values, key_path); | 221 CallStartIDBKeyFromValueAndKeyPathFromIOThread(values, key_path); |
222 waitable_event_.Wait(); | 222 waitable_event_.Wait(); |
223 DCHECK(state_ == STATE_INITIALIZED); | 223 DCHECK(state_ == STATE_INITIALIZED); |
224 | 224 |
225 *keys = keys_; | 225 *keys = keys_; |
226 } | 226 } |
227 | 227 |
228 content::SerializedScriptValue | 228 content::SerializedScriptValue |
229 KeyUtilityClientImpl::InjectIDBKeyIntoSerializedValue( | 229 KeyUtilityClientImpl::InjectIDBKeyIntoSerializedValue( |
230 const IndexedDBKey& key, | 230 const IndexedDBKey& key, |
231 const content::SerializedScriptValue& value, | 231 const content::SerializedScriptValue& value, |
232 const string16& key_path) { | 232 const string16& key_path) { |
233 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::WEBKIT)); | 233 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::WEBKIT_DEPRECATED)); |
234 if (state_ == STATE_SHUTDOWN) | 234 if (state_ == STATE_SHUTDOWN) |
235 return content::SerializedScriptValue(); | 235 return content::SerializedScriptValue(); |
236 | 236 |
237 DCHECK(state_ == STATE_INITIALIZED); | 237 DCHECK(state_ == STATE_INITIALIZED); |
238 | 238 |
239 state_ = STATE_INJECTING_KEY; | 239 state_ = STATE_INJECTING_KEY; |
240 CallStartInjectIDBKeyFromIOThread(key, value, key_path); | 240 CallStartInjectIDBKeyFromIOThread(key, value, key_path); |
241 | 241 |
242 waitable_event_.Wait(); | 242 waitable_event_.Wait(); |
243 DCHECK(state_ == STATE_INITIALIZED); | 243 DCHECK(state_ == STATE_INITIALIZED); |
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
386 void KeyUtilityClientImpl::Client::OnInjectIDBKeyFinished( | 386 void KeyUtilityClientImpl::Client::OnInjectIDBKeyFinished( |
387 const content::SerializedScriptValue& value) { | 387 const content::SerializedScriptValue& value) { |
388 parent_->SetValueAfterInjection(value); | 388 parent_->SetValueAfterInjection(value); |
389 parent_->FinishInjectingKey(); | 389 parent_->FinishInjectingKey(); |
390 } | 390 } |
391 | 391 |
392 void KeyUtilityClientImpl::Client::OnIDBKeysFromValuesAndKeyPathFailed( | 392 void KeyUtilityClientImpl::Client::OnIDBKeysFromValuesAndKeyPathFailed( |
393 int id) { | 393 int id) { |
394 parent_->FinishCreatingKeys(); | 394 parent_->FinishCreatingKeys(); |
395 } | 395 } |
OLD | NEW |