diff options
author | brettw@chromium.org <brettw@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-03-10 01:01:10 +0000 |
---|---|---|
committer | brettw@chromium.org <brettw@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-03-10 01:01:10 +0000 |
commit | 232aabfca535b962d41aae13f08104292b40cbaa (patch) | |
tree | 5b0bb37f4262fc797b9b71c3011e4d5142c6ba1a /ppapi | |
parent | 5d50b28df12016b7582497cd7282454622b52782 (diff) | |
download | chromium_src-232aabfca535b962d41aae13f08104292b40cbaa.zip chromium_src-232aabfca535b962d41aae13f08104292b40cbaa.tar.gz chromium_src-232aabfca535b962d41aae13f08104292b40cbaa.tar.bz2 |
Remove NewRequiredCallback.
This is the same as NewCallback, and we want people to normally use the
"required" type. So just having them call NewCallback is usually the right
thing. This converts the existing callers to just say NewCallback.
BUG=
TEST=
Review URL: http://codereview.chromium.org/9615050
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@125965 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ppapi')
-rw-r--r-- | ppapi/examples/audio_input/audio_input.cc | 4 | ||||
-rw-r--r-- | ppapi/examples/flash_topmost/flash_topmost.cc | 4 | ||||
-rw-r--r-- | ppapi/examples/gamepad/gamepad.cc | 2 | ||||
-rw-r--r-- | ppapi/examples/mouse_lock/mouse_lock.cc | 13 | ||||
-rw-r--r-- | ppapi/examples/url_loader/streaming.cc | 4 | ||||
-rw-r--r-- | ppapi/native_client/src/trusted/plugin/file_downloader.cc | 2 | ||||
-rw-r--r-- | ppapi/native_client/src/trusted/plugin/plugin.cc | 18 | ||||
-rw-r--r-- | ppapi/tests/test_flash.cc | 4 | ||||
-rw-r--r-- | ppapi/tests/test_flash_message_loop.cc | 10 | ||||
-rw-r--r-- | ppapi/utility/completion_callback_factory.h | 95 |
10 files changed, 29 insertions, 127 deletions
diff --git a/ppapi/examples/audio_input/audio_input.cc b/ppapi/examples/audio_input/audio_input.cc index 44fd337..7aff669 100644 --- a/ppapi/examples/audio_input/audio_input.cc +++ b/ppapi/examples/audio_input/audio_input.cc @@ -130,7 +130,7 @@ class MyInstance : public pp::Instance { PP_DCHECK(timer_interval_ > 0); pp::Module::Get()->core()->CallOnMainThread( timer_interval_, - callback_factory_.NewRequiredCallback(&MyInstance::OnTimer), + callback_factory_.NewCallback(&MyInstance::OnTimer), 0); } @@ -161,7 +161,7 @@ class MyInstance : public pp::Instance { device_context_.ReplaceContents(&image); waiting_for_flush_completion_ = true; device_context_.Flush( - callback_factory_.NewRequiredCallback(&MyInstance::DidFlush)); + callback_factory_.NewCallback(&MyInstance::DidFlush)); } } diff --git a/ppapi/examples/flash_topmost/flash_topmost.cc b/ppapi/examples/flash_topmost/flash_topmost.cc index fe17092..dcdcd23 100644 --- a/ppapi/examples/flash_topmost/flash_topmost.cc +++ b/ppapi/examples/flash_topmost/flash_topmost.cc @@ -45,7 +45,7 @@ class MyInstance : public pp::Instance { void ScheduleNextTimer() { pp::Module::Get()->core()->CallOnMainThread( kTimerInterval, - callback_factory_.NewRequiredCallback(&MyInstance::OnTimer), + callback_factory_.NewCallback(&MyInstance::OnTimer), 0); } @@ -76,7 +76,7 @@ class MyInstance : public pp::Instance { device_context_.ReplaceContents(&image); waiting_for_flush_completion_ = true; device_context_.Flush( - callback_factory_.NewRequiredCallback(&MyInstance::DidFlush)); + callback_factory_.NewCallback(&MyInstance::DidFlush)); } } diff --git a/ppapi/examples/gamepad/gamepad.cc b/ppapi/examples/gamepad/gamepad.cc index eb2c8fc..96a127c 100644 --- a/ppapi/examples/gamepad/gamepad.cc +++ b/ppapi/examples/gamepad/gamepad.cc @@ -78,7 +78,7 @@ class MyInstance : public pp::Instance { if (!image.is_null()) { device_context_.ReplaceContents(&image); device_context_.Flush( - callback_factory_.NewRequiredCallback(&MyInstance::OnFlush)); + callback_factory_.NewCallback(&MyInstance::OnFlush)); } else { printf("NullImage\n"); } diff --git a/ppapi/examples/mouse_lock/mouse_lock.cc b/ppapi/examples/mouse_lock/mouse_lock.cc index f6bfbb6..7eec828 100644 --- a/ppapi/examples/mouse_lock/mouse_lock.cc +++ b/ppapi/examples/mouse_lock/mouse_lock.cc @@ -51,8 +51,7 @@ class MyInstance : public pp::Instance, public pp::MouseLock { pp::MouseInputEvent mouse_event(event); if (mouse_event.GetButton() == PP_INPUTEVENT_MOUSEBUTTON_LEFT && !mouse_locked_) { - LockMouse( - callback_factory_.NewRequiredCallback(&MyInstance::DidLockMouse)); + LockMouse(callback_factory_.NewCallback(&MyInstance::DidLockMouse)); } return true; } @@ -69,12 +68,10 @@ class MyInstance : public pp::Instance, public pp::MouseLock { pp::KeyboardInputEvent key_event(event); // Lock the mouse when the Enter key is pressed. if (key_event.GetKeyCode() == 13) { - if (mouse_locked_) { + if (mouse_locked_) UnlockMouse(); - } else { - LockMouse(callback_factory_.NewRequiredCallback( - &MyInstance::DidLockMouse)); - } + else + LockMouse(callback_factory_.NewCallback(&MyInstance::DidLockMouse)); return true; } return false; @@ -135,7 +132,7 @@ class MyInstance : public pp::Instance, public pp::MouseLock { device_context_.ReplaceContents(&image); waiting_for_flush_completion_ = true; device_context_.Flush( - callback_factory_.NewRequiredCallback(&MyInstance::DidFlush)); + callback_factory_.NewCallback(&MyInstance::DidFlush)); } } diff --git a/ppapi/examples/url_loader/streaming.cc b/ppapi/examples/url_loader/streaming.cc index b7186ae..80ee4f0 100644 --- a/ppapi/examples/url_loader/streaming.cc +++ b/ppapi/examples/url_loader/streaming.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Copyright (c) 2012 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -82,7 +82,7 @@ void MyInstance::StartRequest(const std::string& url) { loader_ = pp::URLLoader(this); loader_.Open(request, - factory_.NewRequiredCallback(&MyInstance::OnOpenComplete)); + factory_.NewCallback(&MyInstance::OnOpenComplete)); } void MyInstance::OnOpenComplete(int32_t result) { diff --git a/ppapi/native_client/src/trusted/plugin/file_downloader.cc b/ppapi/native_client/src/trusted/plugin/file_downloader.cc index 8b73697..7f87838 100644 --- a/ppapi/native_client/src/trusted/plugin/file_downloader.cc +++ b/ppapi/native_client/src/trusted/plugin/file_downloader.cc @@ -122,7 +122,7 @@ bool FileDownloader::Open( // synchronously all other internal callbacks that eventually result in the // invocation of the user callback. The user code will not be reentered. pp::CompletionCallback onload_callback = - callback_factory_.NewRequiredCallback(start_notify); + callback_factory_.NewCallback(start_notify); int32_t pp_error = url_loader_.Open(url_request, onload_callback); PLUGIN_PRINTF(("FileDownloader::Open (pp_error=%"NACL_PRId32")\n", pp_error)); CHECK(pp_error == PP_OK_COMPLETIONPENDING); diff --git a/ppapi/native_client/src/trusted/plugin/plugin.cc b/ppapi/native_client/src/trusted/plugin/plugin.cc index 05d63b0..7e3abe4 100644 --- a/ppapi/native_client/src/trusted/plugin/plugin.cc +++ b/ppapi/native_client/src/trusted/plugin/plugin.cc @@ -1496,7 +1496,7 @@ void Plugin::ProcessNaClManifest(const nacl::string& manifest_json) { return; } else { pp::CompletionCallback open_callback = - callback_factory_.NewRequiredCallback(&Plugin::NexeFileDidOpen); + callback_factory_.NewCallback(&Plugin::NexeFileDidOpen); // Will always call the callback on success or failure. CHECK( nexe_downloader_.Open(program_url, @@ -1538,7 +1538,7 @@ void Plugin::RequestNaClManifest(const nacl::string& url) { HistogramEnumerateManifestIsDataURI(static_cast<int>(is_data_uri)); if (is_data_uri) { pp::CompletionCallback open_callback = - callback_factory_.NewRequiredCallback(&Plugin::NaClManifestBufferReady); + callback_factory_.NewCallback(&Plugin::NaClManifestBufferReady); // Will always call the callback on success or failure. CHECK(nexe_downloader_.Open(nmf_resolved_url.AsString(), DOWNLOAD_TO_BUFFER, @@ -1546,7 +1546,7 @@ void Plugin::RequestNaClManifest(const nacl::string& url) { NULL)); } else { pp::CompletionCallback open_callback = - callback_factory_.NewRequiredCallback(&Plugin::NaClManifestFileDidOpen); + callback_factory_.NewCallback(&Plugin::NaClManifestFileDidOpen); // Will always call the callback on success or failure. CHECK(nexe_downloader_.Open(nmf_resolved_url.AsString(), DOWNLOAD_TO_FILE, @@ -1614,9 +1614,8 @@ bool Plugin::StreamAsFile(const nacl::string& url, FileDownloader* downloader = new FileDownloader(); downloader->Initialize(this); url_downloaders_.insert(downloader); - pp::CompletionCallback open_callback = - callback_factory_.NewRequiredCallback( - &Plugin::UrlDidOpenForStreamAsFile, downloader, callback); + pp::CompletionCallback open_callback = callback_factory_.NewCallback( + &Plugin::UrlDidOpenForStreamAsFile, downloader, callback); // Untrusted loads are always relative to the page's origin. CHECK(url_util_ != NULL); pp::Var resolved_url = @@ -1646,10 +1645,9 @@ void Plugin::XYZZY(const nacl::string& url, pp::VarPrivate js_callback) { UNREFERENCED_PARAMETER(url); UNREFERENCED_PARAMETER(js_callback); - pp::CompletionCallback open_callback = - callback_factory_.NewRequiredCallback(pmem, - reinterpret_cast<plugin::FileDownloader*>(NULL), - js_callback); + pp::CompletionCallback open_callback = callback_factory_.NewCallback(pmem, + reinterpret_cast<plugin::FileDownloader*>(NULL), + js_callback); static_cast<void>(open_callback); } #endif // HACK_FOR_MACOS_HANG_REMOVED diff --git a/ppapi/tests/test_flash.cc b/ppapi/tests/test_flash.cc index debbc49..2657bf0 100644 --- a/ppapi/tests/test_flash.cc +++ b/ppapi/tests/test_flash.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Copyright (c) 2012 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -72,7 +72,7 @@ std::string TestFlash::TestGetProxyForURL() { std::string TestFlash::TestMessageLoop() { pp::CompletionCallback callback = - callback_factory_.NewRequiredCallback(&TestFlash::QuitMessageLoopTask); + callback_factory_.NewCallback(&TestFlash::QuitMessageLoopTask); pp::Module::Get()->core()->CallOnMainThread(0, callback); flash_interface_->RunMessageLoop(instance_->pp_instance()); diff --git a/ppapi/tests/test_flash_message_loop.cc b/ppapi/tests/test_flash_message_loop.cc index 5143fe7..e5b7fe8 100644 --- a/ppapi/tests/test_flash_message_loop.cc +++ b/ppapi/tests/test_flash_message_loop.cc @@ -31,9 +31,8 @@ void TestFlashMessageLoop::RunTests(const std::string& filter) { std::string TestFlashMessageLoop::TestBasics() { message_loop_ = new pp::flash::MessageLoop(instance_); - pp::CompletionCallback callback = - callback_factory_.NewRequiredCallback( - &TestFlashMessageLoop::QuitMessageLoopTask); + pp::CompletionCallback callback = callback_factory_.NewCallback( + &TestFlashMessageLoop::QuitMessageLoopTask); pp::Module::Get()->core()->CallOnMainThread(0, callback); int32_t result = message_loop_->Run(); @@ -48,9 +47,8 @@ std::string TestFlashMessageLoop::TestBasics() { std::string TestFlashMessageLoop::TestRunWithoutQuit() { message_loop_ = new pp::flash::MessageLoop(instance_); - pp::CompletionCallback callback = - callback_factory_.NewRequiredCallback( - &TestFlashMessageLoop::DestroyMessageLoopResourceTask); + pp::CompletionCallback callback = callback_factory_.NewCallback( + &TestFlashMessageLoop::DestroyMessageLoopResourceTask); pp::Module::Get()->core()->CallOnMainThread(0, callback); int32_t result = message_loop_->Run(); diff --git a/ppapi/utility/completion_callback_factory.h b/ppapi/utility/completion_callback_factory.h index 98e15f1..e0b1f37 100644 --- a/ppapi/utility/completion_callback_factory.h +++ b/ppapi/utility/completion_callback_factory.h @@ -1,4 +1,4 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Copyright (c) 2012 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -39,7 +39,7 @@ namespace pp { /// } /// /// void ProcessFile(const FileRef& file) { -/// CompletionCallback cc = factory_.NewRequiredCallback( +/// CompletionCallback cc = factory_.NewCallback( /// &MyHandler::DidOpen); /// int32_t rv = fio_.Open(file, PP_FileOpenFlag_Read, cc); /// CHECK(rv == PP_OK_COMPLETIONPENDING); @@ -147,7 +147,6 @@ class CompletionCallbackFactory { /// NewCallback allocates a new, single-use <code>CompletionCallback</code>. /// The <code>CompletionCallback</code> must be run in order for the memory /// allocated by the methods to be freed. - /// NewCallback() is equivalent to NewRequiredCallback() below. /// /// @param[in] method The method to be invoked upon completion of the /// operation. @@ -159,22 +158,6 @@ class CompletionCallbackFactory { return NewCallbackHelper(Dispatcher0<Method>(method)); } - /// NewRequiredCallback() allocates a new, single-use - /// <code>CompletionCallback</code> that will always run. The - /// <code>CompletionCallback</code> must be run in order for the memory - /// allocated by the methods to be freed. - /// - /// @param[in] method The method to be invoked upon completion of the - /// operation. - /// - /// @return A <code>CompletionCallback</code>. - template <typename Method> - CompletionCallback NewRequiredCallback(Method method) { - CompletionCallback cc = NewCallback(method); - cc.set_flags(cc.flags() & ~PP_COMPLETIONCALLBACK_FLAG_OPTIONAL); - return cc; - } - /// NewOptionalCallback() allocates a new, single-use /// <code>CompletionCallback</code> that might not run if the method /// taking it can complete synchronously. Thus, if after passing the @@ -196,7 +179,6 @@ class CompletionCallbackFactory { /// NewCallback() allocates a new, single-use <code>CompletionCallback</code>. /// The <code>CompletionCallback</code> must be run in order for the memory /// allocated by the methods to be freed. - /// NewCallback() is equivalent to NewRequiredCallback() below. /// /// @param[in] method The method to be invoked upon completion of the /// operation. Method should be of type: @@ -212,26 +194,6 @@ class CompletionCallbackFactory { return NewCallbackHelper(Dispatcher1<Method, A>(method, a)); } - /// NewRequiredCallback() allocates a new, single-use - /// <code>CompletionCallback</code> that will always run. The - /// <code>CompletionCallback</code> must be run in order for the memory - /// allocated by the methods to be freed. - /// - /// @param[in] method The method to be invoked upon completion of the - /// operation. Method should be of type: - /// <code>void (T::*)(int32_t result, const A& a)</code> - /// - /// @param[in] a Passed to <code>method</code> when the completion callback - /// runs. - /// - /// @return A <code>CompletionCallback</code>. - template <typename Method, typename A> - CompletionCallback NewRequiredCallback(Method method, const A& a) { - CompletionCallback cc = NewCallback(method, a); - cc.set_flags(cc.flags() & ~PP_COMPLETIONCALLBACK_FLAG_OPTIONAL); - return cc; - } - /// NewOptionalCallback() allocates a new, single-use /// <code>CompletionCallback</code> that might not run if the method /// taking it can complete synchronously. Thus, if after passing the @@ -258,7 +220,6 @@ class CompletionCallbackFactory { /// <code>CompletionCallback</code>. /// The <code>CompletionCallback</code> must be run in order for the memory /// allocated by the methods to be freed. - /// NewCallback() is equivalent to NewRequiredCallback() below. /// /// @param method The method taking the callback. Method should be of type: /// <code>void (T::*)(int32_t result, const A& a, const B& b)</code> @@ -276,29 +237,6 @@ class CompletionCallbackFactory { return NewCallbackHelper(Dispatcher2<Method, A, B>(method, a, b)); } - /// NewRequiredCallback() allocates a new, single-use - /// <code>CompletionCallback</code> that will always run. The - /// <code>CompletionCallback</code> must be run in order for the memory - /// allocated by the methods to be freed. - /// - /// @param method The method taking the callback. Method should be of type: - /// <code>void (T::*)(int32_t result, const A& a, const B& b)</code> - /// - /// @param[in] a Passed to <code>method</code> when the completion callback - /// runs. - /// - /// @param[in] b Passed to <code>method</code> when the completion callback - /// runs. - /// - /// @return A <code>CompletionCallback</code>. - template <typename Method, typename A, typename B> - CompletionCallback NewRequiredCallback(Method method, const A& a, - const B& b) { - CompletionCallback cc = NewCallback(method, a, b); - cc.set_flags(cc.flags() & ~PP_COMPLETIONCALLBACK_FLAG_OPTIONAL); - return cc; - } - /// NewOptionalCallback() allocates a new, single-use /// <code>CompletionCallback</code> that might not run if the method /// taking it can complete synchronously. Thus, if after passing the @@ -329,7 +267,6 @@ class CompletionCallbackFactory { /// <code>CompletionCallback</code>. /// The <code>CompletionCallback</code> must be run in order for the memory /// allocated by the methods to be freed. - /// NewCallback() is equivalent to NewRequiredCallback() below. /// /// @param method The method taking the callback. Method should be of type: /// <code> @@ -353,34 +290,6 @@ class CompletionCallbackFactory { return NewCallbackHelper(Dispatcher3<Method, A, B, C>(method, a, b, c)); } - /// NewRequiredCallback() allocates a new, single-use - /// <code>CompletionCallback</code> that will always run. The - /// <code>CompletionCallback</code> must be run in order for the memory - /// allocated by the methods to be freed. - /// - /// @param method The method taking the callback. Method should be of type: - /// <code> - /// void (T::*)(int32_t result, const A& a, const B& b, const C& c) - /// </code> - /// - /// @param[in] a Passed to <code>method</code> when the completion callback - /// runs. - /// - /// @param[in] b Passed to <code>method</code> when the completion callback - /// runs. - /// - /// @param[in] c Passed to <code>method</code> when the completion callback - /// runs. - /// - /// @return A <code>CompletionCallback</code>. - template <typename Method, typename A, typename B, typename C> - CompletionCallback NewRequiredCallback(Method method, const A& a, - const B& b, const C& c) { - CompletionCallback cc = NewCallback(method, a, b, c); - cc.set_flags(cc.flags() & ~PP_COMPLETIONCALLBACK_FLAG_OPTIONAL); - return cc; - } - /// NewOptionalCallback() allocates a new, single-use /// <code>CompletionCallback</code> that might not run if the method /// taking it can complete synchronously. Thus, if after passing the |