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

Side by Side Diff: content/browser/in_process_webkit/indexed_db_key_utility_client.cc

Issue 8221021: Modify WaitableEvent::Wait() to return void (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fixed comment and style Created 9 years, 2 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 | « chrome/service/gaia/service_gaia_authenticator.cc ('k') | net/base/keygen_handler_unittest.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) 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/lazy_instance.h" 7 #include "base/lazy_instance.h"
8 #include "base/synchronization/waitable_event.h" 8 #include "base/synchronization/waitable_event.h"
9 #include "content/browser/utility_process_host.h" 9 #include "content/browser/utility_process_host.h"
10 #include "content/common/indexed_db_key.h" 10 #include "content/common/indexed_db_key.h"
(...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after
190 DCHECK(state_ == STATE_UNINITIALIZED || state_ == STATE_SHUTDOWN); 190 DCHECK(state_ == STATE_UNINITIALIZED || state_ == STATE_SHUTDOWN);
191 DCHECK(!utility_process_host_); 191 DCHECK(!utility_process_host_);
192 DCHECK(!client_.get()); 192 DCHECK(!client_.get());
193 } 193 }
194 194
195 void KeyUtilityClientImpl::StartUtilityProcess() { 195 void KeyUtilityClientImpl::StartUtilityProcess() {
196 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::WEBKIT)); 196 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::WEBKIT));
197 DCHECK(state_ == STATE_UNINITIALIZED); 197 DCHECK(state_ == STATE_UNINITIALIZED);
198 198
199 GetRDHAndStartUtilityProcess(); 199 GetRDHAndStartUtilityProcess();
200 bool ret = waitable_event_.Wait(); 200 waitable_event_.Wait();
201 201
202 DCHECK(ret && state_ == STATE_INITIALIZED); 202 DCHECK(state_ == STATE_INITIALIZED);
203 } 203 }
204 204
205 void KeyUtilityClientImpl::CreateIDBKeysFromSerializedValuesAndKeyPath( 205 void KeyUtilityClientImpl::CreateIDBKeysFromSerializedValuesAndKeyPath(
206 const std::vector<SerializedScriptValue>& values, 206 const std::vector<SerializedScriptValue>& values,
207 const string16& key_path, 207 const string16& key_path,
208 std::vector<IndexedDBKey>* keys) { 208 std::vector<IndexedDBKey>* keys) {
209 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::WEBKIT)); 209 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::WEBKIT));
210 if (state_ == STATE_SHUTDOWN) { 210 if (state_ == STATE_SHUTDOWN) {
211 keys->clear(); 211 keys->clear();
212 return; 212 return;
213 } 213 }
214 214
215 DCHECK(state_ == STATE_INITIALIZED); 215 DCHECK(state_ == STATE_INITIALIZED);
216 216
217 state_ = STATE_CREATING_KEYS; 217 state_ = STATE_CREATING_KEYS;
218 CallStartIDBKeyFromValueAndKeyPathFromIOThread(values, key_path); 218 CallStartIDBKeyFromValueAndKeyPathFromIOThread(values, key_path);
219 bool ret = waitable_event_.Wait(); 219 waitable_event_.Wait();
220 DCHECK(ret && state_ == STATE_INITIALIZED); 220 DCHECK(state_ == STATE_INITIALIZED);
221 221
222 *keys = keys_; 222 *keys = keys_;
223 } 223 }
224 224
225 SerializedScriptValue KeyUtilityClientImpl::InjectIDBKeyIntoSerializedValue( 225 SerializedScriptValue KeyUtilityClientImpl::InjectIDBKeyIntoSerializedValue(
226 const IndexedDBKey& key, 226 const IndexedDBKey& key,
227 const SerializedScriptValue& value, 227 const SerializedScriptValue& value,
228 const string16& key_path) { 228 const string16& key_path) {
229 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::WEBKIT)); 229 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::WEBKIT));
230 if (state_ == STATE_SHUTDOWN) 230 if (state_ == STATE_SHUTDOWN)
231 return SerializedScriptValue(); 231 return SerializedScriptValue();
232 232
233 DCHECK(state_ == STATE_INITIALIZED); 233 DCHECK(state_ == STATE_INITIALIZED);
234 234
235 state_ = STATE_INJECTING_KEY; 235 state_ = STATE_INJECTING_KEY;
236 CallStartInjectIDBKeyFromIOThread(key, value, key_path); 236 CallStartInjectIDBKeyFromIOThread(key, value, key_path);
237 237
238 bool ret = waitable_event_.Wait(); 238 waitable_event_.Wait();
239 DCHECK(ret && state_ == STATE_INITIALIZED); 239 DCHECK(state_ == STATE_INITIALIZED);
240 240
241 return value_after_injection_; 241 return value_after_injection_;
242 } 242 }
243 243
244 244
245 void KeyUtilityClientImpl::GetRDHAndStartUtilityProcess() { 245 void KeyUtilityClientImpl::GetRDHAndStartUtilityProcess() {
246 // In order to start the UtilityProcess, we need to grab 246 // In order to start the UtilityProcess, we need to grab
247 // a pointer to the ResourceDispatcherHost. This can only 247 // a pointer to the ResourceDispatcherHost. This can only
248 // be done on the UI thread. See the comment at the top of 248 // be done on the UI thread. See the comment at the top of
249 // browser_process.h 249 // browser_process.h
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after
391 void KeyUtilityClientImpl::Client::OnInjectIDBKeyFinished( 391 void KeyUtilityClientImpl::Client::OnInjectIDBKeyFinished(
392 const SerializedScriptValue& value) { 392 const SerializedScriptValue& value) {
393 parent_->SetValueAfterInjection(value); 393 parent_->SetValueAfterInjection(value);
394 parent_->FinishInjectingKey(); 394 parent_->FinishInjectingKey();
395 } 395 }
396 396
397 void KeyUtilityClientImpl::Client::OnIDBKeysFromValuesAndKeyPathFailed( 397 void KeyUtilityClientImpl::Client::OnIDBKeysFromValuesAndKeyPathFailed(
398 int id) { 398 int id) {
399 parent_->FinishCreatingKeys(); 399 parent_->FinishCreatingKeys();
400 } 400 }
OLDNEW
« no previous file with comments | « chrome/service/gaia/service_gaia_authenticator.cc ('k') | net/base/keygen_handler_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698