diff options
-rw-r--r-- | chrome/browser/password_manager/password_store_x_unittest.cc | 8 | ||||
-rw-r--r-- | chrome/browser/sync/glue/ui_model_worker.cc | 3 | ||||
-rw-r--r-- | chrome/browser/sync/glue/ui_model_worker_unittest.cc | 1 | ||||
-rw-r--r-- | chrome/test/webdriver/webdriver_session.cc | 17 | ||||
-rw-r--r-- | content/browser/renderer_host/resource_dispatcher_host.cc | 34 | ||||
-rw-r--r-- | content/common/gpu/transport_texture.cc | 10 | ||||
-rw-r--r-- | content/common/gpu/transport_texture.h | 10 | ||||
-rw-r--r-- | net/disk_cache/backend_impl.cc | 22 | ||||
-rw-r--r-- | net/disk_cache/stress_cache.cc | 8 |
9 files changed, 44 insertions, 69 deletions
diff --git a/chrome/browser/password_manager/password_store_x_unittest.cc b/chrome/browser/password_manager/password_store_x_unittest.cc index 8eaf9b3..61c3c2f 100644 --- a/chrome/browser/password_manager/password_store_x_unittest.cc +++ b/chrome/browser/password_manager/password_store_x_unittest.cc @@ -231,7 +231,7 @@ void LoginDatabaseQueryCallback(LoginDatabase* login_db, mock_return->OnLoginDatabaseQueryDone(forms); } -// Generate |count| expected logins, either autofillable or blacklisted. +// Generate |count| expected logins, either auto-fillable or blacklisted. void InitExpectedForms(bool autofillable, size_t count, VectorOfForms* forms) { const char* domain = autofillable ? "example" : "blacklisted"; for (size_t i = 0; i < count; ++i) { @@ -695,7 +695,8 @@ TEST_P(PasswordStoreXTest, NativeMigration) { .WillOnce(WithArg<0>(STLDeleteElements0())); } - BrowserThread::PostTask(BrowserThread::DB, FROM_HERE, + BrowserThread::PostTask( + BrowserThread::DB, FROM_HERE, base::Bind(&LoginDatabaseQueryCallback, login_db, true, &ld_return)); // Wait for the login DB methods to execute on the DB thread. @@ -715,7 +716,8 @@ TEST_P(PasswordStoreXTest, NativeMigration) { .WillOnce(WithArg<0>(STLDeleteElements0())); } - BrowserThread::PostTask(BrowserThread::DB, FROM_HERE, + BrowserThread::PostTask( + BrowserThread::DB, FROM_HERE, base::Bind(&LoginDatabaseQueryCallback, login_db, false, &ld_return)); // Wait for the login DB methods to execute on the DB thread. diff --git a/chrome/browser/sync/glue/ui_model_worker.cc b/chrome/browser/sync/glue/ui_model_worker.cc index 7753e6a..c7ca1c5 100644 --- a/chrome/browser/sync/glue/ui_model_worker.cc +++ b/chrome/browser/sync/glue/ui_model_worker.cc @@ -17,6 +17,7 @@ namespace browser_sync { namespace { +// A simple callback to signal a waitable event after running a closure. void CallDoWorkAndSignalCallback(const WorkCallback& work, base::WaitableEvent* work_done, UIModelWorker* const scheduler, @@ -32,6 +33,7 @@ void CallDoWorkAndSignalCallback(const WorkCallback& work, // actually gets destroyed. return; } + *error_info = work.Run(); // Notify the UIModelWorker that scheduled us that we have run @@ -131,5 +133,4 @@ ModelSafeGroup UIModelWorker::GetModelSafeGroup() { return GROUP_UI; } - } // namespace browser_sync diff --git a/chrome/browser/sync/glue/ui_model_worker_unittest.cc b/chrome/browser/sync/glue/ui_model_worker_unittest.cc index b6b83db..577447e 100644 --- a/chrome/browser/sync/glue/ui_model_worker_unittest.cc +++ b/chrome/browser/sync/glue/ui_model_worker_unittest.cc @@ -66,6 +66,7 @@ void FakeSyncapiShutdownCallback(base::Thread* syncer_thread, base::WaitableEvent** jobs, size_t job_count) { base::WaitableEvent all_jobs_done(false, false); + // In real life, we would try and close a sync directory, which would // result in the syncer calling it's own destructor, which results in // the SyncerThread::HaltSyncer being called, which sets the diff --git a/chrome/test/webdriver/webdriver_session.cc b/chrome/test/webdriver/webdriver_session.cc index d1ad970..bf5d9a9 100644 --- a/chrome/test/webdriver/webdriver_session.cc +++ b/chrome/test/webdriver/webdriver_session.cc @@ -1207,23 +1207,6 @@ const Capabilities& Session::capabilities() const { return capabilities_; } -void Session::RunSessionTask(Task* task) { - base::WaitableEvent done_event(false, false); - thread_.message_loop_proxy()->PostTask(FROM_HERE, base::Bind( - &Session::RunSessionTaskOnSessionThread, - base::Unretained(this), - task, - &done_event)); - done_event.Wait(); -} - -void Session::RunSessionTaskOnSessionThread(Task* task, - base::WaitableEvent* done_event) { - task->Run(); - delete task; - done_event->Signal(); -} - void Session::RunSessionTask(const base::Closure& task) { base::WaitableEvent done_event(false, false); thread_.message_loop_proxy()->PostTask(FROM_HERE, base::Bind( diff --git a/content/browser/renderer_host/resource_dispatcher_host.cc b/content/browser/renderer_host/resource_dispatcher_host.cc index 8896fc7..46a1562 100644 --- a/content/browser/renderer_host/resource_dispatcher_host.cc +++ b/content/browser/renderer_host/resource_dispatcher_host.cc @@ -2027,23 +2027,19 @@ struct LoadInfo { // Map from ProcessID+ViewID pair to LoadState typedef std::map<std::pair<int, int>, LoadInfo> LoadInfoMap; -// Used to marshall calls to LoadStateChanged from the IO to UI threads. We do -// them all as a single task to avoid spamming the UI thread. -class LoadInfoUpdateTask : public Task { - public: - virtual void Run() { - LoadInfoMap::const_iterator i; - for (i = info_map.begin(); i != info_map.end(); ++i) { - RenderViewHost* view = - RenderViewHost::FromID(i->first.first, i->first.second); - if (view) // The view could be gone at this point. - view->LoadStateChanged(i->second.url, i->second.load_state, - i->second.upload_position, - i->second.upload_size); - } +// Used to marshal calls to LoadStateChanged from the IO to UI threads. We do +// them all as a single callback to avoid spamming the UI thread. +void LoadInfoUpdateCallback(const LoadInfoMap& info_map) { + LoadInfoMap::const_iterator i; + for (i = info_map.begin(); i != info_map.end(); ++i) { + RenderViewHost* view = + RenderViewHost::FromID(i->first.first, i->first.second); + if (view) // The view could be gone at this point. + view->LoadStateChanged(i->second.url, i->second.load_state, + i->second.upload_position, + i->second.upload_size); } - LoadInfoMap info_map; -}; +} } // namespace @@ -2102,9 +2098,9 @@ void ResourceDispatcherHost::UpdateLoadStates() { if (info_map.empty()) return; - LoadInfoUpdateTask* task = new LoadInfoUpdateTask; - task->info_map.swap(info_map); - BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, task); + BrowserThread::PostTask( + BrowserThread::UI, FROM_HERE, + base::Bind(&LoadInfoUpdateCallback, info_map)); } // Calls the ResourceHandler to send upload progress messages to the renderer. diff --git a/content/common/gpu/transport_texture.cc b/content/common/gpu/transport_texture.cc index ab65b49..3084549 100644 --- a/content/common/gpu/transport_texture.cc +++ b/content/common/gpu/transport_texture.cc @@ -24,10 +24,10 @@ TransportTexture::~TransportTexture() { void TransportTexture::CreateTextures( int n, int width, int height, Format format, std::vector<int>* textures, - Task* done_task) { + const base::Closure& callback) { output_textures_ = textures; - DCHECK(!create_task_.get()); - create_task_.reset(done_task); + DCHECK(create_callback_.is_null()); + create_callback_ = callback; bool ret = sender_->Send(new GpuTransportTextureHostMsg_CreateTextures( host_id_, n, width, height, static_cast<int>(format))); @@ -102,7 +102,7 @@ void TransportTexture::OnTexturesCreated(const std::vector<int>& textures) { } // Notify user that textures are ready. - create_task_->Run(); - create_task_.reset(); + create_callback_.Run(); + create_callback_.Reset(); output_textures_ = NULL; } diff --git a/content/common/gpu/transport_texture.h b/content/common/gpu/transport_texture.h index ae941e9..9f13ec4 100644 --- a/content/common/gpu/transport_texture.h +++ b/content/common/gpu/transport_texture.h @@ -47,10 +47,12 @@ class TransportTexture : public IPC::Channel::Listener { virtual ~TransportTexture(); // Create a set of textures of specified size and format. They will be - // stored in |textures| and |done_task| will be called. + // stored in |textures| and |callback| will be called. // Textures IDs stored in |textures| are in the system GL context. void CreateTextures(int n, int width, int height, Format format, - std::vector<int>* textures, Task* done_task); + std::vector<int>* textures, + const base::Closure& callback); + // Release all textures that have previously been allocated. void ReleaseTextures(); @@ -86,8 +88,8 @@ class TransportTexture : public IPC::Channel::Listener { // Output pointer to write generated textures. std::vector<int>* output_textures_; - // Task that gets called when textures are generated. - scoped_ptr<Task> create_task_; + // Callback that gets called when textures are generated. + base::Closure create_callback_; // Mapping between service (GPU) IDs to client (Renderer) IDs. TextureMap texture_map_; diff --git a/net/disk_cache/backend_impl.cc b/net/disk_cache/backend_impl.cc index c86d9a8..a014c5a 100644 --- a/net/disk_cache/backend_impl.cc +++ b/net/disk_cache/backend_impl.cc @@ -87,23 +87,10 @@ FilePath GetPrefixedName(const FilePath& path, const std::string& name, return path.AppendASCII(tmp); } -// This is a simple Task to cleanup old caches. -class CleanupTask : public Task { - public: - CleanupTask(const FilePath& path, const std::string& name) - : path_(path), name_(name) {} - - virtual void Run(); - - private: - FilePath path_; - std::string name_; - DISALLOW_COPY_AND_ASSIGN(CleanupTask); -}; - -void CleanupTask::Run() { +// This is a simple callback to cleanup old caches. +void CleanupCallback(const FilePath& path, const std::string& name) { for (int i = 0; i < kMaxOldFolders; i++) { - FilePath to_delete = GetPrefixedName(path_, name_, i); + FilePath to_delete = GetPrefixedName(path, name, i); disk_cache::DeleteCache(to_delete, true); } } @@ -148,7 +135,8 @@ bool DelayedCacheCleanup(const FilePath& full_path) { return false; } - base::WorkerPool::PostTask(FROM_HERE, new CleanupTask(path, name_str), true); + base::WorkerPool::PostTask( + FROM_HERE, base::Bind(&CleanupCallback, path, name_str), true); return true; } diff --git a/net/disk_cache/stress_cache.cc b/net/disk_cache/stress_cache.cc index b24aaa2..40a0143 100644 --- a/net/disk_cache/stress_cache.cc +++ b/net/disk_cache/stress_cache.cc @@ -184,9 +184,10 @@ void StressTheCache(int iteration) { // waiting for the debugger to attach. bool g_crashing = false; +// RunSoon() and CrashCallback() reference each other, unfortunately. void RunSoon(MessageLoop* target_loop); -void Crash() { +void CrashCallback() { // Keep trying to run. RunSoon(MessageLoop::current()); @@ -207,8 +208,9 @@ void Crash() { } void RunSoon(MessageLoop* target_loop) { - int task_delay = 10000; // 10 seconds - target_loop->PostDelayedTask(FROM_HERE, base::Bind(&Crash), task_delay); + const int kTaskDelay = 10000; // 10 seconds + target_loop->PostDelayedTask( + FROM_HERE, base::Bind(&CrashCallback), kTaskDelay); } // We leak everything here :) |