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

Side by Side Diff: webkit/tools/test_shell/simple_appcache_system.cc

Issue 2249005: AppCache: Use a dedicated thread for the disk cache. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Bound to IO thread Created 10 years, 6 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
OLDNEW
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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 "webkit/tools/test_shell/simple_appcache_system.h" 5 #include "webkit/tools/test_shell/simple_appcache_system.h"
6 6
7 #include "base/callback.h" 7 #include "base/callback.h"
8 #include "base/lock.h" 8 #include "base/lock.h"
9 #include "base/task.h" 9 #include "base/task.h"
10 #include "base/waitable_event.h" 10 #include "base/waitable_event.h"
(...skipping 313 matching lines...) Expand 10 before | Expand all | Expand 10 after
324 if (db_thread_.IsRunning()) { 324 if (db_thread_.IsRunning()) {
325 // We pump a task thru the db thread to ensure any tasks previously 325 // We pump a task thru the db thread to ensure any tasks previously
326 // scheduled on that thread have been performed prior to return. 326 // scheduled on that thread have been performed prior to return.
327 base::WaitableEvent event(false, false); 327 base::WaitableEvent event(false, false);
328 db_thread_.message_loop()->PostTask(FROM_HERE, 328 db_thread_.message_loop()->PostTask(FROM_HERE,
329 NewRunnableFunction(&SignalEvent, &event)); 329 NewRunnableFunction(&SignalEvent, &event));
330 event.Wait(); 330 event.Wait();
331 } 331 }
332 } 332 }
333 333
334 void SimpleAppCacheSystem::InitOnUIThread( 334 void SimpleAppCacheSystem::InitOnUIThread(const FilePath& cache_directory) {
335 const FilePath& cache_directory) {
336 DCHECK(!ui_message_loop_); 335 DCHECK(!ui_message_loop_);
337 // TODO(michaeln): provide a cache_thread message loop 336 AppCacheThread::Init(DB_THREAD_ID, IO_THREAD_ID);
338 AppCacheThread::Init(DB_THREAD_ID, IO_THREAD_ID, NULL);
339 ui_message_loop_ = MessageLoop::current(); 337 ui_message_loop_ = MessageLoop::current();
340 cache_directory_ = cache_directory; 338 cache_directory_ = cache_directory;
341 } 339 }
342 340
343 void SimpleAppCacheSystem::InitOnIOThread(URLRequestContext* request_context) { 341 void SimpleAppCacheSystem::InitOnIOThread(URLRequestContext* request_context) {
344 if (!is_initailized_on_ui_thread()) 342 if (!is_initailized_on_ui_thread())
345 return; 343 return;
346 344
347 DCHECK(!io_message_loop_); 345 DCHECK(!io_message_loop_);
348 io_message_loop_ = MessageLoop::current(); 346 io_message_loop_ = MessageLoop::current();
349 io_message_loop_->AddDestructionObserver(this); 347 io_message_loop_->AddDestructionObserver(this);
350 348
351 if (!db_thread_.IsRunning()) 349 if (!db_thread_.IsRunning())
352 db_thread_.Start(); 350 db_thread_.Start();
353 351
354 // Recreate and initialize per each IO thread. 352 // Recreate and initialize per each IO thread.
355 service_ = new appcache::AppCacheService(); 353 service_ = new appcache::AppCacheService();
356 backend_impl_ = new appcache::AppCacheBackendImpl(); 354 backend_impl_ = new appcache::AppCacheBackendImpl();
357 service_->Initialize(cache_directory_); 355 service_->Initialize(cache_directory_,
356 SimpleResourceLoaderBridge::GetCacheThread());
358 service_->set_request_context(request_context); 357 service_->set_request_context(request_context);
359 backend_impl_->Initialize(service_, frontend_proxy_.get(), kSingleProcessId); 358 backend_impl_->Initialize(service_, frontend_proxy_.get(), kSingleProcessId);
360 359
361 AppCacheInterceptor::EnsureRegistered(); 360 AppCacheInterceptor::EnsureRegistered();
362 } 361 }
363 362
364 WebApplicationCacheHost* SimpleAppCacheSystem::CreateCacheHostForWebKit( 363 WebApplicationCacheHost* SimpleAppCacheSystem::CreateCacheHostForWebKit(
365 WebApplicationCacheHostClient* client) { 364 WebApplicationCacheHostClient* client) {
366 if (!is_initailized_on_ui_thread()) 365 if (!is_initailized_on_ui_thread())
367 return NULL; 366 return NULL;
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
399 398
400 delete backend_impl_; 399 delete backend_impl_;
401 delete service_; 400 delete service_;
402 backend_impl_ = NULL; 401 backend_impl_ = NULL;
403 service_ = NULL; 402 service_ = NULL;
404 io_message_loop_ = NULL; 403 io_message_loop_ = NULL;
405 404
406 // Just in case the main thread is waiting on it. 405 // Just in case the main thread is waiting on it.
407 backend_proxy_->SignalEvent(); 406 backend_proxy_->SignalEvent();
408 } 407 }
OLDNEW
« no previous file with comments | « webkit/appcache/appcache_thread.cc ('k') | webkit/tools/test_shell/simple_resource_loader_bridge.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698