summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorbrettw@chromium.org <brettw@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-09-16 20:10:55 +0000
committerbrettw@chromium.org <brettw@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-09-16 20:10:55 +0000
commite655a951994dcafb7203d6824b90dfef6e445dca (patch)
tree18b9126b21efd9e63f74149263753031ec393ae8
parentc96312d46205ea82764aba6255ecbb8dd5f57d11 (diff)
downloadchromium_src-e655a951994dcafb7203d6824b90dfef6e445dca.zip
chromium_src-e655a951994dcafb7203d6824b90dfef6e445dca.tar.gz
chromium_src-e655a951994dcafb7203d6824b90dfef6e445dca.tar.bz2
Add a new error code for a null callback on the main thread.
Convert the NaCl and ChromeIPC proxies to use the new value. Review URL: http://codereview.chromium.org/7885014 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@101556 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--ppapi/api/pp_errors.idl32
-rw-r--r--ppapi/c/pp_errors.h32
-rw-r--r--ppapi/native_client/src/shared/ppapi_proxy/plugin_nacl_file.cc4
-rw-r--r--ppapi/native_client/src/shared/ppapi_proxy/plugin_ppb_file_io.cc14
-rw-r--r--ppapi/native_client/src/shared/ppapi_proxy/plugin_ppb_file_system.cc4
-rw-r--r--ppapi/native_client/src/shared/ppapi_proxy/plugin_ppb_graphics_2d.cc2
-rw-r--r--ppapi/native_client/src/shared/ppapi_proxy/plugin_ppb_graphics_3d.cc2
-rw-r--r--ppapi/native_client/src/shared/ppapi_proxy/plugin_ppb_url_loader.cc8
-rw-r--r--ppapi/native_client/tests/ppapi_browser/ppb_file_system/ppapi_ppb_file_system.cc2
-rw-r--r--ppapi/native_client/tests/ppapi_browser/ppb_graphics2d/ppapi_ppb_graphics2d.cc2
-rw-r--r--ppapi/native_client/tests/ppapi_browser/ppb_url_loader/ppapi_ppb_url_loader.cc2
-rw-r--r--ppapi/proxy/ppb_broker_proxy.cc2
-rw-r--r--ppapi/proxy/ppb_file_chooser_proxy.cc3
-rw-r--r--ppapi/proxy/ppb_flash_tcp_socket_proxy.cc14
-rw-r--r--ppapi/proxy/ppb_graphics_2d_proxy.cc2
-rw-r--r--ppapi/proxy/ppb_surface_3d_proxy.cc2
-rw-r--r--webkit/plugins/ppapi/plugin_module.cc10
-rw-r--r--webkit/plugins/ppapi/ppapi_plugin_instance.cc2
-rw-r--r--webkit/plugins/ppapi/ppb_broker_impl.cc2
-rw-r--r--webkit/plugins/ppapi/ppb_directory_reader_impl.cc2
-rw-r--r--webkit/plugins/ppapi/ppb_file_chooser_impl.cc2
-rw-r--r--webkit/plugins/ppapi/ppb_file_io_impl.cc6
-rw-r--r--webkit/plugins/ppapi/ppb_file_ref_impl.cc10
-rw-r--r--webkit/plugins/ppapi/ppb_file_system_impl.cc3
-rw-r--r--webkit/plugins/ppapi/ppb_flash_menu_impl.cc6
-rw-r--r--webkit/plugins/ppapi/ppb_flash_net_connector_impl.cc12
-rw-r--r--webkit/plugins/ppapi/ppb_graphics_2d_impl.cc8
-rw-r--r--webkit/plugins/ppapi/ppb_surface_3d_impl.cc2
-rw-r--r--webkit/plugins/ppapi/ppb_transport_impl.cc8
-rw-r--r--webkit/plugins/ppapi/ppb_url_loader_impl.cc2
-rw-r--r--webkit/plugins/ppapi/ppb_video_decoder_impl.cc9
31 files changed, 147 insertions, 64 deletions
diff --git a/ppapi/api/pp_errors.idl b/ppapi/api/pp_errors.idl
index 950b77b..bd49081 100644
--- a/ppapi/api/pp_errors.idl
+++ b/ppapi/api/pp_errors.idl
@@ -9,7 +9,10 @@
/**
* This enumeration contains enumerators of all PPAPI error codes.
- * Errors are negative valued.
+ *
+ * Errors are negative valued. Callers should treat all negative values as a
+ * failure, even if it's not in the list, since the possible errors are likely
+ * to expand and change over time.
*/
[unnamed] enum PP_Error {
/**
@@ -26,11 +29,20 @@
*/
PP_OK_COMPLETIONPENDING = -1,
- /** This value indicates failure for unspecified reasons. */
+ /**This value indicates failure for unspecified reasons. */
PP_ERROR_FAILED = -2,
+
/**
* This value indicates failure due to an asynchronous operation being
- * interrupted, typically as a result of user action.
+ * interrupted. The most common cause of this error code is destroying a
+ * resource that still has a callback pending. All callbacks are guaranteed
+ * to execute, so any callbacks pending on a destroyed resource will be
+ * issued with PP_ERROR_ABORTED.
+ *
+ * If you get an aborted notification that you aren't expecting, check to
+ * make sure that the resource you're using is still in scope. A common
+ * mistake is to create a resource on the stack, which will destroy the
+ * resource as soon as the function returns.
*/
PP_ERROR_ABORTED = -3,
@@ -67,6 +79,20 @@
*/
PP_ERROR_NOTSUPPORTED = -12,
+ /**
+ * Returned if you try to use a null completion callback to "block until
+ * complete" on the main thread. Blocking the main thread is not permitted
+ * to keep the browser responsive (otherwise, you may not be able to handle
+ * input events, and there are reentrancy and deadlock issues).
+ *
+ * The goal is to provide blocking calls from background threads, but PPAPI
+ * calls on background threads are not currently supported. Until this
+ * support is complete, you must either do asynchronous operations on the
+ * main thread, or provide an adaptor for a blocking background thread to
+ * execute the operaitions on the main thread.
+ */
+ PP_ERROR_BLOCKS_MAIN_THREAD = -13,
+
PP_ERROR_FILENOTFOUND = -20,
/** This value indicates failure due to a file that already exists. */
PP_ERROR_FILEEXISTS = -21,
diff --git a/ppapi/c/pp_errors.h b/ppapi/c/pp_errors.h
index 1394aa7..724ff9b 100644
--- a/ppapi/c/pp_errors.h
+++ b/ppapi/c/pp_errors.h
@@ -3,7 +3,7 @@
* found in the LICENSE file.
*/
-/* From pp_errors.idl modified Sat Jul 16 16:50:26 2011. */
+/* From pp_errors.idl modified Wed Sep 14 08:34:03 2011. */
#ifndef PPAPI_C_PP_ERRORS_H_
#define PPAPI_C_PP_ERRORS_H_
@@ -22,7 +22,10 @@
*/
/**
* This enumeration contains enumerators of all PPAPI error codes.
- * Errors are negative valued.
+ *
+ * Errors are negative valued. Callers should treat all negative values as a
+ * failure, even if it's not in the list, since the possible errors are likely
+ * to expand and change over time.
*/
enum {
/**
@@ -38,11 +41,19 @@ enum {
* available.
*/
PP_OK_COMPLETIONPENDING = -1,
- /** This value indicates failure for unspecified reasons. */
+ /**This value indicates failure for unspecified reasons. */
PP_ERROR_FAILED = -2,
/**
* This value indicates failure due to an asynchronous operation being
- * interrupted, typically as a result of user action.
+ * interrupted. The most common cause of this error code is destroying a
+ * resource that still has a callback pending. All callbacks are guaranteed
+ * to execute, so any callbacks pending on a destroyed resource will be
+ * issued with PP_ERROR_ABORTED.
+ *
+ * If you get an aborted notification that you aren't expecting, check to
+ * make sure that the resource you're using is still in scope. A common
+ * mistake is to create a resource on the stack, which will destroy the
+ * resource as soon as the function returns.
*/
PP_ERROR_ABORTED = -3,
/** This value indicates failure due to an invalid argument. */
@@ -69,6 +80,19 @@ enum {
* The requested command is not supported by the browser.
*/
PP_ERROR_NOTSUPPORTED = -12,
+ /**
+ * Returned if you try to use a null completion callback to "block until
+ * complete" on the main thread. Blocking the main thread is not permitted
+ * to keep the browser responsive (otherwise, you may not be able to handle
+ * input events, and there are reentrancy and deadlock issues).
+ *
+ * The goal is to provide blocking calls from background threads, but PPAPI
+ * calls on background threads are not currently supported. Until this
+ * support is complete, you must either do asynchronous operations on the
+ * main thread, or provide an adaptor for a blocking background thread to
+ * execute the operaitions on the main thread.
+ */
+ PP_ERROR_BLOCKS_MAIN_THREAD = -13,
PP_ERROR_FILENOTFOUND = -20,
/** This value indicates failure due to a file that already exists. */
PP_ERROR_FILEEXISTS = -21,
diff --git a/ppapi/native_client/src/shared/ppapi_proxy/plugin_nacl_file.cc b/ppapi/native_client/src/shared/ppapi_proxy/plugin_nacl_file.cc
index 1099ec1..4c8758c 100644
--- a/ppapi/native_client/src/shared/ppapi_proxy/plugin_nacl_file.cc
+++ b/ppapi/native_client/src/shared/ppapi_proxy/plugin_nacl_file.cc
@@ -24,10 +24,10 @@ int32_t StreamAsFile(PP_Instance instance,
int32_t callback_id =
CompletionCallbackTable::Get()->AddCallback(callback);
if (callback_id == 0)
- return PP_ERROR_BADARGUMENT;
+ return PP_ERROR_BLOCKS_MAIN_THREAD;
NaClSrpcError srpc_result = NaClFileRpcClient::StreamAsFile(
- GetMainSrpcChannel(), instance, const_cast<char*>(url), callback_id);
+ GetMainSrpcChannel(), instance, const_cast<char*>(url), callback_id);
DebugPrintf("NaClFile::StreamAsFile: %s\n", NaClSrpcErrorString(srpc_result));
if (srpc_result == NACL_SRPC_RESULT_OK)
diff --git a/ppapi/native_client/src/shared/ppapi_proxy/plugin_ppb_file_io.cc b/ppapi/native_client/src/shared/ppapi_proxy/plugin_ppb_file_io.cc
index 848b1ee..9f4851e 100644
--- a/ppapi/native_client/src/shared/ppapi_proxy/plugin_ppb_file_io.cc
+++ b/ppapi/native_client/src/shared/ppapi_proxy/plugin_ppb_file_io.cc
@@ -66,7 +66,7 @@ int32_t Open(PP_Resource file_io,
int32_t callback_id =
CompletionCallbackTable::Get()->AddCallback(callback);
if (callback_id == 0) // Just like Chrome, for now disallow blocking calls.
- return PP_ERROR_BADARGUMENT;
+ return PP_ERROR_BLOCKS_MAIN_THREAD;
int32_t pp_error;
NaClSrpcError srpc_result =
@@ -90,7 +90,7 @@ int32_t Query(PP_Resource file_io,
struct PP_CompletionCallback callback) {
DebugPrintf("PPB_FileIO::Query: file_io=%"NACL_PRIu32"\n", file_io);
if (callback.func == 0) // Just like Chrome, for now disallow blocking calls.
- return PP_ERROR_BADARGUMENT;
+ return PP_ERROR_BLOCKS_MAIN_THREAD;
int32_t callback_id = CompletionCallbackTable::Get()->AddCallback(
callback, reinterpret_cast<char*>(info));
@@ -130,7 +130,7 @@ int32_t Touch(PP_Resource file_io,
int32_t callback_id =
CompletionCallbackTable::Get()->AddCallback(callback);
if (callback_id == 0) // Just like Chrome, for now disallow blocking calls.
- return PP_ERROR_BADARGUMENT;
+ return PP_ERROR_BLOCKS_MAIN_THREAD;
int32_t pp_error = PP_ERROR_FAILED;
@@ -165,7 +165,7 @@ int32_t Read(PP_Resource file_io,
int32_t callback_id =
CompletionCallbackTable::Get()->AddCallback(callback, buffer);
if (callback_id == 0) // Just like Chrome, for now disallow blocking calls.
- return PP_ERROR_BADARGUMENT;
+ return PP_ERROR_BLOCKS_MAIN_THREAD;
int32_t pp_error_or_bytes;
NaClSrpcError srpc_result =
@@ -202,7 +202,7 @@ int32_t Write(PP_Resource file_io,
int32_t callback_id =
CompletionCallbackTable::Get()->AddCallback(callback);
if (callback_id == 0) // Just like Chrome, for now disallow blocking calls.
- return PP_ERROR_BADARGUMENT;
+ return PP_ERROR_BLOCKS_MAIN_THREAD;
int32_t pp_error_or_bytes = PP_ERROR_FAILED;
NaClSrpcError srpc_result = PpbFileIORpcClient::PPB_FileIO_Write(
@@ -231,7 +231,7 @@ int32_t SetLength(PP_Resource file_io,
int32_t callback_id =
CompletionCallbackTable::Get()->AddCallback(callback);
if (callback_id == 0) // Just like Chrome, for now disallow blocking calls.
- return PP_ERROR_BADARGUMENT;
+ return PP_ERROR_BLOCKS_MAIN_THREAD;
int32_t pp_error = PP_ERROR_FAILED;
NaClSrpcError srpc_result = PpbFileIORpcClient::PPB_FileIO_SetLength(
@@ -256,7 +256,7 @@ int32_t Flush(PP_Resource file_io,
int32_t callback_id =
CompletionCallbackTable::Get()->AddCallback(callback);
if (callback_id == 0) // Just like Chrome, for now disallow blocking calls.
- return PP_ERROR_BADARGUMENT;
+ return PP_ERROR_BLOCKS_MAIN_THREAD;
int32_t pp_error = PP_ERROR_FAILED;
NaClSrpcError srpc_result = PpbFileIORpcClient::PPB_FileIO_Flush(
diff --git a/ppapi/native_client/src/shared/ppapi_proxy/plugin_ppb_file_system.cc b/ppapi/native_client/src/shared/ppapi_proxy/plugin_ppb_file_system.cc
index 64ebaf5..fb4fa40 100644
--- a/ppapi/native_client/src/shared/ppapi_proxy/plugin_ppb_file_system.cc
+++ b/ppapi/native_client/src/shared/ppapi_proxy/plugin_ppb_file_system.cc
@@ -57,8 +57,8 @@ int32_t Open(PP_Resource file_system,
DebugPrintf("PPB_FileSystem::Open: file_system=%"NACL_PRIu32"\n",
file_system);
int32_t callback_id = CompletionCallbackTable::Get()->AddCallback(callback);
- if (callback_id == 0)
- return PP_ERROR_BADARGUMENT;
+ if (callback_id == 0) // Just like Chrome, for now disallow blocking calls.
+ return PP_ERROR_BLOCKS_MAIN_THREAD;
int32_t pp_error;
NaClSrpcError srpc_result =
diff --git a/ppapi/native_client/src/shared/ppapi_proxy/plugin_ppb_graphics_2d.cc b/ppapi/native_client/src/shared/ppapi_proxy/plugin_ppb_graphics_2d.cc
index 3bab6d1..2bf2797 100644
--- a/ppapi/native_client/src/shared/ppapi_proxy/plugin_ppb_graphics_2d.cc
+++ b/ppapi/native_client/src/shared/ppapi_proxy/plugin_ppb_graphics_2d.cc
@@ -153,7 +153,7 @@ int32_t Flush(PP_Resource graphics_2d,
int32_t callback_id =
CompletionCallbackTable::Get()->AddCallback(callback);
if (callback_id == 0) // Just like Chrome, for now disallow blocking calls.
- return PP_ERROR_BADARGUMENT;
+ return PP_ERROR_BLOCKS_MAIN_THREAD;
int32_t pp_error;
NaClSrpcError srpc_result =
diff --git a/ppapi/native_client/src/shared/ppapi_proxy/plugin_ppb_graphics_3d.cc b/ppapi/native_client/src/shared/ppapi_proxy/plugin_ppb_graphics_3d.cc
index 974563a..736eee2 100644
--- a/ppapi/native_client/src/shared/ppapi_proxy/plugin_ppb_graphics_3d.cc
+++ b/ppapi/native_client/src/shared/ppapi_proxy/plugin_ppb_graphics_3d.cc
@@ -238,7 +238,7 @@ int32_t PluginGraphics3D::SwapBuffers(PP_Resource graphics3d_id,
int32_t callback_id = CompletionCallbackTable::Get()->AddCallback(callback);
if (callback_id == 0) // Just like Chrome, for now disallow blocking calls.
- return PP_ERROR_BADARGUMENT;
+ return PP_ERROR_BLOCKS_MAIN_THREAD;
int32_t pp_error;
NaClSrpcError retval =
diff --git a/ppapi/native_client/src/shared/ppapi_proxy/plugin_ppb_url_loader.cc b/ppapi/native_client/src/shared/ppapi_proxy/plugin_ppb_url_loader.cc
index 2118e90..be7a639 100644
--- a/ppapi/native_client/src/shared/ppapi_proxy/plugin_ppb_url_loader.cc
+++ b/ppapi/native_client/src/shared/ppapi_proxy/plugin_ppb_url_loader.cc
@@ -60,7 +60,7 @@ int32_t Open(PP_Resource loader,
int32_t callback_id =
CompletionCallbackTable::Get()->AddCallback(callback);
if (callback_id == 0) // Just like Chrome, for now disallow blocking calls.
- return PP_ERROR_BADARGUMENT;
+ return PP_ERROR_BLOCKS_MAIN_THREAD;
int32_t pp_error;
NaClSrpcError srpc_result =
@@ -80,7 +80,7 @@ int32_t FollowRedirect(PP_Resource loader,
int32_t callback_id =
CompletionCallbackTable::Get()->AddCallback(callback);
if (callback_id == 0) // Just like Chrome, for now disallow blocking calls.
- return PP_ERROR_BADARGUMENT;
+ return PP_ERROR_BLOCKS_MAIN_THREAD;
int32_t pp_error;
NaClSrpcError srpc_result =
@@ -167,7 +167,7 @@ int32_t ReadResponseBody(PP_Resource loader,
int32_t callback_id =
CompletionCallbackTable::Get()->AddCallback(callback, buffer);
if (callback_id == 0) // Just like Chrome, for now disallow blocking calls.
- return PP_ERROR_BADARGUMENT;
+ return PP_ERROR_BLOCKS_MAIN_THREAD;
int32_t pp_error_or_bytes;
NaClSrpcError srpc_result =
@@ -195,7 +195,7 @@ int32_t FinishStreamingToFile(PP_Resource loader,
int32_t callback_id =
CompletionCallbackTable::Get()->AddCallback(callback);
if (callback_id == 0) // Just like Chrome, for now disallow blocking calls.
- return PP_ERROR_BADARGUMENT;
+ return PP_ERROR_BLOCKS_MAIN_THREAD;
int32_t pp_error;
NaClSrpcError srpc_result =
diff --git a/ppapi/native_client/tests/ppapi_browser/ppb_file_system/ppapi_ppb_file_system.cc b/ppapi/native_client/tests/ppapi_browser/ppb_file_system/ppapi_ppb_file_system.cc
index 5d17cde..ebf8128 100644
--- a/ppapi/native_client/tests/ppapi_browser/ppb_file_system/ppapi_ppb_file_system.cc
+++ b/ppapi/native_client/tests/ppapi_browser/ppb_file_system/ppapi_ppb_file_system.cc
@@ -134,7 +134,7 @@ void TestOpen() {
pp_error = ppb_file_system->Open(file_system, kSize,
PP_BlockUntilComplete());
ppb_core->ReleaseResource(file_system);
- EXPECT(pp_error == PP_ERROR_BADARGUMENT);
+ EXPECT(pp_error == PP_ERROR_BLOCKS_MAIN_THREAD);
#endif
// Test success for asynchronous open.
diff --git a/ppapi/native_client/tests/ppapi_browser/ppb_graphics2d/ppapi_ppb_graphics2d.cc b/ppapi/native_client/tests/ppapi_browser/ppb_graphics2d/ppapi_ppb_graphics2d.cc
index cedeead..c8b4007 100644
--- a/ppapi/native_client/tests/ppapi_browser/ppb_graphics2d/ppapi_ppb_graphics2d.cc
+++ b/ppapi/native_client/tests/ppapi_browser/ppb_graphics2d/ppapi_ppb_graphics2d.cc
@@ -486,7 +486,7 @@ void TestFlush() {
// Invalid args -> PP_ERROR_BAD..., no callback.
EXPECT(PP_ERROR_BADRESOURCE == PPBGraphics2D()->Flush(kInvalidResource, cc));
EXPECT(PP_ERROR_BADRESOURCE == PPBGraphics2D()->Flush(kNotAResource, cc));
- EXPECT(PP_ERROR_BADARGUMENT ==
+ EXPECT(PP_ERROR_BLOCKS_MAIN_THREAD ==
PPBGraphics2D()->Flush(graphics2d, PP_BlockUntilComplete()));
// Valid args -> PP_OK_COMPLETIONPENDING, expect callback.
diff --git a/ppapi/native_client/tests/ppapi_browser/ppb_url_loader/ppapi_ppb_url_loader.cc b/ppapi/native_client/tests/ppapi_browser/ppb_url_loader/ppapi_ppb_url_loader.cc
index 1c5d30f..70d4d93 100644
--- a/ppapi/native_client/tests/ppapi_browser/ppb_url_loader/ppapi_ppb_url_loader.cc
+++ b/ppapi/native_client/tests/ppapi_browser/ppb_url_loader/ppapi_ppb_url_loader.cc
@@ -407,7 +407,7 @@ void TestOpenSimple() {
loader = PPBURLLoader()->Create(pp_instance());
// We are on the main thread, performing a sync call should fail
rv = PPBURLLoader()->Open(loader, request, PP_BlockUntilComplete());
- EXPECT(PP_ERROR_BADARGUMENT == rv);
+ EXPECT(PP_ERROR_BLOCKS_MAIN_THREAD == rv);
PPBCore()->ReleaseResource(loader);
LOG_TO_BROWSER("open (asynchronous) normal");
diff --git a/ppapi/proxy/ppb_broker_proxy.cc b/ppapi/proxy/ppb_broker_proxy.cc
index ff06759..f584cf0 100644
--- a/ppapi/proxy/ppb_broker_proxy.cc
+++ b/ppapi/proxy/ppb_broker_proxy.cc
@@ -98,7 +98,7 @@ PPB_Broker_API* Broker::AsPPB_Broker_API() {
int32_t Broker::Connect(PP_CompletionCallback connect_callback) {
if (!connect_callback.func) {
// Synchronous calls are not supported.
- return PP_ERROR_BADARGUMENT;
+ return PP_ERROR_BLOCKS_MAIN_THREAD;
}
if (current_connect_callback_.func)
diff --git a/ppapi/proxy/ppb_file_chooser_proxy.cc b/ppapi/proxy/ppb_file_chooser_proxy.cc
index 73f7a6a..c74ba4f 100644
--- a/ppapi/proxy/ppb_file_chooser_proxy.cc
+++ b/ppapi/proxy/ppb_file_chooser_proxy.cc
@@ -83,6 +83,9 @@ PPB_FileChooser_API* FileChooser::AsPPB_FileChooser_API() {
}
int32_t FileChooser::Show(const PP_CompletionCallback& callback) {
+ if (!callback.func)
+ return PP_ERROR_BLOCKS_MAIN_THREAD;
+
if (current_show_callback_.func)
return PP_ERROR_INPROGRESS; // Can't show more than once.
diff --git a/ppapi/proxy/ppb_flash_tcp_socket_proxy.cc b/ppapi/proxy/ppb_flash_tcp_socket_proxy.cc
index 7ff2ce3..020cf28 100644
--- a/ppapi/proxy/ppb_flash_tcp_socket_proxy.cc
+++ b/ppapi/proxy/ppb_flash_tcp_socket_proxy.cc
@@ -209,8 +209,10 @@ PP_Bool FlashTCPSocket::GetRemoteAddress(PP_Flash_NetAddress* remote_addr) {
int32_t FlashTCPSocket::SSLHandshake(const char* server_name,
uint16_t server_port,
PP_CompletionCallback callback) {
- if (!server_name || !callback.func)
+ if (!server_name)
return PP_ERROR_BADARGUMENT;
+ if (!callback.func)
+ return PP_ERROR_BLOCKS_MAIN_THREAD;
if (connection_state_ != CONNECTED)
return PP_ERROR_FAILED;
@@ -230,8 +232,10 @@ int32_t FlashTCPSocket::SSLHandshake(const char* server_name,
int32_t FlashTCPSocket::Read(char* buffer,
int32_t bytes_to_read,
PP_CompletionCallback callback) {
- if (!buffer || bytes_to_read <= 0 || !callback.func)
+ if (!buffer || bytes_to_read <= 0)
return PP_ERROR_BADARGUMENT;
+ if (!callback.func)
+ return PP_ERROR_BLOCKS_MAIN_THREAD;
if (!IsConnected())
return PP_ERROR_FAILED;
@@ -251,8 +255,10 @@ int32_t FlashTCPSocket::Read(char* buffer,
int32_t FlashTCPSocket::Write(const char* buffer,
int32_t bytes_to_write,
PP_CompletionCallback callback) {
- if (!buffer || bytes_to_write <= 0 || !callback.func)
+ if (!buffer || bytes_to_write <= 0)
return PP_ERROR_BADARGUMENT;
+ if (!callback.func)
+ return PP_ERROR_BLOCKS_MAIN_THREAD;
if (!IsConnected())
return PP_ERROR_FAILED;
@@ -365,7 +371,7 @@ int32_t FlashTCPSocket::ConnectWithMessage(IPC::Message* msg,
PP_CompletionCallback callback) {
scoped_ptr<IPC::Message> msg_deletor(msg);
if (!callback.func)
- return PP_ERROR_BADARGUMENT;
+ return PP_ERROR_BLOCKS_MAIN_THREAD;
if (connection_state_ != BEFORE_CONNECT)
return PP_ERROR_FAILED;
if (connect_callback_.func)
diff --git a/ppapi/proxy/ppb_graphics_2d_proxy.cc b/ppapi/proxy/ppb_graphics_2d_proxy.cc
index 232e1fe..dcf8d26 100644
--- a/ppapi/proxy/ppb_graphics_2d_proxy.cc
+++ b/ppapi/proxy/ppb_graphics_2d_proxy.cc
@@ -124,7 +124,7 @@ int32_t Graphics2D::Flush(PP_CompletionCallback callback) {
// For now, disallow blocking calls. We'll need to add support for other
// threads to this later.
if (!callback.func)
- return PP_ERROR_BADARGUMENT;
+ return PP_ERROR_BLOCKS_MAIN_THREAD;
if (current_flush_callback_.func)
return PP_ERROR_INPROGRESS; // Can't have >1 flush pending.
diff --git a/ppapi/proxy/ppb_surface_3d_proxy.cc b/ppapi/proxy/ppb_surface_3d_proxy.cc
index 70809da..c46f01b 100644
--- a/ppapi/proxy/ppb_surface_3d_proxy.cc
+++ b/ppapi/proxy/ppb_surface_3d_proxy.cc
@@ -62,7 +62,7 @@ int32_t Surface3D::SwapBuffers(PP_CompletionCallback callback) {
// For now, disallow blocking calls. We'll need to add support for other
// threads to this later.
if (!callback.func)
- return PP_ERROR_BADARGUMENT;
+ return PP_ERROR_BLOCKS_MAIN_THREAD;
if (is_flush_pending())
return PP_ERROR_INPROGRESS; // Can't have >1 flush pending.
diff --git a/webkit/plugins/ppapi/plugin_module.cc b/webkit/plugins/ppapi/plugin_module.cc
index 785132e..a5dc215 100644
--- a/webkit/plugins/ppapi/plugin_module.cc
+++ b/webkit/plugins/ppapi/plugin_module.cc
@@ -157,10 +157,12 @@ PP_TimeTicks GetTickTime() {
void CallOnMainThread(int delay_in_msec,
PP_CompletionCallback callback,
int32_t result) {
- GetMainThreadMessageLoop()->PostDelayedTask(
- FROM_HERE,
- NewRunnableFunction(callback.func, callback.user_data, result),
- delay_in_msec);
+ if (callback.func) {
+ GetMainThreadMessageLoop()->PostDelayedTask(
+ FROM_HERE,
+ NewRunnableFunction(callback.func, callback.user_data, result),
+ delay_in_msec);
+ }
}
PP_Bool IsMainThread() {
diff --git a/webkit/plugins/ppapi/ppapi_plugin_instance.cc b/webkit/plugins/ppapi/ppapi_plugin_instance.cc
index 0425cd4..2e099c0 100644
--- a/webkit/plugins/ppapi/ppapi_plugin_instance.cc
+++ b/webkit/plugins/ppapi/ppapi_plugin_instance.cc
@@ -1579,7 +1579,7 @@ int32_t PluginInstance::LockMouse(PP_Instance instance,
PP_CompletionCallback callback) {
if (!callback.func) {
// Don't support synchronous call.
- return PP_ERROR_BADARGUMENT;
+ return PP_ERROR_BLOCKS_MAIN_THREAD;
}
if (lock_mouse_callback_.func)
return PP_ERROR_INPROGRESS;
diff --git a/webkit/plugins/ppapi/ppb_broker_impl.cc b/webkit/plugins/ppapi/ppb_broker_impl.cc
index 8bf2e79..7d897c7 100644
--- a/webkit/plugins/ppapi/ppb_broker_impl.cc
+++ b/webkit/plugins/ppapi/ppb_broker_impl.cc
@@ -56,7 +56,7 @@ PPB_Broker_API* PPB_Broker_Impl::AsPPB_Broker_API() {
int32_t PPB_Broker_Impl::Connect(PP_CompletionCallback connect_callback) {
if (!connect_callback.func) {
// Synchronous calls are not supported.
- return PP_ERROR_BADARGUMENT;
+ return PP_ERROR_BLOCKS_MAIN_THREAD;
}
// TODO(ddorwin): Return PP_ERROR_FAILED if plugin is in-process.
diff --git a/webkit/plugins/ppapi/ppb_directory_reader_impl.cc b/webkit/plugins/ppapi/ppb_directory_reader_impl.cc
index 36428d8..da7112b 100644
--- a/webkit/plugins/ppapi/ppb_directory_reader_impl.cc
+++ b/webkit/plugins/ppapi/ppb_directory_reader_impl.cc
@@ -79,6 +79,8 @@ PPB_DirectoryReader_API* PPB_DirectoryReader_Impl::AsPPB_DirectoryReader_API() {
int32_t PPB_DirectoryReader_Impl::GetNextEntry(
PP_DirectoryEntry_Dev* entry,
PP_CompletionCallback callback) {
+ if (!callback.func)
+ return PP_ERROR_BLOCKS_MAIN_THREAD;
if (directory_ref_->GetFileSystemType() == PP_FILESYSTEMTYPE_EXTERNAL)
return PP_ERROR_FAILED;
diff --git a/webkit/plugins/ppapi/ppb_file_chooser_impl.cc b/webkit/plugins/ppapi/ppb_file_chooser_impl.cc
index b2acadc..f7904da 100644
--- a/webkit/plugins/ppapi/ppb_file_chooser_impl.cc
+++ b/webkit/plugins/ppapi/ppb_file_chooser_impl.cc
@@ -120,7 +120,7 @@ int32_t PPB_FileChooser_Impl::ValidateCallback(
const PP_CompletionCallback& callback) {
// We only support non-blocking calls.
if (!callback.func)
- return PP_ERROR_BADARGUMENT;
+ return PP_ERROR_BLOCKS_MAIN_THREAD;
if (callback_.get() && !callback_->completed())
return PP_ERROR_INPROGRESS;
diff --git a/webkit/plugins/ppapi/ppb_file_io_impl.cc b/webkit/plugins/ppapi/ppb_file_io_impl.cc
index faa0870..b074596 100644
--- a/webkit/plugins/ppapi/ppb_file_io_impl.cc
+++ b/webkit/plugins/ppapi/ppb_file_io_impl.cc
@@ -315,10 +315,8 @@ int32_t PPB_FileIO_Impl::CommonCallValidation(bool should_be_open,
OperationType new_op,
PP_CompletionCallback callback) {
// Only asynchronous operation is supported.
- if (!callback.func) {
- NOTIMPLEMENTED();
- return PP_ERROR_BADARGUMENT;
- }
+ if (!callback.func)
+ return PP_ERROR_BLOCKS_MAIN_THREAD;
if (should_be_open) {
if (file_ == base::kInvalidPlatformFileValue)
diff --git a/webkit/plugins/ppapi/ppb_file_ref_impl.cc b/webkit/plugins/ppapi/ppb_file_ref_impl.cc
index c196f15..7c43ba4 100644
--- a/webkit/plugins/ppapi/ppb_file_ref_impl.cc
+++ b/webkit/plugins/ppapi/ppb_file_ref_impl.cc
@@ -162,6 +162,8 @@ PP_Resource PPB_FileRef_Impl::GetParent() {
int32_t PPB_FileRef_Impl::MakeDirectory(PP_Bool make_ancestors,
PP_CompletionCallback callback) {
+ if (!callback.func)
+ return PP_ERROR_BLOCKS_MAIN_THREAD;
if (!IsValidNonExternalFileSystem())
return PP_ERROR_NOACCESS;
@@ -179,8 +181,11 @@ int32_t PPB_FileRef_Impl::MakeDirectory(PP_Bool make_ancestors,
int32_t PPB_FileRef_Impl::Touch(PP_Time last_access_time,
PP_Time last_modified_time,
PP_CompletionCallback callback) {
+ if (!callback.func)
+ return PP_ERROR_BLOCKS_MAIN_THREAD;
if (!IsValidNonExternalFileSystem())
return PP_ERROR_NOACCESS;
+
PluginInstance* plugin_instance = ResourceHelper::GetPluginInstance(this);
if (!plugin_instance)
return PP_ERROR_FAILED;
@@ -195,8 +200,11 @@ int32_t PPB_FileRef_Impl::Touch(PP_Time last_access_time,
}
int32_t PPB_FileRef_Impl::Delete(PP_CompletionCallback callback) {
+ if (!callback.func)
+ return PP_ERROR_BLOCKS_MAIN_THREAD;
if (!IsValidNonExternalFileSystem())
return PP_ERROR_NOACCESS;
+
PluginInstance* plugin_instance = ResourceHelper::GetPluginInstance(this);
if (!plugin_instance)
return PP_ERROR_FAILED;
@@ -210,6 +218,8 @@ int32_t PPB_FileRef_Impl::Delete(PP_CompletionCallback callback) {
int32_t PPB_FileRef_Impl::Rename(PP_Resource new_pp_file_ref,
PP_CompletionCallback callback) {
+ if (!callback.func)
+ return PP_ERROR_BLOCKS_MAIN_THREAD;
EnterResourceNoLock<PPB_FileRef_API> enter(new_pp_file_ref, true);
if (enter.failed())
return PP_ERROR_BADRESOURCE;
diff --git a/webkit/plugins/ppapi/ppb_file_system_impl.cc b/webkit/plugins/ppapi/ppb_file_system_impl.cc
index ac9f900..a63e954 100644
--- a/webkit/plugins/ppapi/ppb_file_system_impl.cc
+++ b/webkit/plugins/ppapi/ppb_file_system_impl.cc
@@ -53,6 +53,9 @@ PPB_FileSystem_API* PPB_FileSystem_Impl::AsPPB_FileSystem_API() {
int32_t PPB_FileSystem_Impl::Open(int64_t expected_size,
PP_CompletionCallback callback) {
+ if (!callback.func)
+ return PP_ERROR_BLOCKS_MAIN_THREAD;
+
// Should not allow multiple opens.
if (called_open_)
return PP_ERROR_INPROGRESS;
diff --git a/webkit/plugins/ppapi/ppb_flash_menu_impl.cc b/webkit/plugins/ppapi/ppb_flash_menu_impl.cc
index c82e362..895aa4d 100644
--- a/webkit/plugins/ppapi/ppb_flash_menu_impl.cc
+++ b/webkit/plugins/ppapi/ppb_flash_menu_impl.cc
@@ -135,10 +135,8 @@ int32_t PPB_Flash_Menu_Impl::Show(const PP_Point* location,
if (!location)
return PP_ERROR_BADARGUMENT;
- if (!callback.func) {
- NOTIMPLEMENTED();
- return PP_ERROR_BADARGUMENT;
- }
+ if (!callback.func)
+ return PP_ERROR_BLOCKS_MAIN_THREAD;
if (callback_.get() && !callback_->completed())
return PP_ERROR_INPROGRESS;
diff --git a/webkit/plugins/ppapi/ppb_flash_net_connector_impl.cc b/webkit/plugins/ppapi/ppb_flash_net_connector_impl.cc
index 5b85ec1..1adbf48 100644
--- a/webkit/plugins/ppapi/ppb_flash_net_connector_impl.cc
+++ b/webkit/plugins/ppapi/ppb_flash_net_connector_impl.cc
@@ -43,10 +43,8 @@ int32_t PPB_Flash_NetConnector_Impl::ConnectTcp(
if (!socket_out)
return PP_ERROR_BADARGUMENT;
- if (!callback.func) {
- NOTIMPLEMENTED();
- return PP_ERROR_BADARGUMENT;
- }
+ if (!callback.func)
+ return PP_ERROR_BLOCKS_MAIN_THREAD;
if (callback_.get() && !callback_->completed())
return PP_ERROR_INPROGRESS;
@@ -80,10 +78,8 @@ int32_t PPB_Flash_NetConnector_Impl::ConnectTcpAddress(
if (!socket_out)
return PP_ERROR_BADARGUMENT;
- if (!callback.func) {
- NOTIMPLEMENTED();
- return PP_ERROR_BADARGUMENT;
- }
+ if (!callback.func)
+ return PP_ERROR_BLOCKS_MAIN_THREAD;
if (callback_.get() && !callback_->completed())
return PP_ERROR_INPROGRESS;
diff --git a/webkit/plugins/ppapi/ppb_graphics_2d_impl.cc b/webkit/plugins/ppapi/ppb_graphics_2d_impl.cc
index 3a75e99..bbef628 100644
--- a/webkit/plugins/ppapi/ppb_graphics_2d_impl.cc
+++ b/webkit/plugins/ppapi/ppb_graphics_2d_impl.cc
@@ -285,15 +285,13 @@ void PPB_Graphics2D_Impl::ReplaceContents(PP_Resource image_data) {
}
int32_t PPB_Graphics2D_Impl::Flush(PP_CompletionCallback callback) {
+ if (!callback.func)
+ return PP_ERROR_BLOCKS_MAIN_THREAD;
+
// Don't allow more than one pending flush at a time.
if (HasPendingFlush())
return PP_ERROR_INPROGRESS;
- // TODO(brettw) check that the current thread is not the main one and
- // implement blocking flushes in this case.
- if (!callback.func)
- return PP_ERROR_BADARGUMENT;
-
bool nothing_visible = true;
for (size_t i = 0; i < queued_operations_.size(); i++) {
QueuedOperation& operation = queued_operations_[i];
diff --git a/webkit/plugins/ppapi/ppb_surface_3d_impl.cc b/webkit/plugins/ppapi/ppb_surface_3d_impl.cc
index 4cbc306..89ff723 100644
--- a/webkit/plugins/ppapi/ppb_surface_3d_impl.cc
+++ b/webkit/plugins/ppapi/ppb_surface_3d_impl.cc
@@ -62,7 +62,7 @@ int32_t PPB_Surface3D_Impl::SwapBuffers(PP_CompletionCallback callback) {
if (!callback.func) {
// Blocking SwapBuffers isn't supported (since we have to be on the main
// thread).
- return PP_ERROR_BADARGUMENT;
+ return PP_ERROR_BLOCKS_MAIN_THREAD;
}
if (swap_callback_.get() && !swap_callback_->completed()) {
diff --git a/webkit/plugins/ppapi/ppb_transport_impl.cc b/webkit/plugins/ppapi/ppb_transport_impl.cc
index 1e121e2..1fd89d8 100644
--- a/webkit/plugins/ppapi/ppb_transport_impl.cc
+++ b/webkit/plugins/ppapi/ppb_transport_impl.cc
@@ -231,6 +231,8 @@ int32_t PPB_Transport_Impl::SetProperty(PP_TransportProperty property,
}
int32_t PPB_Transport_Impl::Connect(PP_CompletionCallback callback) {
+ if (!callback.func)
+ return PP_ERROR_BLOCKS_MAIN_THREAD;
if (!p2p_transport_.get())
return PP_ERROR_FAILED;
@@ -259,6 +261,8 @@ int32_t PPB_Transport_Impl::Connect(PP_CompletionCallback callback) {
int32_t PPB_Transport_Impl::GetNextAddress(PP_Var* address,
PP_CompletionCallback callback) {
+ if (!callback.func)
+ return PP_ERROR_BLOCKS_MAIN_THREAD;
if (!p2p_transport_.get())
return PP_ERROR_FAILED;
@@ -295,6 +299,8 @@ int32_t PPB_Transport_Impl::ReceiveRemoteAddress(PP_Var address) {
int32_t PPB_Transport_Impl::Recv(void* data, uint32_t len,
PP_CompletionCallback callback) {
+ if (!callback.func)
+ return PP_ERROR_BLOCKS_MAIN_THREAD;
if (!p2p_transport_.get())
return PP_ERROR_FAILED;
@@ -322,6 +328,8 @@ int32_t PPB_Transport_Impl::Recv(void* data, uint32_t len,
int32_t PPB_Transport_Impl::Send(const void* data, uint32_t len,
PP_CompletionCallback callback) {
+ if (!callback.func)
+ return PP_ERROR_BLOCKS_MAIN_THREAD;
if (!p2p_transport_.get())
return PP_ERROR_FAILED;
diff --git a/webkit/plugins/ppapi/ppb_url_loader_impl.cc b/webkit/plugins/ppapi/ppb_url_loader_impl.cc
index 5d0acb9..ee1a1a0 100644
--- a/webkit/plugins/ppapi/ppb_url_loader_impl.cc
+++ b/webkit/plugins/ppapi/ppb_url_loader_impl.cc
@@ -378,7 +378,7 @@ void PPB_URLLoader_Impl::FinishLoading(int32_t done_status) {
int32_t PPB_URLLoader_Impl::ValidateCallback(PP_CompletionCallback callback) {
// We only support non-blocking calls.
if (!callback.func)
- return PP_ERROR_BADARGUMENT;
+ return PP_ERROR_BLOCKS_MAIN_THREAD;
if (pending_callback_.get() && !pending_callback_->completed())
return PP_ERROR_INPROGRESS;
diff --git a/webkit/plugins/ppapi/ppb_video_decoder_impl.cc b/webkit/plugins/ppapi/ppb_video_decoder_impl.cc
index 7dc63a1..28bc215 100644
--- a/webkit/plugins/ppapi/ppb_video_decoder_impl.cc
+++ b/webkit/plugins/ppapi/ppb_video_decoder_impl.cc
@@ -117,6 +117,9 @@ bool PPB_VideoDecoder_Impl::Init(
int32_t PPB_VideoDecoder_Impl::Decode(
const PP_VideoBitstreamBuffer_Dev* bitstream_buffer,
PP_CompletionCallback callback) {
+ if (!callback.func)
+ return PP_ERROR_BLOCKS_MAIN_THREAD;
+
if (!platform_video_decoder_)
return PP_ERROR_BADRESOURCE;
@@ -166,6 +169,9 @@ void PPB_VideoDecoder_Impl::ReusePictureBuffer(int32_t picture_buffer_id) {
}
int32_t PPB_VideoDecoder_Impl::Flush(PP_CompletionCallback callback) {
+ if (!callback.func)
+ return PP_ERROR_BLOCKS_MAIN_THREAD;
+
if (!platform_video_decoder_)
return PP_ERROR_BADRESOURCE;
@@ -178,6 +184,9 @@ int32_t PPB_VideoDecoder_Impl::Flush(PP_CompletionCallback callback) {
}
int32_t PPB_VideoDecoder_Impl::Reset(PP_CompletionCallback callback) {
+ if (!callback.func)
+ return PP_ERROR_BLOCKS_MAIN_THREAD;
+
if (!platform_video_decoder_)
return PP_ERROR_BADRESOURCE;