summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rwxr-xr-xchrome/test/nacl_test_injection/buildbot_nacl_integration.py2
-rw-r--r--ppapi/c/dev/ppb_directory_reader_dev.h7
-rw-r--r--ppapi/c/dev/ppb_file_chooser_dev.h6
-rw-r--r--ppapi/c/dev/ppb_file_io_dev.h7
-rw-r--r--ppapi/c/dev/ppb_file_io_trusted_dev.h7
-rw-r--r--ppapi/c/dev/ppb_file_ref_dev.h5
-rw-r--r--ppapi/c/dev/ppb_file_system_dev.h5
-rw-r--r--ppapi/c/dev/ppb_graphics_3d_dev.h5
-rw-r--r--ppapi/c/dev/ppb_layer_compositor_dev.h4
-rw-r--r--ppapi/c/dev/ppb_surface_3d_dev.h6
-rw-r--r--ppapi/c/dev/ppb_transport_dev.h4
-rw-r--r--ppapi/c/pp_completion_callback.h126
-rw-r--r--ppapi/c/ppb_core.h7
-rw-r--r--ppapi/c/ppb_file_io.h5
-rw-r--r--ppapi/c/ppb_file_ref.h5
-rw-r--r--ppapi/c/ppb_file_system.h4
-rw-r--r--ppapi/c/ppb_graphics_2d.h7
-rw-r--r--ppapi/c/ppb_url_loader.h5
-rw-r--r--ppapi/c/private/ppb_flash_menu.h2
-rw-r--r--ppapi/c/private/ppb_flash_net_connector.h2
-rw-r--r--ppapi/c/trusted/ppb_audio_trusted.h3
-rw-r--r--ppapi/c/trusted/ppb_broker_trusted.h2
-rw-r--r--ppapi/c/trusted/ppb_file_io_trusted.h5
-rw-r--r--ppapi/cpp/completion_callback.h105
-rw-r--r--ppapi/cpp/dev/directory_reader_dev.cc4
-rw-r--r--ppapi/cpp/dev/file_chooser_dev.cc4
-rw-r--r--ppapi/cpp/dev/file_io_dev.cc16
-rw-r--r--ppapi/cpp/dev/file_ref_dev.cc12
-rw-r--r--ppapi/cpp/dev/file_system_dev.cc4
-rw-r--r--ppapi/cpp/dev/surface_3d_dev.cc4
-rw-r--r--ppapi/cpp/dev/transport_dev.cc8
-rw-r--r--ppapi/cpp/dev/video_decoder_dev.cc15
-rw-r--r--ppapi/cpp/file_io.cc14
-rw-r--r--ppapi/cpp/file_ref.cc10
-rw-r--r--ppapi/cpp/file_system.cc2
-rw-r--r--ppapi/cpp/graphics_2d.cc4
-rw-r--r--ppapi/cpp/paint_manager.cc2
-rw-r--r--ppapi/cpp/private/flash_menu.cc2
-rw-r--r--ppapi/cpp/private/flash_net_connector.cc4
-rw-r--r--ppapi/cpp/url_loader.cc10
-rw-r--r--ppapi/cpp/url_loader.h4
-rw-r--r--ppapi/example/example.cc4
-rw-r--r--ppapi/ppapi_shared.gypi2
-rw-r--r--ppapi/proxy/ppb_audio_proxy.cc2
-rw-r--r--ppapi/proxy/ppb_broker_proxy.cc2
-rw-r--r--ppapi/proxy/ppb_file_chooser_proxy.cc2
-rw-r--r--ppapi/proxy/ppb_file_system_proxy.cc2
-rw-r--r--ppapi/proxy/ppb_flash_menu_proxy.cc2
-rw-r--r--ppapi/proxy/ppb_flash_net_connector_proxy.cc4
-rw-r--r--ppapi/proxy/ppb_graphics_2d_proxy.cc2
-rw-r--r--ppapi/proxy/ppb_surface_3d_proxy.cc2
-rw-r--r--ppapi/proxy/ppb_url_loader_proxy.cc2
-rw-r--r--ppapi/tests/arch_dependent_sizes_32.h2
-rw-r--r--ppapi/tests/arch_dependent_sizes_64.h2
-rw-r--r--ppapi/tests/test_case.cc3
-rw-r--r--ppapi/tests/test_case.h17
-rw-r--r--ppapi/tests/test_directory_reader.cc14
-rw-r--r--ppapi/tests/test_file_io.cc92
-rw-r--r--ppapi/tests/test_file_ref.cc133
-rw-r--r--ppapi/tests/test_file_system.cc29
-rw-r--r--ppapi/tests/test_graphics_2d.cc50
-rw-r--r--ppapi/tests/test_transport.cc21
-rw-r--r--ppapi/tests/test_url_loader.cc58
-rw-r--r--ppapi/tests/test_utils.cc15
-rw-r--r--ppapi/tests/test_utils.h4
-rw-r--r--ppapi/thunk/common.cc30
-rw-r--r--ppapi/thunk/common.h21
-rw-r--r--ppapi/thunk/ppb_audio_trusted_thunk.cc10
-rw-r--r--ppapi/thunk/ppb_broker_thunk.cc8
-rw-r--r--ppapi/thunk/ppb_directory_reader_thunk.cc8
-rw-r--r--ppapi/thunk/ppb_file_chooser_thunk.cc8
-rw-r--r--ppapi/thunk/ppb_file_io_thunk.cc41
-rw-r--r--ppapi/thunk/ppb_file_io_trusted_thunk.cc13
-rw-r--r--ppapi/thunk/ppb_file_ref_thunk.cc24
-rw-r--r--ppapi/thunk/ppb_file_system_thunk.cc8
-rw-r--r--ppapi/thunk/ppb_flash_menu_thunk.cc9
-rw-r--r--ppapi/thunk/ppb_flash_net_connector_thunk.cc18
-rw-r--r--ppapi/thunk/ppb_graphics_2d_thunk.cc6
-rw-r--r--ppapi/thunk/ppb_graphics_3d_thunk.cc8
-rw-r--r--ppapi/thunk/ppb_layer_compositor_thunk.cc5
-rw-r--r--ppapi/thunk/ppb_surface_3d_thunk.cc8
-rw-r--r--ppapi/thunk/ppb_transport_thunk.cc23
-rw-r--r--ppapi/thunk/ppb_url_loader_thunk.cc24
-rw-r--r--ppapi/thunk/ppb_video_decoder_thunk.cc24
-rw-r--r--remoting/client/plugin/pepper_port_allocator_session.cc4
85 files changed, 856 insertions, 365 deletions
diff --git a/chrome/test/nacl_test_injection/buildbot_nacl_integration.py b/chrome/test/nacl_test_injection/buildbot_nacl_integration.py
index fbbcf53..3800d9b 100755
--- a/chrome/test/nacl_test_injection/buildbot_nacl_integration.py
+++ b/chrome/test/nacl_test_injection/buildbot_nacl_integration.py
@@ -23,7 +23,7 @@ def Main():
# Uncomment the following line if there is skew in the PPAPI interface
# and the tests are failing. Comment out once the issues are resolved.
- # return
+ return
script_dir = os.path.dirname(os.path.abspath(__file__))
test_dir = os.path.dirname(script_dir)
diff --git a/ppapi/c/dev/ppb_directory_reader_dev.h b/ppapi/c/dev/ppb_directory_reader_dev.h
index 41b7299..94e1e12 100644
--- a/ppapi/c/dev/ppb_directory_reader_dev.h
+++ b/ppapi/c/dev/ppb_directory_reader_dev.h
@@ -1,4 +1,4 @@
-/* Copyright (c) 2010 The Chromium Authors. All rights reserved.
+/* Copyright (c) 2011 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.
*/
@@ -19,8 +19,8 @@ struct PP_DirectoryEntry_Dev {
};
PP_COMPILE_ASSERT_STRUCT_SIZE_IN_BYTES(PP_DirectoryEntry_Dev, 8);
-#define PPB_DIRECTORYREADER_DEV_INTERFACE_0_4 "PPB_DirectoryReader(Dev);0.4"
-#define PPB_DIRECTORYREADER_DEV_INTERFACE PPB_DIRECTORYREADER_DEV_INTERFACE_0_4
+#define PPB_DIRECTORYREADER_DEV_INTERFACE_0_5 "PPB_DirectoryReader(Dev);0.5"
+#define PPB_DIRECTORYREADER_DEV_INTERFACE PPB_DIRECTORYREADER_DEV_INTERFACE_0_5
struct PPB_DirectoryReader_Dev {
// Creates a DirectoryReader for the given directory. Upon success, the
@@ -56,4 +56,3 @@ struct PPB_DirectoryReader_Dev {
};
#endif /* PPAPI_C_DEV_PPB_DIRECTORY_READER_DEV_H_ */
-
diff --git a/ppapi/c/dev/ppb_file_chooser_dev.h b/ppapi/c/dev/ppb_file_chooser_dev.h
index e0c010f..27080fe 100644
--- a/ppapi/c/dev/ppb_file_chooser_dev.h
+++ b/ppapi/c/dev/ppb_file_chooser_dev.h
@@ -1,4 +1,4 @@
-/* Copyright (c) 2010 The Chromium Authors. All rights reserved.
+/* Copyright (c) 2011 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.
*/
@@ -31,8 +31,8 @@ struct PP_FileChooserOptions_Dev {
const char* accept_mime_types;
};
-#define PPB_FILECHOOSER_DEV_INTERFACE_0_3 "PPB_FileChooser(Dev);0.3"
-#define PPB_FILECHOOSER_DEV_INTERFACE PPB_FILECHOOSER_DEV_INTERFACE_0_3
+#define PPB_FILECHOOSER_DEV_INTERFACE_0_4 "PPB_FileChooser(Dev);0.4"
+#define PPB_FILECHOOSER_DEV_INTERFACE PPB_FILECHOOSER_DEV_INTERFACE_0_4
struct PPB_FileChooser_Dev {
// Creates a file chooser dialog with the specified options. The chooser is
diff --git a/ppapi/c/dev/ppb_file_io_dev.h b/ppapi/c/dev/ppb_file_io_dev.h
index 0b08712..4ffd282 100644
--- a/ppapi/c/dev/ppb_file_io_dev.h
+++ b/ppapi/c/dev/ppb_file_io_dev.h
@@ -1,4 +1,4 @@
-/* Copyright (c) 2010 The Chromium Authors. All rights reserved.
+/* Copyright (c) 2011 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,8 +39,8 @@ typedef enum {
} PP_FileOpenFlags_Dev;
PP_COMPILE_ASSERT_SIZE_IN_BYTES(PP_FileOpenFlags_Dev, 4);
-#define PPB_FILEIO_DEV_INTERFACE_0_3 "PPB_FileIO(Dev);0.3"
-#define PPB_FILEIO_DEV_INTERFACE PPB_FILEIO_DEV_INTERFACE_0_3
+#define PPB_FILEIO_DEV_INTERFACE_0_4 "PPB_FileIO(Dev);0.4"
+#define PPB_FILEIO_DEV_INTERFACE PPB_FILEIO_DEV_INTERFACE_0_4
// Use this interface to operate on a regular file (PP_FileType_Regular).
struct PPB_FileIO_Dev {
@@ -117,4 +117,3 @@ struct PPB_FileIO_Dev {
};
#endif /* PPAPI_C_DEV_PPB_FILE_IO_DEV_H_ */
-
diff --git a/ppapi/c/dev/ppb_file_io_trusted_dev.h b/ppapi/c/dev/ppb_file_io_trusted_dev.h
index d3f7c38..ed73a6c 100644
--- a/ppapi/c/dev/ppb_file_io_trusted_dev.h
+++ b/ppapi/c/dev/ppb_file_io_trusted_dev.h
@@ -1,4 +1,4 @@
-/* Copyright (c) 2010 The Chromium Authors. All rights reserved.
+/* Copyright (c) 2011 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.
*/
@@ -10,8 +10,8 @@
struct PP_CompletionCallback;
-#define PPB_FILEIOTRUSTED_DEV_INTERFACE_0_2 "PPB_FileIOTrusted(Dev);0.2"
-#define PPB_FILEIOTRUSTED_DEV_INTERFACE PPB_FILEIOTRUSTED_DEV_INTERFACE_0_2
+#define PPB_FILEIOTRUSTED_DEV_INTERFACE_0_3 "PPB_FileIOTrusted(Dev);0.3"
+#define PPB_FILEIOTRUSTED_DEV_INTERFACE PPB_FILEIOTRUSTED_DEV_INTERFACE_0_3
// Available only to trusted implementations.
struct PPB_FileIOTrusted_Dev {
@@ -45,4 +45,3 @@ struct PPB_FileIOTrusted_Dev {
};
#endif /* PPAPI_C_DEV_PPB_FILE_IO_TRUSTED_DEV_H_ */
-
diff --git a/ppapi/c/dev/ppb_file_ref_dev.h b/ppapi/c/dev/ppb_file_ref_dev.h
index 61e60dc..05b3d9c 100644
--- a/ppapi/c/dev/ppb_file_ref_dev.h
+++ b/ppapi/c/dev/ppb_file_ref_dev.h
@@ -13,8 +13,8 @@
struct PP_CompletionCallback;
-#define PPB_FILEREF_DEV_INTERFACE_0_7 "PPB_FileRef(Dev);0.7"
-#define PPB_FILEREF_DEV_INTERFACE PPB_FILEREF_DEV_INTERFACE_0_7
+#define PPB_FILEREF_DEV_INTERFACE_0_8 "PPB_FileRef(Dev);0.8"
+#define PPB_FILEREF_DEV_INTERFACE PPB_FILEREF_DEV_INTERFACE_0_8
// A FileRef is a "weak pointer" to a file in a file system. It contains a
// PP_FileSystemType identifier and a file path string.
@@ -79,4 +79,3 @@ struct PPB_FileRef_Dev {
};
#endif /* PPAPI_C_DEV_PPB_FILE_REF_DEV_H_ */
-
diff --git a/ppapi/c/dev/ppb_file_system_dev.h b/ppapi/c/dev/ppb_file_system_dev.h
index f64236c..ba1e517 100644
--- a/ppapi/c/dev/ppb_file_system_dev.h
+++ b/ppapi/c/dev/ppb_file_system_dev.h
@@ -14,8 +14,8 @@
struct PP_CompletionCallback;
-#define PPB_FILESYSTEM_DEV_INTERFACE_0_5 "PPB_FileSystem(Dev);0.5"
-#define PPB_FILESYSTEM_DEV_INTERFACE PPB_FILESYSTEM_DEV_INTERFACE_0_5
+#define PPB_FILESYSTEM_DEV_INTERFACE_0_6 "PPB_FileSystem(Dev);0.6"
+#define PPB_FILESYSTEM_DEV_INTERFACE PPB_FILESYSTEM_DEV_INTERFACE_0_6
struct PPB_FileSystem_Dev {
/** Creates a filesystem object of the given type. */
@@ -45,4 +45,3 @@ struct PPB_FileSystem_Dev {
};
#endif /* PPAPI_C_DEV_PPB_FILE_SYSTEM_DEV_H_ */
-
diff --git a/ppapi/c/dev/ppb_graphics_3d_dev.h b/ppapi/c/dev/ppb_graphics_3d_dev.h
index 63826c8..6e53328 100644
--- a/ppapi/c/dev/ppb_graphics_3d_dev.h
+++ b/ppapi/c/dev/ppb_graphics_3d_dev.h
@@ -31,8 +31,8 @@
// // Shutdown.
// core->ReleaseResource(context);
-#define PPB_GRAPHICS_3D_DEV_INTERFACE_0_4 "PPB_Graphics3D(Dev);0.4"
-#define PPB_GRAPHICS_3D_DEV_INTERFACE PPB_GRAPHICS_3D_DEV_INTERFACE_0_4
+#define PPB_GRAPHICS_3D_DEV_INTERFACE_0_5 "PPB_Graphics3D(Dev);0.5"
+#define PPB_GRAPHICS_3D_DEV_INTERFACE PPB_GRAPHICS_3D_DEV_INTERFACE_0_5
struct PPB_Graphics3D_Dev {
// TODO(alokp): Do these functions need module argument?
@@ -226,4 +226,3 @@ struct PPB_Graphics3D_Dev {
};
#endif /* PPAPI_C_DEV_PPB_GRAPHICS_3D_DEV_H_ */
-
diff --git a/ppapi/c/dev/ppb_layer_compositor_dev.h b/ppapi/c/dev/ppb_layer_compositor_dev.h
index 1ee4594..1d3ee37 100644
--- a/ppapi/c/dev/ppb_layer_compositor_dev.h
+++ b/ppapi/c/dev/ppb_layer_compositor_dev.h
@@ -11,7 +11,9 @@
#include "ppapi/c/pp_resource.h"
#include "ppapi/c/pp_size.h"
-#define PPB_LAYER_COMPOSITOR_DEV_INTERFACE "PPB_LayerCompositor(Dev);0.1"
+#define PPB_LAYER_COMPOSITOR_DEV_INTERFACE_0_2 "PPB_LayerCompositor(Dev);0.2"
+#define PPB_LAYER_COMPOSITOR_DEV_INTERFACE \
+ PPB_LAYER_COMPOSITOR_DEV_INTERFACE_0_2
// PPB_LayerCompositor allows multiple layers of PPB_Surface3D and
// PPB_VideoLayer be bound to a plugin instance.
diff --git a/ppapi/c/dev/ppb_surface_3d_dev.h b/ppapi/c/dev/ppb_surface_3d_dev.h
index 1eb5057..47b47ef 100644
--- a/ppapi/c/dev/ppb_surface_3d_dev.h
+++ b/ppapi/c/dev/ppb_surface_3d_dev.h
@@ -1,4 +1,4 @@
-/* Copyright (c) 2010 The Chromium Authors. All rights reserved.
+/* Copyright (c) 2011 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.
*/
@@ -12,8 +12,8 @@
#include "ppapi/c/pp_instance.h"
#include "ppapi/c/pp_resource.h"
-#define PPB_SURFACE_3D_DEV_INTERFACE_0_1 "PPB_Surface3D(Dev);0.1"
-#define PPB_SURFACE_3D_DEV_INTERFACE PPB_SURFACE_3D_DEV_INTERFACE_0_1
+#define PPB_SURFACE_3D_DEV_INTERFACE_0_2 "PPB_Surface3D(Dev);0.2"
+#define PPB_SURFACE_3D_DEV_INTERFACE PPB_SURFACE_3D_DEV_INTERFACE_0_2
struct PPB_Surface3D_Dev {
// Creates a render surface and returns a handle to it.
diff --git a/ppapi/c/dev/ppb_transport_dev.h b/ppapi/c/dev/ppb_transport_dev.h
index 5b303e2..bc3a8cd 100644
--- a/ppapi/c/dev/ppb_transport_dev.h
+++ b/ppapi/c/dev/ppb_transport_dev.h
@@ -13,8 +13,8 @@
#include "ppapi/c/pp_stdint.h"
#include "ppapi/c/pp_var.h"
-#define PPB_TRANSPORT_DEV_INTERFACE_0_4 "PPB_Transport;0.4"
-#define PPB_TRANSPORT_DEV_INTERFACE PPB_TRANSPORT_DEV_INTERFACE_0_4
+#define PPB_TRANSPORT_DEV_INTERFACE_0_5 "PPB_Transport;0.5"
+#define PPB_TRANSPORT_DEV_INTERFACE PPB_TRANSPORT_DEV_INTERFACE_0_5
struct PPB_Transport_Dev {
// Creates a new transport object with the specified name using the
diff --git a/ppapi/c/pp_completion_callback.h b/ppapi/c/pp_completion_callback.h
index 248dedc..bc7074a 100644
--- a/ppapi/c/pp_completion_callback.h
+++ b/ppapi/c/pp_completion_callback.h
@@ -21,8 +21,15 @@
*/
/**
- * PP_CompletionCallback_Func defines the signature that you implement to
- * receive callbacks on asynchronous completion.
+ * PP_CompletionCallback_Func defines the function signature that you implement
+ * to receive callbacks on asynchronous completion of an operation.
+ *
+ * |user_data| is a pointer to user-specified data associated with this
+ * function at callback creation. See PP_MakeCompletionCallback() for details.
+ *
+ * |result| is the result of the operation. Non-positive values correspond to
+ * the error codes from pp_errors.h (excluding PP_OK_COMPLETIONPENDING).
+ * Positive values indicate additional information such as bytes read.
*/
typedef void (*PP_CompletionCallback_Func)(void* user_data, int32_t result);
/**
@@ -30,28 +37,61 @@ typedef void (*PP_CompletionCallback_Func)(void* user_data, int32_t result);
*/
/**
+ *
+ * @addtogroup Enums
+ * @{
+ */
+
+/**
+ * This enumeration contains flags used to control how non-NULL callbacks are
+ * scheduled by asynchronous methods.
+ */
+typedef enum {
+ /**
+ * This flag allows any non-NULL callback to be always invoked asynchronously,
+ * on success or error, even if the operation could complete synchronously
+ * without blocking.
+ *
+ * The method taking such callback will always return PP_OK_COMPLETIONPENDING.
+ * The callback will be invoked on the main thread of PPAPI execution.
+ *
+ * TODO(polina): make this the default once all the clients use flags.
+ */
+ PP_COMPLETIONCALLBACK_FLAG_NONE = 0 << 0,
+ /**
+ * This flag allows any method taking such callback to complete synchronously
+ * and not call the callback if the operation would not block. This is useful
+ * when performance is an issue, and the operation bandwidth should not be
+ * limited to the processing speed of the message loop.
+ *
+ * On synchronous method completion, the completion result will be returned
+ * by the method itself. Otherwise, the method will return
+ * PP_OK_COMPLETIONPENDING, and the callback will be invoked asynchronously on
+ * the main thread of PPAPI execution.
+ */
+ PP_COMPLETIONCALLBACK_FLAG_OPTIONAL = 1 << 0
+} PP_CompletionCallback_Flag;
+PP_COMPILE_ASSERT_SIZE_IN_BYTES(PP_CompletionCallback_Flag, 4);
+
+
+/**
* @addtogroup Structs
* @{
*/
/**
- * Any method that takes a PP_CompletionCallback has the option of completing
- * asynchronously if the operation would block. Such a method should return
- * PP_OK_COMPLETIONPENDING to indicate that the method will complete
- * asynchronously and will always be invoked from the main thread of PPAPI
- * execution. If the completion callback is NULL, then the operation will
- * block if necessary to complete its work. PP_BlockUntilComplete() provides a
- * convenient way to specify blocking behavior. Refer to PP_BlockUntilComplete
- * for more information.
+ * Any method that takes a PP_CompletionCallback can complete asynchronously.
+ * Refer to PP_CompletionCallback_Flag for more information.
*
- * The result parameter passes an int32_t that, if negative or equal to 0,
- * indicate if the call will completely asynchronously (the callback will be
- * called with a status code). A value greater than zero indicates additional
- * information such as bytes read.
+ * If PP_CompletionCallback_Func is NULL, the operation might block if necessary
+ * to complete the work. Refer to PP_BlockUntilComplete for more information.
+ *
+ * See PP_MakeCompletionCallback() for the description of each field.
*/
struct PP_CompletionCallback {
PP_CompletionCallback_Func func;
void* user_data;
+ int32_t flags;
};
/**
* @}
@@ -61,14 +101,20 @@ struct PP_CompletionCallback {
* @addtogroup Functions
* @{
*/
-
/**
- * PP_MakeCompletionCallback() is used to create a PP_CompletionCallback.
+ * PP_MakeCompletionCallback() is used to create a PP_CompletionCallback
+ * without flags. If you want to alter the default callback behavior, set the
+ * flags to a bit field combination of PP_CompletionCallback_Flag's.
+ *
+ * Example:
+ * struct PP_CompletionCallback cc = PP_MakeCompletionCallback(Foo, NULL);
+ * cc.flags = cc.flags | PP_COMPLETIONCALLBACK_FLAG_OPTIONAL;
+ *
+ * @param[in] func A PP_CompletionCallback_Func to be called on completion.
+ * @param[in] user_data A pointer to user data passed to be passed to the
+ * callback function. This is optional and is typically used to help track state
+ * in case of multiple pending callbacks.
*
- * @param[in] func A PP_CompletionCallback_Func that will be called.
- * @param[in] user_data A pointer to user data passed to your callback
- * function. This is optional and is typically used to help track state
- * when you may have multiple callbacks pending.
* @return A PP_CompletionCallback structure.
*/
PP_INLINE struct PP_CompletionCallback PP_MakeCompletionCallback(
@@ -77,6 +123,27 @@ PP_INLINE struct PP_CompletionCallback PP_MakeCompletionCallback(
struct PP_CompletionCallback cc;
cc.func = func;
cc.user_data = user_data;
+ /* TODO(polina): switch the default to PP_COMPLETIONCALLBACK_FLAG_NONE. */
+ cc.flags = PP_COMPLETIONCALLBACK_FLAG_OPTIONAL;
+ return cc;
+}
+
+/**
+ * PP_MakeOptionalCompletionCallback() is used to create a PP_CompletionCallback
+ * with PP_COMPLETIONCALLBACK_FLAG_OPTIONAL set.
+ *
+ * @param[in] func A PP_CompletionCallback_Func to be called on completion.
+ * @param[in] user_data A pointer to user data passed to be passed to the
+ * callback function. This is optional and is typically used to help track state
+ * in case of multiple pending callbacks.
+ *
+ * @return A PP_CompletionCallback structure.
+ */
+PP_INLINE struct PP_CompletionCallback PP_MakeOptionalCompletionCallback(
+ PP_CompletionCallback_Func func,
+ void* user_data) {
+ struct PP_CompletionCallback cc = PP_MakeCompletionCallback(func, user_data);
+ cc.flags = cc.flags | PP_COMPLETIONCALLBACK_FLAG_OPTIONAL;
return cc;
}
/**
@@ -89,17 +156,18 @@ PP_INLINE struct PP_CompletionCallback PP_MakeCompletionCallback(
*/
/**
- * PP_RunCompletionCallback() is used to run a callback.
+ * PP_RunCompletionCallback() is used to run a callback. It invokes
+ * the callback function passing it user data specified on creation and
+ * completion |result|.
*
* @param[in] cc A pointer to a PP_CompletionCallback that will be run.
- * @param[in] res The result parameter that, if negative or equal to 0,
- * indicate if the call will completely asynchronously (the callback will be
- * called with a status code). A value greater than zero indicates additional
- * information such as bytes read.
+ * @param[in] result The result of the operation. Non-positive values correspond
+ * to the error codes from pp_errors.h (excluding PP_OK_COMPLETIONPENDING).
+ * Positive values indicate additional information such as bytes read.
*/
PP_INLINE void PP_RunCompletionCallback(struct PP_CompletionCallback* cc,
- int32_t res) {
- cc->func(cc->user_data, res);
+ int32_t result) {
+ cc->func(cc->user_data, result);
}
/**
@@ -114,10 +182,10 @@ PP_INLINE void PP_RunCompletionCallback(struct PP_CompletionCallback* cc,
/**
* PP_BlockUntilComplete() is used in place of an actual completion callback
* to request blocking behavior. If specified, the calling thread will block
- * until the function completes. Blocking completion callbacks are only usable
+ * until the function completes. Blocking completion callbacks are only allowed
* from background threads.
*
- * @return A PP_CompletionCallback structure.
+ * @return A PP_CompletionCallback structure corresponding to a NULL callback.
*/
PP_INLINE struct PP_CompletionCallback PP_BlockUntilComplete() {
return PP_MakeCompletionCallback(NULL, NULL);
diff --git a/ppapi/c/ppb_core.h b/ppapi/c/ppb_core.h
index ac7b8f4..968dfcd 100644
--- a/ppapi/c/ppb_core.h
+++ b/ppapi/c/ppb_core.h
@@ -1,4 +1,4 @@
-/* Copyright (c) 2010 The Chromium Authors. All rights reserved.
+/* Copyright (c) 2011 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.
*/
@@ -13,8 +13,8 @@
struct PP_CompletionCallback;
-#define PPB_CORE_INTERFACE_0_4 "PPB_Core;0.4"
-#define PPB_CORE_INTERFACE PPB_CORE_INTERFACE_0_4
+#define PPB_CORE_INTERFACE_0_5 "PPB_Core;0.5"
+#define PPB_CORE_INTERFACE PPB_CORE_INTERFACE_0_5
/**
* @file
@@ -139,4 +139,3 @@ struct PPB_Core {
#endif /* PPAPI_C_DEV_PPB_CORE_DEV_H_ */
-
diff --git a/ppapi/c/ppb_file_io.h b/ppapi/c/ppb_file_io.h
index 0f274db..92ad35b 100644
--- a/ppapi/c/ppb_file_io.h
+++ b/ppapi/c/ppb_file_io.h
@@ -39,8 +39,8 @@ typedef enum {
} PP_FileOpenFlags;
PP_COMPILE_ASSERT_SIZE_IN_BYTES(PP_FileOpenFlags, 4);
-#define PPB_FILEIO_INTERFACE_0_4 "PPB_FileIO;0.4"
-#define PPB_FILEIO_INTERFACE PPB_FILEIO_INTERFACE_0_4
+#define PPB_FILEIO_INTERFACE_0_5 "PPB_FileIO;0.5"
+#define PPB_FILEIO_INTERFACE PPB_FILEIO_INTERFACE_0_5
// Use this interface to operate on a regular file (PP_FileType_Regular).
struct PPB_FileIO {
@@ -117,3 +117,4 @@ struct PPB_FileIO {
};
#endif /* PPAPI_C_PPB_FILE_IO_H_ */
+
diff --git a/ppapi/c/ppb_file_ref.h b/ppapi/c/ppb_file_ref.h
index 3f6faf7..4813d1a 100644
--- a/ppapi/c/ppb_file_ref.h
+++ b/ppapi/c/ppb_file_ref.h
@@ -13,8 +13,8 @@
struct PP_CompletionCallback;
-#define PPB_FILEREF_INTERFACE_0_8 "PPB_FileRef;0.8"
-#define PPB_FILEREF_INTERFACE PPB_FILEREF_INTERFACE_0_8
+#define PPB_FILEREF_INTERFACE_0_9 "PPB_FileRef;0.9"
+#define PPB_FILEREF_INTERFACE PPB_FILEREF_INTERFACE_0_9
// A FileRef is a "weak pointer" to a file in a file system. It contains a
// PP_FileSystemType identifier and a file path string.
@@ -79,3 +79,4 @@ struct PPB_FileRef {
};
#endif /* PPAPI_C_PPB_FILE_REF_H_ */
+
diff --git a/ppapi/c/ppb_file_system.h b/ppapi/c/ppb_file_system.h
index 692aa9c..07f1f78 100644
--- a/ppapi/c/ppb_file_system.h
+++ b/ppapi/c/ppb_file_system.h
@@ -14,8 +14,8 @@
struct PP_CompletionCallback;
-#define PPB_FILESYSTEM_INTERFACE_0_6 "PPB_FileSystem;0.6"
-#define PPB_FILESYSTEM_INTERFACE PPB_FILESYSTEM_INTERFACE_0_6
+#define PPB_FILESYSTEM_INTERFACE_0_7 "PPB_FileSystem;0.7"
+#define PPB_FILESYSTEM_INTERFACE PPB_FILESYSTEM_INTERFACE_0_7
struct PPB_FileSystem {
/** Creates a filesystem object of the given type. */
diff --git a/ppapi/c/ppb_graphics_2d.h b/ppapi/c/ppb_graphics_2d.h
index b08e9fc..d32ef5d 100644
--- a/ppapi/c/ppb_graphics_2d.h
+++ b/ppapi/c/ppb_graphics_2d.h
@@ -1,4 +1,4 @@
-/* Copyright (c) 2010 The Chromium Authors. All rights reserved.
+/* Copyright (c) 2011 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.
*/
@@ -16,8 +16,8 @@ struct PP_Point;
struct PP_Rect;
struct PP_Size;
-#define PPB_GRAPHICS_2D_INTERFACE_0_3 "PPB_Graphics2D;0.3"
-#define PPB_GRAPHICS_2D_INTERFACE PPB_GRAPHICS_2D_INTERFACE_0_3
+#define PPB_GRAPHICS_2D_INTERFACE_0_4 "PPB_Graphics2D;0.4"
+#define PPB_GRAPHICS_2D_INTERFACE PPB_GRAPHICS_2D_INTERFACE_0_4
/**
* @file
@@ -231,4 +231,3 @@ struct PPB_Graphics2D {
* @}
*/
#endif /* PPAPI_C_PPB_GRAPHICS_2D_H_ */
-
diff --git a/ppapi/c/ppb_url_loader.h b/ppapi/c/ppb_url_loader.h
index 6ff753b..afbee22 100644
--- a/ppapi/c/ppb_url_loader.h
+++ b/ppapi/c/ppb_url_loader.h
@@ -12,8 +12,8 @@
struct PP_CompletionCallback;
-#define PPB_URLLOADER_INTERFACE_0_1 "PPB_URLLoader;0.1"
-#define PPB_URLLOADER_INTERFACE PPB_URLLOADER_INTERFACE_0_1
+#define PPB_URLLOADER_INTERFACE_0_2 "PPB_URLLoader;0.2"
+#define PPB_URLLOADER_INTERFACE PPB_URLLOADER_INTERFACE_0_2
/**
* @file
@@ -216,4 +216,3 @@ struct PPB_URLLoader {
*/
#endif /* PPAPI_C_PPB_URL_LOADER_H_ */
-
diff --git a/ppapi/c/private/ppb_flash_menu.h b/ppapi/c/private/ppb_flash_menu.h
index 7fc62e5..d7cbf4d 100644
--- a/ppapi/c/private/ppb_flash_menu.h
+++ b/ppapi/c/private/ppb_flash_menu.h
@@ -10,7 +10,7 @@
#include "ppapi/c/pp_point.h"
#include "ppapi/c/pp_resource.h"
-#define PPB_FLASH_MENU_INTERFACE "PPB_Flash_Menu;1"
+#define PPB_FLASH_MENU_INTERFACE "PPB_Flash_Menu;0.2"
struct PP_CompletionCallback;
diff --git a/ppapi/c/private/ppb_flash_net_connector.h b/ppapi/c/private/ppb_flash_net_connector.h
index 2cc25bb..9f342fc 100644
--- a/ppapi/c/private/ppb_flash_net_connector.h
+++ b/ppapi/c/private/ppb_flash_net_connector.h
@@ -10,7 +10,7 @@
#include "ppapi/c/pp_resource.h"
#include "ppapi/c/private/ppb_flash_file.h" // For |PP_FileHandle|.
-#define PPB_FLASH_NETCONNECTOR_INTERFACE "PPB_Flash_NetConnector;0.1"
+#define PPB_FLASH_NETCONNECTOR_INTERFACE "PPB_Flash_NetConnector;0.2"
// This is an opaque type holding a network address.
struct PP_Flash_NetAddress {
diff --git a/ppapi/c/trusted/ppb_audio_trusted.h b/ppapi/c/trusted/ppb_audio_trusted.h
index 49c947c..cac02f2 100644
--- a/ppapi/c/trusted/ppb_audio_trusted.h
+++ b/ppapi/c/trusted/ppb_audio_trusted.h
@@ -9,7 +9,7 @@
#include "ppapi/c/pp_instance.h"
#include "ppapi/c/pp_resource.h"
-#define PPB_AUDIO_TRUSTED_INTERFACE "PPB_AudioTrusted;0.5"
+#define PPB_AUDIO_TRUSTED_INTERFACE "PPB_AudioTrusted;0.6"
/**
* This interface is to be used by proxy implementations. All
@@ -47,4 +47,3 @@ struct PPB_AudioTrusted {
};
#endif /* PPAPI_C_PPB_AUDIO_TRUSTED_H_ */
-
diff --git a/ppapi/c/trusted/ppb_broker_trusted.h b/ppapi/c/trusted/ppb_broker_trusted.h
index 84fb924..5cf091f 100644
--- a/ppapi/c/trusted/ppb_broker_trusted.h
+++ b/ppapi/c/trusted/ppb_broker_trusted.h
@@ -10,7 +10,7 @@
#include "ppapi/c/pp_instance.h"
#include "ppapi/c/pp_resource.h"
-#define PPB_BROKER_TRUSTED_INTERFACE "PPB_BrokerTrusted;0.1"
+#define PPB_BROKER_TRUSTED_INTERFACE "PPB_BrokerTrusted;0.2"
/**
* @file
diff --git a/ppapi/c/trusted/ppb_file_io_trusted.h b/ppapi/c/trusted/ppb_file_io_trusted.h
index 44e6e43..766ed3f 100644
--- a/ppapi/c/trusted/ppb_file_io_trusted.h
+++ b/ppapi/c/trusted/ppb_file_io_trusted.h
@@ -10,8 +10,8 @@
struct PP_CompletionCallback;
-#define PPB_FILEIOTRUSTED_INTERFACE_0_3 "PPB_FileIOTrusted;0.3"
-#define PPB_FILEIOTRUSTED_INTERFACE PPB_FILEIOTRUSTED_INTERFACE_0_3
+#define PPB_FILEIOTRUSTED_INTERFACE_0_4 "PPB_FileIOTrusted;0.4"
+#define PPB_FILEIOTRUSTED_INTERFACE PPB_FILEIOTRUSTED_INTERFACE_0_4
// Available only to trusted implementations.
struct PPB_FileIOTrusted {
@@ -45,3 +45,4 @@ struct PPB_FileIOTrusted {
};
#endif /* PPAPI_C_PPB_FILE_IO_TRUSTED_H_ */
+
diff --git a/ppapi/cpp/completion_callback.h b/ppapi/cpp/completion_callback.h
index 92403f3..6438c07 100644
--- a/ppapi/cpp/completion_callback.h
+++ b/ppapi/cpp/completion_callback.h
@@ -6,6 +6,7 @@
#define PPAPI_CPP_COMPLETION_CALLBACK_H_
#include "ppapi/c/pp_completion_callback.h"
+#include "ppapi/c/pp_errors.h"
#include "ppapi/cpp/logging.h"
#include "ppapi/cpp/non_thread_safe_ref_count.h"
@@ -27,6 +28,14 @@ class CompletionCallback {
cc_ = PP_MakeCompletionCallback(func, user_data);
}
+ CompletionCallback(PP_CompletionCallback_Func func, void* user_data,
+ int32_t flags) {
+ cc_ = PP_MakeCompletionCallback(func, user_data);
+ cc_.flags = flags;
+ }
+
+ void set_flags(int32_t flags) { cc_.flags = flags; }
+
// Call this method to explicitly run the CompletionCallback. Normally, the
// system runs a CompletionCallback after an asynchronous operation
// completes, but programs may wish to run the CompletionCallback manually
@@ -36,7 +45,34 @@ class CompletionCallback {
PP_RunCompletionCallback(&cc_, result);
}
+ bool IsOptional() const {
+ return (cc_.func == NULL ||
+ (cc_.flags & PP_COMPLETIONCALLBACK_FLAG_OPTIONAL) != 0);
+ }
+
const PP_CompletionCallback& pp_completion_callback() const { return cc_; }
+ int32_t flags() const { return cc_.flags; }
+
+ // Use this when implementing functions taking callbacks.
+ // If the callback is required and |result| indicates that it has not
+ // been scheduled, it will be forced on the main thread.
+ //
+ // EXAMPLE USAGE:
+ //
+ // int32_t OpenURL(pp::URLLoader* loader,
+ // pp::URLRequestInfo* url_request_info,
+ // const CompletionCallback& cc) {
+ // if (loader == NULL || url_request_info == NULL)
+ // return cc.MayForce(PP_ERROR_BADRESOURCE);
+ // return loader->Open(*loader, *url_request_info, cc);
+ // }
+ //
+ int32_t MayForce(int32_t result) const {
+ if (result == PP_OK_COMPLETIONPENDING || IsOptional())
+ return result;
+ Module::Get()->core()->CallOnMainThread(0, *this, result);
+ return PP_OK_COMPLETIONPENDING;
+ }
protected:
PP_CompletionCallback cc_;
@@ -67,10 +103,10 @@ class CompletionCallback {
// }
//
// void ProcessFile(const FileRef& file) {
-// CompletionCallback cc = factory_.NewCallback(&MyHandler::DidOpen);
+// CompletionCallback cc = factory_.NewRequiredCallback(
+// &MyHandler::DidOpen);
// int32_t rv = fio_.Open(file, PP_FileOpenFlag_Read, cc);
-// if (rv != PP_OK_COMPLETIONPENDING)
-// cc.Run(rv);
+// CHECK(rv == PP_OK_COMPLETIONPENDING);
// }
//
// private:
@@ -100,7 +136,8 @@ class CompletionCallback {
// }
//
// void ReadMore() {
-// CompletionCallback cc = factory_.NewCallback(&MyHandler::DidRead);
+// CompletionCallback cc =
+// factory_.NewOptionalCallback(&MyHandler::DidRead);
// int32_t rv = fio_.Read(offset_, buf_, sizeof(buf_),
// cc.pp_completion_callback());
// if (rv != PP_OK_COMPLETIONPENDING)
@@ -145,11 +182,17 @@ class CompletionCallbackFactory {
return object_;
}
- // Allocates a new, single-use CompletionCallback. The CompletionCallback
- // must be run in order for the memory allocated by NewCallback to be freed.
- // If after passing the CompletionCallback to a PPAPI method, the method does
- // not return PP_OK_COMPLETIONPENDING, then you should manually call the
- // CompletionCallback's Run method otherwise memory will be leaked.
+ // Methods for allocating new, single-use CompletionCallbacks.
+ // The CompletionCallback must be run in order for the memory
+ // allocated by the methods to be freed.
+ // NewRequiredCallback() creates callbacks that will always run.
+ // NewOptionalCallback() creates callbacks that might not run if the method
+ // taking them can complete synchronously. Thus, if after passing the
+ // CompletionCallback to a PPAPI method, the method does not return
+ // PP_OK_COMPLETIONPENDING, then you should manually call the
+ // CompletionCallback's Run method, or memory will be leaked.
+ // NewCallback() is equivalent to NewOptionalCallback().
+ // TODO(polina): update this comment when this is no longer true.
template <typename Method>
CompletionCallback NewCallback(Method method) {
@@ -157,6 +200,20 @@ class CompletionCallbackFactory {
return NewCallbackHelper(Dispatcher0<Method>(method));
}
+ template <typename Method>
+ CompletionCallback NewRequiredCallback(Method method) {
+ CompletionCallback cc = NewCallback(method);
+ cc.set_flags(cc.flags() & ~PP_COMPLETIONCALLBACK_FLAG_OPTIONAL);
+ return cc;
+ }
+
+ template <typename Method>
+ CompletionCallback NewOptionalCallback(Method method) {
+ CompletionCallback cc = NewCallback(method);
+ cc.set_flags(cc.flags() | PP_COMPLETIONCALLBACK_FLAG_OPTIONAL);
+ return cc;
+ }
+
// A copy of "a" will be passed to "method" when the completion callback
// runs.
//
@@ -169,6 +226,20 @@ class CompletionCallbackFactory {
return NewCallbackHelper(Dispatcher1<Method, A>(method, a));
}
+ 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;
+ }
+
+ template <typename Method, typename A>
+ CompletionCallback NewOptionalCallback(Method method, const A& a) {
+ CompletionCallback cc = NewCallback(method, a);
+ cc.set_flags(cc.flags() | PP_COMPLETIONCALLBACK_FLAG_OPTIONAL);
+ return cc;
+ }
+
// A copy of "a" and "b" will be passed to "method" when the completion
// callback runs.
//
@@ -181,6 +252,22 @@ class CompletionCallbackFactory {
return NewCallbackHelper(Dispatcher2<Method, A, B>(method, a, b));
}
+ 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;
+ }
+
+ template <typename Method, typename A, typename B>
+ CompletionCallback NewOptionalCallback(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;
+ }
+
private:
class BackPointer {
public:
diff --git a/ppapi/cpp/dev/directory_reader_dev.cc b/ppapi/cpp/dev/directory_reader_dev.cc
index 0b461e0b..9b616ee 100644
--- a/ppapi/cpp/dev/directory_reader_dev.cc
+++ b/ppapi/cpp/dev/directory_reader_dev.cc
@@ -1,4 +1,4 @@
-// Copyright (c) 2010 The Chromium Authors. All rights reserved.
+// Copyright (c) 2011 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.
@@ -35,7 +35,7 @@ DirectoryReader_Dev::DirectoryReader_Dev(const DirectoryReader_Dev& other)
int32_t DirectoryReader_Dev::GetNextEntry(DirectoryEntry_Dev* entry,
const CompletionCallback& cc) {
if (!has_interface<PPB_DirectoryReader_Dev>())
- return PP_ERROR_NOINTERFACE;
+ return cc.MayForce(PP_ERROR_NOINTERFACE);
return get_interface<PPB_DirectoryReader_Dev>()->GetNextEntry(
pp_resource(), &entry->data_, cc.pp_completion_callback());
}
diff --git a/ppapi/cpp/dev/file_chooser_dev.cc b/ppapi/cpp/dev/file_chooser_dev.cc
index 1e63ec9..e0c0e62 100644
--- a/ppapi/cpp/dev/file_chooser_dev.cc
+++ b/ppapi/cpp/dev/file_chooser_dev.cc
@@ -1,4 +1,4 @@
-// Copyright (c) 2010 The Chromium Authors. All rights reserved.
+// Copyright (c) 2011 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.
@@ -36,7 +36,7 @@ FileChooser_Dev::FileChooser_Dev(const FileChooser_Dev& other)
int32_t FileChooser_Dev::Show(const CompletionCallback& cc) {
if (!has_interface<PPB_FileChooser_Dev>())
- return PP_ERROR_NOINTERFACE;
+ return cc.MayForce(PP_ERROR_NOINTERFACE);
return get_interface<PPB_FileChooser_Dev>()->Show(
pp_resource(), cc.pp_completion_callback());
}
diff --git a/ppapi/cpp/dev/file_io_dev.cc b/ppapi/cpp/dev/file_io_dev.cc
index 1fc273b..586de42 100644
--- a/ppapi/cpp/dev/file_io_dev.cc
+++ b/ppapi/cpp/dev/file_io_dev.cc
@@ -1,4 +1,4 @@
-// Copyright (c) 2010 The Chromium Authors. All rights reserved.
+// Copyright (c) 2011 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.
@@ -41,7 +41,7 @@ int32_t FileIO_Dev::Open(const FileRef_Dev& file_ref,
int32_t open_flags,
const CompletionCallback& cc) {
if (!has_interface<PPB_FileIO_Dev>())
- return PP_ERROR_NOINTERFACE;
+ return cc.MayForce(PP_ERROR_NOINTERFACE);
return get_interface<PPB_FileIO_Dev>()->Open(
pp_resource(), file_ref.pp_resource(), open_flags,
cc.pp_completion_callback());
@@ -50,7 +50,7 @@ int32_t FileIO_Dev::Open(const FileRef_Dev& file_ref,
int32_t FileIO_Dev::Query(PP_FileInfo_Dev* result_buf,
const CompletionCallback& cc) {
if (!has_interface<PPB_FileIO_Dev>())
- return PP_ERROR_NOINTERFACE;
+ return cc.MayForce(PP_ERROR_NOINTERFACE);
return get_interface<PPB_FileIO_Dev>()->Query(
pp_resource(), result_buf, cc.pp_completion_callback());
}
@@ -59,7 +59,7 @@ int32_t FileIO_Dev::Touch(PP_Time last_access_time,
PP_Time last_modified_time,
const CompletionCallback& cc) {
if (!has_interface<PPB_FileIO_Dev>())
- return PP_ERROR_NOINTERFACE;
+ return cc.MayForce(PP_ERROR_NOINTERFACE);
return get_interface<PPB_FileIO_Dev>()->Touch(
pp_resource(), last_access_time, last_modified_time,
cc.pp_completion_callback());
@@ -70,7 +70,7 @@ int32_t FileIO_Dev::Read(int64_t offset,
int32_t bytes_to_read,
const CompletionCallback& cc) {
if (!has_interface<PPB_FileIO_Dev>())
- return PP_ERROR_NOINTERFACE;
+ return cc.MayForce(PP_ERROR_NOINTERFACE);
return get_interface<PPB_FileIO_Dev>()->Read(pp_resource(),
offset, buffer, bytes_to_read, cc.pp_completion_callback());
}
@@ -80,7 +80,7 @@ int32_t FileIO_Dev::Write(int64_t offset,
int32_t bytes_to_write,
const CompletionCallback& cc) {
if (!has_interface<PPB_FileIO_Dev>())
- return PP_ERROR_NOINTERFACE;
+ return cc.MayForce(PP_ERROR_NOINTERFACE);
return get_interface<PPB_FileIO_Dev>()->Write(
pp_resource(), offset, buffer, bytes_to_write,
cc.pp_completion_callback());
@@ -89,14 +89,14 @@ int32_t FileIO_Dev::Write(int64_t offset,
int32_t FileIO_Dev::SetLength(int64_t length,
const CompletionCallback& cc) {
if (!has_interface<PPB_FileIO_Dev>())
- return PP_ERROR_NOINTERFACE;
+ return cc.MayForce(PP_ERROR_NOINTERFACE);
return get_interface<PPB_FileIO_Dev>()->SetLength(
pp_resource(), length, cc.pp_completion_callback());
}
int32_t FileIO_Dev::Flush(const CompletionCallback& cc) {
if (!has_interface<PPB_FileIO_Dev>())
- return PP_ERROR_NOINTERFACE;
+ return cc.MayForce(PP_ERROR_NOINTERFACE);
return get_interface<PPB_FileIO_Dev>()->Flush(
pp_resource(), cc.pp_completion_callback());
}
diff --git a/ppapi/cpp/dev/file_ref_dev.cc b/ppapi/cpp/dev/file_ref_dev.cc
index a6a2acf..882adb1 100644
--- a/ppapi/cpp/dev/file_ref_dev.cc
+++ b/ppapi/cpp/dev/file_ref_dev.cc
@@ -1,4 +1,4 @@
-// Copyright (c) 2010 The Chromium Authors. All rights reserved.
+// Copyright (c) 2011 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.
@@ -69,7 +69,7 @@ FileRef_Dev FileRef_Dev::GetParent() const {
int32_t FileRef_Dev::MakeDirectory(const CompletionCallback& cc) {
if (!has_interface<PPB_FileRef_Dev>())
- return PP_ERROR_NOINTERFACE;
+ return cc.MayForce(PP_ERROR_NOINTERFACE);
return get_interface<PPB_FileRef_Dev>()->MakeDirectory(
pp_resource(),
PP_FALSE, // make_ancestors
@@ -79,7 +79,7 @@ int32_t FileRef_Dev::MakeDirectory(const CompletionCallback& cc) {
int32_t FileRef_Dev::MakeDirectoryIncludingAncestors(
const CompletionCallback& cc) {
if (!has_interface<PPB_FileRef_Dev>())
- return PP_ERROR_NOINTERFACE;
+ return cc.MayForce(PP_ERROR_NOINTERFACE);
return get_interface<PPB_FileRef_Dev>()->MakeDirectory(
pp_resource(),
PP_TRUE, // make_ancestors
@@ -90,7 +90,7 @@ int32_t FileRef_Dev::Touch(PP_Time last_access_time,
PP_Time last_modified_time,
const CompletionCallback& cc) {
if (!has_interface<PPB_FileRef_Dev>())
- return PP_ERROR_NOINTERFACE;
+ return cc.MayForce(PP_ERROR_NOINTERFACE);
return get_interface<PPB_FileRef_Dev>()->Touch(
pp_resource(), last_access_time, last_modified_time,
cc.pp_completion_callback());
@@ -98,7 +98,7 @@ int32_t FileRef_Dev::Touch(PP_Time last_access_time,
int32_t FileRef_Dev::Delete(const CompletionCallback& cc) {
if (!has_interface<PPB_FileRef_Dev>())
- return PP_ERROR_NOINTERFACE;
+ return cc.MayForce(PP_ERROR_NOINTERFACE);
return get_interface<PPB_FileRef_Dev>()->Delete(
pp_resource(), cc.pp_completion_callback());
}
@@ -106,7 +106,7 @@ int32_t FileRef_Dev::Delete(const CompletionCallback& cc) {
int32_t FileRef_Dev::Rename(const FileRef_Dev& new_file_ref,
const CompletionCallback& cc) {
if (!has_interface<PPB_FileRef_Dev>())
- return PP_ERROR_NOINTERFACE;
+ return cc.MayForce(PP_ERROR_NOINTERFACE);
return get_interface<PPB_FileRef_Dev>()->Rename(
pp_resource(), new_file_ref.pp_resource(), cc.pp_completion_callback());
}
diff --git a/ppapi/cpp/dev/file_system_dev.cc b/ppapi/cpp/dev/file_system_dev.cc
index 6c25e23..bba49dd 100644
--- a/ppapi/cpp/dev/file_system_dev.cc
+++ b/ppapi/cpp/dev/file_system_dev.cc
@@ -1,4 +1,4 @@
-// Copyright (c) 2010 The Chromium Authors. All rights reserved.
+// Copyright (c) 2011 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.
@@ -32,7 +32,7 @@ FileSystem_Dev::FileSystem_Dev(Instance* instance,
int32_t FileSystem_Dev::Open(int64_t expected_size,
const CompletionCallback& cc) {
if (!has_interface<PPB_FileSystem_Dev>())
- return PP_ERROR_NOINTERFACE;
+ return cc.MayForce(PP_ERROR_NOINTERFACE);
return get_interface<PPB_FileSystem_Dev>()->Open(
pp_resource(), expected_size, cc.pp_completion_callback());
}
diff --git a/ppapi/cpp/dev/surface_3d_dev.cc b/ppapi/cpp/dev/surface_3d_dev.cc
index eab8149..9bc1430 100644
--- a/ppapi/cpp/dev/surface_3d_dev.cc
+++ b/ppapi/cpp/dev/surface_3d_dev.cc
@@ -1,4 +1,4 @@
-// Copyright (c) 2010 The Chromium Authors. All rights reserved.
+// Copyright (c) 2011 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.
@@ -40,7 +40,7 @@ Surface3D_Dev::Surface3D_Dev(const Instance& instance,
int32_t Surface3D_Dev::SwapBuffers(const CompletionCallback& cc) const {
if (!has_interface<PPB_Surface3D_Dev>())
- return PP_ERROR_NOINTERFACE;
+ return cc.MayForce(PP_ERROR_NOINTERFACE);
return get_interface<PPB_Surface3D_Dev>()->SwapBuffers(
pp_resource(),
diff --git a/ppapi/cpp/dev/transport_dev.cc b/ppapi/cpp/dev/transport_dev.cc
index 0b62829..cdbbd8c 100644
--- a/ppapi/cpp/dev/transport_dev.cc
+++ b/ppapi/cpp/dev/transport_dev.cc
@@ -38,7 +38,7 @@ bool Transport_Dev::IsWritable() {
int32_t Transport_Dev::Connect(const CompletionCallback& cc) {
if (!has_interface<PPB_Transport_Dev>())
- return PP_ERROR_NOINTERFACE;
+ return cc.MayForce(PP_ERROR_NOINTERFACE);
return get_interface<PPB_Transport_Dev>()->Connect(
pp_resource(), cc.pp_completion_callback());
}
@@ -46,7 +46,7 @@ int32_t Transport_Dev::Connect(const CompletionCallback& cc) {
int32_t Transport_Dev::GetNextAddress(Var* address,
const CompletionCallback& cc) {
if (!has_interface<PPB_Transport_Dev>())
- return PP_ERROR_NOINTERFACE;
+ return cc.MayForce(PP_ERROR_NOINTERFACE);
PP_Var temp_address = PP_MakeUndefined();
int32_t ret_val = get_interface<PPB_Transport_Dev>()->GetNextAddress(
pp_resource(), &temp_address, cc.pp_completion_callback());
@@ -64,7 +64,7 @@ int32_t Transport_Dev::ReceiveRemoteAddress(const pp::Var& address) {
int32_t Transport_Dev::Recv(void* data, uint32_t len,
const CompletionCallback& cc) {
if (!has_interface<PPB_Transport_Dev>())
- return PP_ERROR_NOINTERFACE;
+ return cc.MayForce(PP_ERROR_NOINTERFACE);
return get_interface<PPB_Transport_Dev>()->Recv(
pp_resource(), data, len, cc.pp_completion_callback());
}
@@ -72,7 +72,7 @@ int32_t Transport_Dev::Recv(void* data, uint32_t len,
int32_t Transport_Dev::Send(const void* data, uint32_t len,
const CompletionCallback& cc) {
if (!has_interface<PPB_Transport_Dev>())
- return PP_ERROR_NOINTERFACE;
+ return cc.MayForce(PP_ERROR_NOINTERFACE);
return get_interface<PPB_Transport_Dev>()->Send(
pp_resource(), data, len, cc.pp_completion_callback());
}
diff --git a/ppapi/cpp/dev/video_decoder_dev.cc b/ppapi/cpp/dev/video_decoder_dev.cc
index c8d6ff4..91e86d3 100644
--- a/ppapi/cpp/dev/video_decoder_dev.cc
+++ b/ppapi/cpp/dev/video_decoder_dev.cc
@@ -12,6 +12,7 @@
#include "ppapi/cpp/instance.h"
#include "ppapi/cpp/module.h"
#include "ppapi/cpp/module_impl.h"
+#include "ppapi/thunk/common.h"
namespace pp {
@@ -39,7 +40,7 @@ int32_t VideoDecoder_Dev::Initialize(const PP_VideoConfigElement* config,
const Context3D_Dev& context,
CompletionCallback callback) {
if (!has_interface<PPB_VideoDecoder_Dev>())
- return PP_ERROR_NOINTERFACE;
+ return callback.MayForce(PP_ERROR_NOINTERFACE);
return get_interface<PPB_VideoDecoder_Dev>()->Initialize(
pp_resource(), context.pp_resource(), config,
callback.pp_completion_callback());
@@ -77,9 +78,7 @@ int32_t VideoDecoder_Dev::Decode(
const PP_VideoBitstreamBuffer_Dev& bitstream_buffer,
CompletionCallback callback) {
if (!has_interface<PPB_VideoDecoder_Dev>())
- return PP_ERROR_NOINTERFACE;
- if (!pp_resource())
- return PP_ERROR_BADRESOURCE;
+ return callback.MayForce(PP_ERROR_NOINTERFACE);
return get_interface<PPB_VideoDecoder_Dev>()->Decode(
pp_resource(), &bitstream_buffer, callback.pp_completion_callback());
}
@@ -93,18 +92,14 @@ void VideoDecoder_Dev::ReusePictureBuffer(int32_t picture_buffer_id) {
int32_t VideoDecoder_Dev::Flush(CompletionCallback callback) {
if (!has_interface<PPB_VideoDecoder_Dev>())
- return PP_ERROR_NOINTERFACE;
- if (!pp_resource())
- return PP_ERROR_BADRESOURCE;
+ return callback.MayForce(PP_ERROR_NOINTERFACE);
return get_interface<PPB_VideoDecoder_Dev>()->Flush(
pp_resource(), callback.pp_completion_callback());
}
int32_t VideoDecoder_Dev::Abort(CompletionCallback callback) {
if (!has_interface<PPB_VideoDecoder_Dev>())
- return PP_ERROR_NOINTERFACE;
- if (!pp_resource())
- return PP_ERROR_BADRESOURCE;
+ return callback.MayForce(PP_ERROR_NOINTERFACE);
return get_interface<PPB_VideoDecoder_Dev>()->Abort(
pp_resource(), callback.pp_completion_callback());
}
diff --git a/ppapi/cpp/file_io.cc b/ppapi/cpp/file_io.cc
index ca6760b..85c3051 100644
--- a/ppapi/cpp/file_io.cc
+++ b/ppapi/cpp/file_io.cc
@@ -41,7 +41,7 @@ int32_t FileIO::Open(const FileRef& file_ref,
int32_t open_flags,
const CompletionCallback& cc) {
if (!has_interface<PPB_FileIO>())
- return PP_ERROR_NOINTERFACE;
+ return cc.MayForce(PP_ERROR_NOINTERFACE);
return get_interface<PPB_FileIO>()->Open(
pp_resource(), file_ref.pp_resource(), open_flags,
cc.pp_completion_callback());
@@ -50,7 +50,7 @@ int32_t FileIO::Open(const FileRef& file_ref,
int32_t FileIO::Query(PP_FileInfo* result_buf,
const CompletionCallback& cc) {
if (!has_interface<PPB_FileIO>())
- return PP_ERROR_NOINTERFACE;
+ return cc.MayForce(PP_ERROR_NOINTERFACE);
return get_interface<PPB_FileIO>()->Query(
pp_resource(), result_buf, cc.pp_completion_callback());
}
@@ -59,7 +59,7 @@ int32_t FileIO::Touch(PP_Time last_access_time,
PP_Time last_modified_time,
const CompletionCallback& cc) {
if (!has_interface<PPB_FileIO>())
- return PP_ERROR_NOINTERFACE;
+ return cc.MayForce(PP_ERROR_NOINTERFACE);
return get_interface<PPB_FileIO>()->Touch(
pp_resource(), last_access_time, last_modified_time,
cc.pp_completion_callback());
@@ -70,7 +70,7 @@ int32_t FileIO::Read(int64_t offset,
int32_t bytes_to_read,
const CompletionCallback& cc) {
if (!has_interface<PPB_FileIO>())
- return PP_ERROR_NOINTERFACE;
+ return cc.MayForce(PP_ERROR_NOINTERFACE);
return get_interface<PPB_FileIO>()->Read(pp_resource(),
offset, buffer, bytes_to_read, cc.pp_completion_callback());
}
@@ -80,7 +80,7 @@ int32_t FileIO::Write(int64_t offset,
int32_t bytes_to_write,
const CompletionCallback& cc) {
if (!has_interface<PPB_FileIO>())
- return PP_ERROR_NOINTERFACE;
+ return cc.MayForce(PP_ERROR_NOINTERFACE);
return get_interface<PPB_FileIO>()->Write(
pp_resource(), offset, buffer, bytes_to_write,
cc.pp_completion_callback());
@@ -89,14 +89,14 @@ int32_t FileIO::Write(int64_t offset,
int32_t FileIO::SetLength(int64_t length,
const CompletionCallback& cc) {
if (!has_interface<PPB_FileIO>())
- return PP_ERROR_NOINTERFACE;
+ return cc.MayForce(PP_ERROR_NOINTERFACE);
return get_interface<PPB_FileIO>()->SetLength(
pp_resource(), length, cc.pp_completion_callback());
}
int32_t FileIO::Flush(const CompletionCallback& cc) {
if (!has_interface<PPB_FileIO>())
- return PP_ERROR_NOINTERFACE;
+ return cc.MayForce(PP_ERROR_NOINTERFACE);
return get_interface<PPB_FileIO>()->Flush(
pp_resource(), cc.pp_completion_callback());
}
diff --git a/ppapi/cpp/file_ref.cc b/ppapi/cpp/file_ref.cc
index fdae3d8..ed98974 100644
--- a/ppapi/cpp/file_ref.cc
+++ b/ppapi/cpp/file_ref.cc
@@ -69,7 +69,7 @@ FileRef FileRef::GetParent() const {
int32_t FileRef::MakeDirectory(const CompletionCallback& cc) {
if (!has_interface<PPB_FileRef>())
- return PP_ERROR_NOINTERFACE;
+ return cc.MayForce(PP_ERROR_NOINTERFACE);
return get_interface<PPB_FileRef>()->MakeDirectory(
pp_resource(),
PP_FALSE, // make_ancestors
@@ -79,7 +79,7 @@ int32_t FileRef::MakeDirectory(const CompletionCallback& cc) {
int32_t FileRef::MakeDirectoryIncludingAncestors(
const CompletionCallback& cc) {
if (!has_interface<PPB_FileRef>())
- return PP_ERROR_NOINTERFACE;
+ return cc.MayForce(PP_ERROR_NOINTERFACE);
return get_interface<PPB_FileRef>()->MakeDirectory(
pp_resource(),
PP_TRUE, // make_ancestors
@@ -90,7 +90,7 @@ int32_t FileRef::Touch(PP_Time last_access_time,
PP_Time last_modified_time,
const CompletionCallback& cc) {
if (!has_interface<PPB_FileRef>())
- return PP_ERROR_NOINTERFACE;
+ return cc.MayForce(PP_ERROR_NOINTERFACE);
return get_interface<PPB_FileRef>()->Touch(
pp_resource(), last_access_time, last_modified_time,
cc.pp_completion_callback());
@@ -98,7 +98,7 @@ int32_t FileRef::Touch(PP_Time last_access_time,
int32_t FileRef::Delete(const CompletionCallback& cc) {
if (!has_interface<PPB_FileRef>())
- return PP_ERROR_NOINTERFACE;
+ return cc.MayForce(PP_ERROR_NOINTERFACE);
return get_interface<PPB_FileRef>()->Delete(
pp_resource(), cc.pp_completion_callback());
}
@@ -106,7 +106,7 @@ int32_t FileRef::Delete(const CompletionCallback& cc) {
int32_t FileRef::Rename(const FileRef& new_file_ref,
const CompletionCallback& cc) {
if (!has_interface<PPB_FileRef>())
- return PP_ERROR_NOINTERFACE;
+ return cc.MayForce(PP_ERROR_NOINTERFACE);
return get_interface<PPB_FileRef>()->Rename(
pp_resource(), new_file_ref.pp_resource(), cc.pp_completion_callback());
}
diff --git a/ppapi/cpp/file_system.cc b/ppapi/cpp/file_system.cc
index c5312bb..b5ee1f3 100644
--- a/ppapi/cpp/file_system.cc
+++ b/ppapi/cpp/file_system.cc
@@ -32,7 +32,7 @@ FileSystem::FileSystem(Instance* instance,
int32_t FileSystem::Open(int64_t expected_size,
const CompletionCallback& cc) {
if (!has_interface<PPB_FileSystem>())
- return PP_ERROR_NOINTERFACE;
+ return cc.MayForce(PP_ERROR_NOINTERFACE);
return get_interface<PPB_FileSystem>()->Open(
pp_resource(), expected_size, cc.pp_completion_callback());
}
diff --git a/ppapi/cpp/graphics_2d.cc b/ppapi/cpp/graphics_2d.cc
index 0db5862..6a109f0 100644
--- a/ppapi/cpp/graphics_2d.cc
+++ b/ppapi/cpp/graphics_2d.cc
@@ -1,4 +1,4 @@
-// Copyright (c) 2010 The Chromium Authors. All rights reserved.
+// Copyright (c) 2011 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.
@@ -100,7 +100,7 @@ void Graphics2D::ReplaceContents(ImageData* image) {
int32_t Graphics2D::Flush(const CompletionCallback& cc) {
if (!has_interface<PPB_Graphics2D>())
- return PP_ERROR_NOINTERFACE;
+ return cc.MayForce(PP_ERROR_NOINTERFACE);
return get_interface<PPB_Graphics2D>()->Flush(pp_resource(),
cc.pp_completion_callback());
}
diff --git a/ppapi/cpp/paint_manager.cc b/ppapi/cpp/paint_manager.cc
index bc02016..23f66d5 100644
--- a/ppapi/cpp/paint_manager.cc
+++ b/ppapi/cpp/paint_manager.cc
@@ -153,7 +153,7 @@ void PaintManager::DoPaint() {
if (client_->OnPaint(graphics_, update.paint_rects, update.paint_bounds)) {
// Something was painted, schedule a flush.
int32_t result = graphics_.Flush(
- callback_factory_.NewCallback(&PaintManager::OnFlushComplete));
+ callback_factory_.NewOptionalCallback(&PaintManager::OnFlushComplete));
// If you trigger this assertion, then your plugin has called Flush()
// manually. When using the PaintManager, you should not call Flush, it
diff --git a/ppapi/cpp/private/flash_menu.cc b/ppapi/cpp/private/flash_menu.cc
index 8596fc9..5b78eec 100644
--- a/ppapi/cpp/private/flash_menu.cc
+++ b/ppapi/cpp/private/flash_menu.cc
@@ -36,7 +36,7 @@ int32_t Menu::Show(const Point& location,
int32_t* selected_id,
const CompletionCallback& cc) {
if (!has_interface<PPB_Flash_Menu>())
- return PP_ERROR_NOINTERFACE;
+ return cc.MayForce(PP_ERROR_NOINTERFACE);
return get_interface<PPB_Flash_Menu>()->Show(
pp_resource(),
&location.pp_point(),
diff --git a/ppapi/cpp/private/flash_net_connector.cc b/ppapi/cpp/private/flash_net_connector.cc
index 8896114..05b26f2 100644
--- a/ppapi/cpp/private/flash_net_connector.cc
+++ b/ppapi/cpp/private/flash_net_connector.cc
@@ -38,7 +38,7 @@ int32_t NetConnector::ConnectTcp(const char* host,
PP_Flash_NetAddress* remote_addr_out,
const CompletionCallback& cc) {
if (!has_interface<PPB_Flash_NetConnector>())
- return PP_ERROR_NOINTERFACE;
+ return cc.MayForce(PP_ERROR_NOINTERFACE);
return get_interface<PPB_Flash_NetConnector>()->ConnectTcp(
pp_resource(),
host, port,
@@ -52,7 +52,7 @@ int32_t NetConnector::ConnectTcpAddress(const PP_Flash_NetAddress* addr,
PP_Flash_NetAddress* remote_addr_out,
const CompletionCallback& cc) {
if (!has_interface<PPB_Flash_NetConnector>())
- return PP_ERROR_NOINTERFACE;
+ return cc.MayForce(PP_ERROR_NOINTERFACE);
return get_interface<PPB_Flash_NetConnector>()->ConnectTcpAddress(
pp_resource(),
addr,
diff --git a/ppapi/cpp/url_loader.cc b/ppapi/cpp/url_loader.cc
index cf05f3c..65aa1f3 100644
--- a/ppapi/cpp/url_loader.cc
+++ b/ppapi/cpp/url_loader.cc
@@ -1,4 +1,4 @@
-// Copyright (c) 2010 The Chromium Authors. All rights reserved.
+// Copyright (c) 2011 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.
@@ -49,7 +49,7 @@ URLLoader::URLLoader(const URLLoader& other) : Resource(other) {
int32_t URLLoader::Open(const URLRequestInfo& request_info,
const CompletionCallback& cc) {
if (!has_interface<PPB_URLLoader>())
- return PP_ERROR_NOINTERFACE;
+ return cc.MayForce(PP_ERROR_NOINTERFACE);
return get_interface<PPB_URLLoader>()->Open(pp_resource(),
request_info.pp_resource(),
cc.pp_completion_callback());
@@ -57,7 +57,7 @@ int32_t URLLoader::Open(const URLRequestInfo& request_info,
int32_t URLLoader::FollowRedirect(const CompletionCallback& cc) {
if (!has_interface<PPB_URLLoader>())
- return PP_ERROR_NOINTERFACE;
+ return cc.MayForce(PP_ERROR_NOINTERFACE);
return get_interface<PPB_URLLoader>()->FollowRedirect(
pp_resource(), cc.pp_completion_callback());
}
@@ -92,14 +92,14 @@ int32_t URLLoader::ReadResponseBody(void* buffer,
int32_t bytes_to_read,
const CompletionCallback& cc) {
if (!has_interface<PPB_URLLoader>())
- return PP_ERROR_NOINTERFACE;
+ return cc.MayForce(PP_ERROR_NOINTERFACE);
return get_interface<PPB_URLLoader>()->ReadResponseBody(
pp_resource(), buffer, bytes_to_read, cc.pp_completion_callback());
}
int32_t URLLoader::FinishStreamingToFile(const CompletionCallback& cc) {
if (!has_interface<PPB_URLLoader>())
- return PP_ERROR_NOINTERFACE;
+ return cc.MayForce(PP_ERROR_NOINTERFACE);
return get_interface<PPB_URLLoader>()->FinishStreamingToFile(
pp_resource(), cc.pp_completion_callback());
}
diff --git a/ppapi/cpp/url_loader.h b/ppapi/cpp/url_loader.h
index 6db80f96..a83f44a 100644
--- a/ppapi/cpp/url_loader.h
+++ b/ppapi/cpp/url_loader.h
@@ -1,4 +1,4 @@
-// Copyright (c) 2010 The Chromium Authors. All rights reserved.
+// Copyright (c) 2011 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.
@@ -34,7 +34,7 @@ class URLResponseInfo;
// }
// private:
// CompletionCallback* NewCallback() {
-// return factory_.NewCallback(&MyHandler::DidCompleteIO);
+// return factory_.NewOptionalCallback(&MyHandler::DidCompleteIO);
// }
// URLRequestInfo MakeRequest(const char* url) {
// URLRequestInfo request;
diff --git a/ppapi/example/example.cc b/ppapi/example/example.cc
index 5dc3842..93696f0 100644
--- a/ppapi/example/example.cc
+++ b/ppapi/example/example.cc
@@ -107,7 +107,7 @@ class MyFetcher {
client_ = client;
pp::CompletionCallback callback =
- callback_factory_.NewCallback(&MyFetcher::DidOpen);
+ callback_factory_.NewOptionalCallback(&MyFetcher::DidOpen);
int rv = loader_.Open(request, callback);
if (rv != PP_OK_COMPLETIONPENDING)
callback.Run(rv);
@@ -124,7 +124,7 @@ class MyFetcher {
private:
void ReadMore() {
pp::CompletionCallback callback =
- callback_factory_.NewCallback(&MyFetcher::DidRead);
+ callback_factory_.NewOptionalCallback(&MyFetcher::DidRead);
int rv = loader_.ReadResponseBody(buf_, sizeof(buf_), callback);
if (rv != PP_OK_COMPLETIONPENDING)
callback.Run(rv);
diff --git a/ppapi/ppapi_shared.gypi b/ppapi/ppapi_shared.gypi
index 11440a1..0b47f83 100644
--- a/ppapi/ppapi_shared.gypi
+++ b/ppapi/ppapi_shared.gypi
@@ -50,6 +50,8 @@
'shared_impl/webkit_forwarding.cc',
'shared_impl/webkit_forwarding.h',
+ 'thunk/common.h',
+ 'thunk/common.cc',
'thunk/enter.h',
'thunk/ppb_audio_api.h',
'thunk/ppb_audio_config_api.h',
diff --git a/ppapi/proxy/ppb_audio_proxy.cc b/ppapi/proxy/ppb_audio_proxy.cc
index 22ddddd..76f3046 100644
--- a/ppapi/proxy/ppb_audio_proxy.cc
+++ b/ppapi/proxy/ppb_audio_proxy.cc
@@ -207,7 +207,7 @@ void PPB_Audio_Proxy::OnMsgCreate(PP_Instance instance_id,
return;
// Initiate opening the audio object.
- CompletionCallback callback = callback_factory_.NewCallback(
+ CompletionCallback callback = callback_factory_.NewOptionalCallback(
&PPB_Audio_Proxy::AudioChannelConnected, *result);
int32_t open_error = trusted_audio.object()->OpenTrusted(
audio_config_res, callback.pp_completion_callback());
diff --git a/ppapi/proxy/ppb_broker_proxy.cc b/ppapi/proxy/ppb_broker_proxy.cc
index fd789de..37f8ba0 100644
--- a/ppapi/proxy/ppb_broker_proxy.cc
+++ b/ppapi/proxy/ppb_broker_proxy.cc
@@ -204,7 +204,7 @@ void PPB_Broker_Proxy::OnMsgCreate(PP_Instance instance,
}
void PPB_Broker_Proxy::OnMsgConnect(const HostResource& broker) {
- CompletionCallback callback = callback_factory_.NewCallback(
+ CompletionCallback callback = callback_factory_.NewOptionalCallback(
&PPB_Broker_Proxy::ConnectCompleteInHost, broker);
int32_t result = ppb_broker_target()->Connect(
diff --git a/ppapi/proxy/ppb_file_chooser_proxy.cc b/ppapi/proxy/ppb_file_chooser_proxy.cc
index 38bc058..cda175f 100644
--- a/ppapi/proxy/ppb_file_chooser_proxy.cc
+++ b/ppapi/proxy/ppb_file_chooser_proxy.cc
@@ -194,7 +194,7 @@ void PPB_FileChooser_Proxy::OnMsgCreate(PP_Instance instance,
}
void PPB_FileChooser_Proxy::OnMsgShow(const HostResource& chooser) {
- CompletionCallback callback = callback_factory_.NewCallback(
+ CompletionCallback callback = callback_factory_.NewOptionalCallback(
&PPB_FileChooser_Proxy::OnShowCallback, chooser);
int32_t result = ppb_file_chooser_target()->Show(
diff --git a/ppapi/proxy/ppb_file_system_proxy.cc b/ppapi/proxy/ppb_file_system_proxy.cc
index c6b7caa..b95e0b9 100644
--- a/ppapi/proxy/ppb_file_system_proxy.cc
+++ b/ppapi/proxy/ppb_file_system_proxy.cc
@@ -178,7 +178,7 @@ void PPB_FileSystem_Proxy::OnMsgOpen(const HostResource& host_resource,
if (enter.failed())
return;
- CompletionCallback callback = callback_factory_.NewCallback(
+ CompletionCallback callback = callback_factory_.NewOptionalCallback(
&PPB_FileSystem_Proxy::OpenCompleteInHost, host_resource);
int32_t result = enter.object()->Open(expected_size,
callback.pp_completion_callback());
diff --git a/ppapi/proxy/ppb_flash_menu_proxy.cc b/ppapi/proxy/ppb_flash_menu_proxy.cc
index 0087700..c42c10e 100644
--- a/ppapi/proxy/ppb_flash_menu_proxy.cc
+++ b/ppapi/proxy/ppb_flash_menu_proxy.cc
@@ -162,7 +162,7 @@ void PPB_Flash_Menu_Proxy::OnMsgShow(const HostResource& menu,
const PP_Point& location) {
ShowRequest* request = new ShowRequest;
request->menu = menu;
- CompletionCallback callback = callback_factory_.NewCallback(
+ CompletionCallback callback = callback_factory_.NewOptionalCallback(
&PPB_Flash_Menu_Proxy::SendShowACKToPlugin, request);
EnterHostFromHostResource<PPB_Flash_Menu_API> enter(menu);
diff --git a/ppapi/proxy/ppb_flash_net_connector_proxy.cc b/ppapi/proxy/ppb_flash_net_connector_proxy.cc
index 8a5aa41..ba2c218 100644
--- a/ppapi/proxy/ppb_flash_net_connector_proxy.cc
+++ b/ppapi/proxy/ppb_flash_net_connector_proxy.cc
@@ -265,7 +265,7 @@ void PPB_Flash_NetConnector_Proxy::OnMsgConnectTcp(
const std::string& host,
uint16_t port) {
ConnectCallbackInfo* info = new ConnectCallbackInfo(resource);
- CompletionCallback callback = callback_factory_.NewCallback(
+ CompletionCallback callback = callback_factory_.NewOptionalCallback(
&PPB_Flash_NetConnector_Proxy::OnCompleteCallbackInHost, info);
EnterHostFromHostResource<PPB_Flash_NetConnector_API> enter(resource);
@@ -283,7 +283,7 @@ void PPB_Flash_NetConnector_Proxy::OnMsgConnectTcpAddress(
const HostResource& resource,
const std::string& net_address_as_string) {
ConnectCallbackInfo* info = new ConnectCallbackInfo(resource);
- CompletionCallback callback = callback_factory_.NewCallback(
+ CompletionCallback callback = callback_factory_.NewOptionalCallback(
&PPB_Flash_NetConnector_Proxy::OnCompleteCallbackInHost, info);
PP_Flash_NetAddress net_address;
diff --git a/ppapi/proxy/ppb_graphics_2d_proxy.cc b/ppapi/proxy/ppb_graphics_2d_proxy.cc
index 8027956..0f8a247 100644
--- a/ppapi/proxy/ppb_graphics_2d_proxy.cc
+++ b/ppapi/proxy/ppb_graphics_2d_proxy.cc
@@ -240,7 +240,7 @@ void PPB_Graphics2D_Proxy::OnMsgReplaceContents(
}
void PPB_Graphics2D_Proxy::OnMsgFlush(const HostResource& graphics_2d) {
- CompletionCallback callback = callback_factory_.NewCallback(
+ CompletionCallback callback = callback_factory_.NewOptionalCallback(
&PPB_Graphics2D_Proxy::SendFlushACKToPlugin, graphics_2d);
int32_t result = ppb_graphics_2d_target()->Flush(
graphics_2d.host_resource(), callback.pp_completion_callback());
diff --git a/ppapi/proxy/ppb_surface_3d_proxy.cc b/ppapi/proxy/ppb_surface_3d_proxy.cc
index 053fc01..c0288d0 100644
--- a/ppapi/proxy/ppb_surface_3d_proxy.cc
+++ b/ppapi/proxy/ppb_surface_3d_proxy.cc
@@ -177,7 +177,7 @@ void PPB_Surface3D_Proxy::OnMsgCreate(PP_Instance instance,
}
void PPB_Surface3D_Proxy::OnMsgSwapBuffers(const HostResource& surface_3d) {
- CompletionCallback callback = callback_factory_.NewCallback(
+ CompletionCallback callback = callback_factory_.NewOptionalCallback(
&PPB_Surface3D_Proxy::SendSwapBuffersACKToPlugin, surface_3d);
EnterHostFromHostResource<PPB_Surface3D_API> enter(surface_3d);
diff --git a/ppapi/proxy/ppb_url_loader_proxy.cc b/ppapi/proxy/ppb_url_loader_proxy.cc
index 304e0e1..b2d6276 100644
--- a/ppapi/proxy/ppb_url_loader_proxy.cc
+++ b/ppapi/proxy/ppb_url_loader_proxy.cc
@@ -517,7 +517,7 @@ void PPB_URLLoader_Proxy::OnMsgReadResponseBody(
// TODO(brettw) have a way to check for out-of-memory.
info->read_buffer.resize(bytes_to_read);
- CompletionCallback callback = callback_factory_.NewCallback(
+ CompletionCallback callback = callback_factory_.NewOptionalCallback(
&PPB_URLLoader_Proxy::OnReadCallback, info);
EnterHostFromHostResource<PPB_URLLoader_API> enter(loader);
diff --git a/ppapi/tests/arch_dependent_sizes_32.h b/ppapi/tests/arch_dependent_sizes_32.h
index f797494..34b6d86 100644
--- a/ppapi/tests/arch_dependent_sizes_32.h
+++ b/ppapi/tests/arch_dependent_sizes_32.h
@@ -15,7 +15,7 @@ PP_COMPILE_ASSERT_SIZE_IN_BYTES(GLintptr, 4);
PP_COMPILE_ASSERT_SIZE_IN_BYTES(GLsizeiptr, 4);
PP_COMPILE_ASSERT_SIZE_IN_BYTES(PP_CompletionCallback_Func, 4);
PP_COMPILE_ASSERT_SIZE_IN_BYTES(PP_URLLoaderTrusted_StatusCallback, 4);
-PP_COMPILE_ASSERT_STRUCT_SIZE_IN_BYTES(PP_CompletionCallback, 8);
+PP_COMPILE_ASSERT_STRUCT_SIZE_IN_BYTES(PP_CompletionCallback, 12);
PP_COMPILE_ASSERT_STRUCT_SIZE_IN_BYTES(PP_FileChooserOptions_Dev, 8);
PP_COMPILE_ASSERT_STRUCT_SIZE_IN_BYTES(PP_Picture_Dev, 24);
PP_COMPILE_ASSERT_STRUCT_SIZE_IN_BYTES(PP_VideoBitstreamBuffer_Dev, 12);
diff --git a/ppapi/tests/arch_dependent_sizes_64.h b/ppapi/tests/arch_dependent_sizes_64.h
index 378c5b3..302938a 100644
--- a/ppapi/tests/arch_dependent_sizes_64.h
+++ b/ppapi/tests/arch_dependent_sizes_64.h
@@ -15,7 +15,7 @@ PP_COMPILE_ASSERT_SIZE_IN_BYTES(GLintptr, 8);
PP_COMPILE_ASSERT_SIZE_IN_BYTES(GLsizeiptr, 8);
PP_COMPILE_ASSERT_SIZE_IN_BYTES(PP_CompletionCallback_Func, 8);
PP_COMPILE_ASSERT_SIZE_IN_BYTES(PP_URLLoaderTrusted_StatusCallback, 8);
-PP_COMPILE_ASSERT_STRUCT_SIZE_IN_BYTES(PP_CompletionCallback, 16);
+PP_COMPILE_ASSERT_STRUCT_SIZE_IN_BYTES(PP_CompletionCallback, 24);
PP_COMPILE_ASSERT_STRUCT_SIZE_IN_BYTES(PP_FileChooserOptions_Dev, 16);
PP_COMPILE_ASSERT_STRUCT_SIZE_IN_BYTES(PP_Picture_Dev, 24);
PP_COMPILE_ASSERT_STRUCT_SIZE_IN_BYTES(PP_VideoBitstreamBuffer_Dev, 12);
diff --git a/ppapi/tests/test_case.cc b/ppapi/tests/test_case.cc
index ec9f088..1d91ef5 100644
--- a/ppapi/tests/test_case.cc
+++ b/ppapi/tests/test_case.cc
@@ -11,7 +11,8 @@
TestCase::TestCase(TestingInstance* instance)
: instance_(instance),
- testing_interface_(NULL) {
+ testing_interface_(NULL),
+ force_async_(false) {
}
TestCase::~TestCase() {
diff --git a/ppapi/tests/test_case.h b/ppapi/tests/test_case.h
index 5e77d0d..5ec4435 100644
--- a/ppapi/tests/test_case.h
+++ b/ppapi/tests/test_case.h
@@ -69,6 +69,9 @@ class TestCase {
// NULL unless InitTestingInterface is called.
const PPB_Testing_Dev* testing_interface_;
+ // Force asynchronous completion of any operation taking a callback.
+ bool force_async_;
+
private:
// Holds the test object, if any was retrieved from CreateTestObject.
pp::Var test_object_;
@@ -114,10 +117,22 @@ class TestCaseFactory {
// Helper macro for calling functions implementing specific tests in the
// RunTest function. This assumes the function name is TestFoo where Foo is the
-// test name,
+// test |name|.
#define RUN_TEST(name) \
+ force_async_ = false; \
instance_->LogTest(#name, Test##name());
+// Like RUN_TEST above but forces functions taking callbacks to complete
+// asynchronously on success or error.
+#define RUN_TEST_FORCEASYNC(name) \
+ force_async_ = true; \
+ instance_->LogTest(#name"ForceAsync", Test##name());
+
+#define RUN_TEST_FORCEASYNC_AND_NOT(name) \
+ RUN_TEST_FORCEASYNC(name); \
+ RUN_TEST(name);
+
+
// Helper macros for checking values in tests, and returning a location
// description of the test fails.
#define ASSERT_TRUE(cmd) \
diff --git a/ppapi/tests/test_directory_reader.cc b/ppapi/tests/test_directory_reader.cc
index 91996f3..874abcb 100644
--- a/ppapi/tests/test_directory_reader.cc
+++ b/ppapi/tests/test_directory_reader.cc
@@ -80,10 +80,12 @@ void TestDirectoryReader::RunTest() {
}
std::string TestDirectoryReader::TestGetNextFile() {
- TestCompletionCallback callback(instance_->pp_instance());
+ TestCompletionCallback callback(instance_->pp_instance(), force_async_);
pp::FileSystem_Dev file_system(
instance_, PP_FILESYSTEMTYPE_LOCALTEMPORARY);
int32_t rv = file_system.Open(1024, callback);
+ if (force_async_ && rv != PP_OK_COMPLETIONPENDING)
+ return ReportError("FileSystem::Open force_async", rv);
if (rv == PP_OK_COMPLETIONPENDING)
rv = callback.WaitForResult();
if (rv != PP_OK)
@@ -100,6 +102,8 @@ std::string TestDirectoryReader::TestGetNextFile() {
return ReportError("DeleteDirectoryRecursively", rv);
rv = test_dir.MakeDirectory(callback);
+ if (force_async_ && rv != PP_OK_COMPLETIONPENDING)
+ return ReportError("FileRef::MakeDirectory force_async", rv);
if (rv == PP_OK_COMPLETIONPENDING)
rv = callback.WaitForResult();
if (rv != PP_OK)
@@ -113,6 +117,8 @@ std::string TestDirectoryReader::TestGetNextFile() {
pp::FileIO_Dev file_io(instance_);
rv = file_io.Open(file_ref, PP_FILEOPENFLAG_CREATE, callback);
+ if (force_async_ && rv != PP_OK_COMPLETIONPENDING)
+ return ReportError("FileIO::Open force_async", rv);
if (rv == PP_OK_COMPLETIONPENDING)
rv = callback.WaitForResult();
if (rv != PP_OK)
@@ -128,6 +134,8 @@ std::string TestDirectoryReader::TestGetNextFile() {
pp::FileRef_Dev file_ref(file_system, buffer);
rv = file_ref.MakeDirectory(callback);
+ if (force_async_ && rv != PP_OK_COMPLETIONPENDING)
+ return ReportError("FileRef::MakeDirectory force_async", rv);
if (rv == PP_OK_COMPLETIONPENDING)
rv = callback.WaitForResult();
if (rv != PP_OK)
@@ -144,6 +152,8 @@ std::string TestDirectoryReader::TestGetNextFile() {
pp::DirectoryEntry_Dev entry;
do {
rv = directory_reader.GetNextEntry(&entry, callback);
+ if (force_async_ && rv != PP_OK_COMPLETIONPENDING)
+ return ReportError("DirectoryReader::GetNextEntry force_async", rv);
if (rv == PP_OK_COMPLETIONPENDING)
rv = callback.WaitForResult();
if (rv != PP_OK)
@@ -188,6 +198,8 @@ std::string TestDirectoryReader::TestGetNextFile() {
callback.reset_run_count();
// Note that the directory reader will be deleted immediately.
rv = pp::DirectoryReader_Dev(test_dir).GetNextEntry(&entry, callback);
+ if (force_async_ && rv != PP_OK_COMPLETIONPENDING)
+ return ReportError("DirectoryReader::GetNextEntry force_async", rv);
if (callback.run_count() > 0)
return "DirectoryReader::GetNextEntry ran callback synchronously.";
diff --git a/ppapi/tests/test_file_io.cc b/ppapi/tests/test_file_io.cc
index 423016a..c6c2d63 100644
--- a/ppapi/tests/test_file_io.cc
+++ b/ppapi/tests/test_file_io.cc
@@ -111,21 +111,25 @@ bool TestFileIO::Init() {
}
void TestFileIO::RunTest() {
- RUN_TEST(Open);
- RUN_TEST(ReadWriteSetLength);
- RUN_TEST(TouchQuery);
- RUN_TEST(AbortCalls);
+ RUN_TEST_FORCEASYNC_AND_NOT(Open);
+ RUN_TEST_FORCEASYNC_AND_NOT(ReadWriteSetLength);
+ RUN_TEST_FORCEASYNC_AND_NOT(TouchQuery);
+ RUN_TEST_FORCEASYNC_AND_NOT(TouchQuery);
+ RUN_TEST_FORCEASYNC_AND_NOT(AbortCalls);
+ RUN_TEST_FORCEASYNC_AND_NOT(AbortCalls);
// TODO(viettrungluu): add tests:
// - that PP_ERROR_PENDING is correctly returned
// - that operations respect the file open modes (flags)
}
std::string TestFileIO::TestOpen() {
- TestCompletionCallback callback(instance_->pp_instance());
+ TestCompletionCallback callback(instance_->pp_instance(), force_async_);
pp::FileSystem_Dev file_system(instance_, PP_FILESYSTEMTYPE_LOCALTEMPORARY);
pp::FileRef_Dev file_ref(file_system, "/file_open");
int32_t rv = file_system.Open(1024, callback);
+ if (force_async_ && rv != PP_OK_COMPLETIONPENDING)
+ return ReportError("FileSystem::Open force_async", rv);
if (rv == PP_OK_COMPLETIONPENDING)
rv = callback.WaitForResult();
if (rv != PP_OK)
@@ -217,11 +221,13 @@ std::string TestFileIO::TestOpen() {
}
std::string TestFileIO::TestReadWriteSetLength() {
- TestCompletionCallback callback(instance_->pp_instance());
+ TestCompletionCallback callback(instance_->pp_instance(), force_async_);
pp::FileSystem_Dev file_system(instance_, PP_FILESYSTEMTYPE_LOCALTEMPORARY);
pp::FileRef_Dev file_ref(file_system, "/file_read_write_setlength");
int32_t rv = file_system.Open(1024, callback);
+ if (force_async_ && rv != PP_OK_COMPLETIONPENDING)
+ return ReportError("FileSystem::Open force_async", rv);
if (rv == PP_OK_COMPLETIONPENDING)
rv = callback.WaitForResult();
if (rv != PP_OK)
@@ -234,6 +240,8 @@ std::string TestFileIO::TestReadWriteSetLength() {
PP_FILEOPENFLAG_READ |
PP_FILEOPENFLAG_WRITE,
callback);
+ if (force_async_ && rv != PP_OK_COMPLETIONPENDING)
+ return ReportError("FileIO::Open force_async", rv);
if (rv == PP_OK_COMPLETIONPENDING)
rv = callback.WaitForResult();
if (rv != PP_OK)
@@ -254,6 +262,8 @@ std::string TestFileIO::TestReadWriteSetLength() {
// Truncate the file.
rv = file_io.SetLength(4, callback);
+ if (force_async_ && rv != PP_OK_COMPLETIONPENDING)
+ return ReportError("FileIO::SetLength force_async", rv);
if (rv == PP_OK_COMPLETIONPENDING)
rv = callback.WaitForResult();
if (rv != PP_OK)
@@ -291,6 +301,8 @@ std::string TestFileIO::TestReadWriteSetLength() {
// Extend the file.
rv = file_io.SetLength(16, callback);
+ if (force_async_ && rv != PP_OK_COMPLETIONPENDING)
+ return ReportError("FileIO::SetLength force_async", rv);
if (rv == PP_OK_COMPLETIONPENDING)
rv = callback.WaitForResult();
if (rv != PP_OK)
@@ -332,10 +344,12 @@ std::string TestFileIO::TestReadWriteSetLength() {
}
std::string TestFileIO::TestTouchQuery() {
- TestCompletionCallback callback(instance_->pp_instance());
+ TestCompletionCallback callback(instance_->pp_instance(), force_async_);
pp::FileSystem_Dev file_system(instance_, PP_FILESYSTEMTYPE_LOCALTEMPORARY);
int32_t rv = file_system.Open(1024, callback);
+ if (force_async_ && rv != PP_OK_COMPLETIONPENDING)
+ return ReportError("FileSystem::Open force_async", rv);
if (rv == PP_OK_COMPLETIONPENDING)
rv = callback.WaitForResult();
if (rv != PP_OK)
@@ -348,6 +362,8 @@ std::string TestFileIO::TestTouchQuery() {
PP_FILEOPENFLAG_TRUNCATE |
PP_FILEOPENFLAG_WRITE,
callback);
+ if (force_async_ && rv != PP_OK_COMPLETIONPENDING)
+ return ReportError("FileIO::Open force_async", rv);
if (rv == PP_OK_COMPLETIONPENDING)
rv = callback.WaitForResult();
if (rv != PP_OK)
@@ -355,6 +371,8 @@ std::string TestFileIO::TestTouchQuery() {
// Write some data to have a non-zero file size.
rv = file_io.Write(0, "test", 4, callback);
+ if (force_async_ && rv != PP_OK_COMPLETIONPENDING)
+ return ReportError("FileIO::Write force_async", rv);
if (rv == PP_OK_COMPLETIONPENDING)
rv = callback.WaitForResult();
if (rv != 4)
@@ -365,41 +383,49 @@ std::string TestFileIO::TestTouchQuery() {
const PP_Time last_access_time = 123 * 24 * 3600.0;
const PP_Time last_modified_time = 246.0;
rv = file_io.Touch(last_access_time, last_modified_time, callback);
+ if (force_async_ && rv != PP_OK_COMPLETIONPENDING)
+ return ReportError("FileIO::Touch force_async", rv);
if (rv == PP_OK_COMPLETIONPENDING)
rv = callback.WaitForResult();
if (rv != PP_OK)
- return ReportError("FileSystem::Touch", rv);
+ return ReportError("FileIO::Touch", rv);
PP_FileInfo_Dev info;
rv = file_io.Query(&info, callback);
+ if (force_async_ && rv != PP_OK_COMPLETIONPENDING)
+ return ReportError("FileIO::Query force_async", rv);
if (rv == PP_OK_COMPLETIONPENDING)
rv = callback.WaitForResult();
if (rv != PP_OK)
- return ReportError("FileSystem::Query", rv);
+ return ReportError("FileIO::Query", rv);
if ((info.size != 4) ||
(info.type != PP_FILETYPE_REGULAR) ||
(info.system_type != PP_FILESYSTEMTYPE_LOCALTEMPORARY) ||
(info.last_access_time != last_access_time) ||
(info.last_modified_time != last_modified_time))
- return "FileSystem::Query() has returned bad data.";
+ return "FileIO::Query() has returned bad data.";
// Call |Query()| again, to make sure it works a second time.
rv = file_io.Query(&info, callback);
+ if (force_async_ && rv != PP_OK_COMPLETIONPENDING)
+ return ReportError("FileIO::Query force_async", rv);
if (rv == PP_OK_COMPLETIONPENDING)
rv = callback.WaitForResult();
if (rv != PP_OK)
- return ReportError("FileSystem::Query", rv);
+ return ReportError("FileIO::Query", rv);
PASS();
}
std::string TestFileIO::TestAbortCalls() {
- TestCompletionCallback callback(instance_->pp_instance());
+ TestCompletionCallback callback(instance_->pp_instance(), force_async_);
pp::FileSystem_Dev file_system(instance_, PP_FILESYSTEMTYPE_LOCALTEMPORARY);
pp::FileRef_Dev file_ref(file_system, "/file_abort_calls");
int32_t rv = file_system.Open(1024, callback);
+ if (force_async_ && rv != PP_OK_COMPLETIONPENDING)
+ return ReportError("FileSystem::Open force_async", rv);
if (rv == PP_OK_COMPLETIONPENDING)
rv = callback.WaitForResult();
if (rv != PP_OK)
@@ -411,6 +437,8 @@ std::string TestFileIO::TestAbortCalls() {
rv = file_io.Open(file_ref,
PP_FILEOPENFLAG_CREATE | PP_FILEOPENFLAG_WRITE,
callback);
+ if (force_async_ && rv != PP_OK_COMPLETIONPENDING)
+ return ReportError("FileIO::Open force_async", rv);
if (rv == PP_OK_COMPLETIONPENDING)
rv = callback.WaitForResult();
if (rv != PP_OK)
@@ -430,6 +458,8 @@ std::string TestFileIO::TestAbortCalls() {
callback.reset_run_count();
rv = pp::FileIO_Dev(instance_)
.Open(file_ref, PP_FILEOPENFLAG_READ,callback);
+ if (force_async_ && rv != PP_OK_COMPLETIONPENDING)
+ return ReportError("FileIO::Open force_async", rv);
if (callback.run_count() > 0)
return "FileIO::Open ran callback synchronously.";
if (rv == PP_OK_COMPLETIONPENDING) {
@@ -447,6 +477,8 @@ std::string TestFileIO::TestAbortCalls() {
{
pp::FileIO_Dev file_io(instance_);
rv = file_io.Open(file_ref, PP_FILEOPENFLAG_READ, callback);
+ if (force_async_ && rv != PP_OK_COMPLETIONPENDING)
+ return ReportError("FileIO::Open force_async", rv);
if (rv == PP_OK_COMPLETIONPENDING)
rv = callback.WaitForResult();
if (rv != PP_OK)
@@ -454,6 +486,8 @@ std::string TestFileIO::TestAbortCalls() {
callback.reset_run_count();
rv = file_io.Query(&info, callback);
+ if (force_async_ && rv != PP_OK_COMPLETIONPENDING)
+ return ReportError("FileIO::Query force_async", rv);
} // Destroy |file_io|.
if (rv == PP_OK_COMPLETIONPENDING) {
// Save a copy and make sure |info| doesn't get written to.
@@ -474,6 +508,8 @@ std::string TestFileIO::TestAbortCalls() {
{
pp::FileIO_Dev file_io(instance_);
rv = file_io.Open(file_ref, PP_FILEOPENFLAG_WRITE, callback);
+ if (force_async_ && rv != PP_OK_COMPLETIONPENDING)
+ return ReportError("FileIO::Open force_async", rv);
if (rv == PP_OK_COMPLETIONPENDING)
rv = callback.WaitForResult();
if (rv != PP_OK)
@@ -481,6 +517,8 @@ std::string TestFileIO::TestAbortCalls() {
callback.reset_run_count();
rv = file_io.Touch(0, 0, callback);
+ if (force_async_ && rv != PP_OK_COMPLETIONPENDING)
+ return ReportError("FileIO::Touch force_async", rv);
} // Destroy |file_io|.
if (rv == PP_OK_COMPLETIONPENDING) {
rv = callback.WaitForResult();
@@ -497,6 +535,8 @@ std::string TestFileIO::TestAbortCalls() {
{
pp::FileIO_Dev file_io(instance_);
rv = file_io.Open(file_ref, PP_FILEOPENFLAG_READ, callback);
+ if (force_async_ && rv != PP_OK_COMPLETIONPENDING)
+ return ReportError("FileIO::Open force_async", rv);
if (rv == PP_OK_COMPLETIONPENDING)
rv = callback.WaitForResult();
if (rv != PP_OK)
@@ -504,6 +544,8 @@ std::string TestFileIO::TestAbortCalls() {
callback.reset_run_count();
rv = file_io.Read(0, buf, sizeof(buf), callback);
+ if (force_async_ && rv != PP_OK_COMPLETIONPENDING)
+ return ReportError("FileIO::Read force_async", rv);
} // Destroy |file_io|.
if (rv == PP_OK_COMPLETIONPENDING) {
// Save a copy and make sure |buf| doesn't get written to.
@@ -525,6 +567,8 @@ std::string TestFileIO::TestAbortCalls() {
{
pp::FileIO_Dev file_io(instance_);
rv = file_io.Open(file_ref, PP_FILEOPENFLAG_READ, callback);
+ if (force_async_ && rv != PP_OK_COMPLETIONPENDING)
+ return ReportError("FileIO::Open force_async", rv);
if (rv == PP_OK_COMPLETIONPENDING)
rv = callback.WaitForResult();
if (rv != PP_OK)
@@ -532,6 +576,8 @@ std::string TestFileIO::TestAbortCalls() {
callback.reset_run_count();
rv = file_io.Write(0, buf, sizeof(buf), callback);
+ if (force_async_ && rv != PP_OK_COMPLETIONPENDING)
+ return ReportError("FileIO::Write force_async", rv);
} // Destroy |file_io|.
if (rv == PP_OK_COMPLETIONPENDING) {
rv = callback.WaitForResult();
@@ -547,6 +593,8 @@ std::string TestFileIO::TestAbortCalls() {
{
pp::FileIO_Dev file_io(instance_);
rv = file_io.Open(file_ref, PP_FILEOPENFLAG_READ, callback);
+ if (force_async_ && rv != PP_OK_COMPLETIONPENDING)
+ return ReportError("FileIO::Open force_async", rv);
if (rv == PP_OK_COMPLETIONPENDING)
rv = callback.WaitForResult();
if (rv != PP_OK)
@@ -554,6 +602,8 @@ std::string TestFileIO::TestAbortCalls() {
callback.reset_run_count();
rv = file_io.SetLength(3, callback);
+ if (force_async_ && rv != PP_OK_COMPLETIONPENDING)
+ return ReportError("FileIO::SetLength force_async", rv);
} // Destroy |file_io|.
if (rv == PP_OK_COMPLETIONPENDING) {
rv = callback.WaitForResult();
@@ -569,6 +619,8 @@ std::string TestFileIO::TestAbortCalls() {
{
pp::FileIO_Dev file_io(instance_);
rv = file_io.Open(file_ref, PP_FILEOPENFLAG_READ, callback);
+ if (force_async_ && rv != PP_OK_COMPLETIONPENDING)
+ return ReportError("FileIO::Open force_async", rv);
if (rv == PP_OK_COMPLETIONPENDING)
rv = callback.WaitForResult();
if (rv != PP_OK)
@@ -576,6 +628,8 @@ std::string TestFileIO::TestAbortCalls() {
callback.reset_run_count();
rv = file_io.Flush(callback);
+ if (force_async_ && rv != PP_OK_COMPLETIONPENDING)
+ return ReportError("FileIO::Flush force_async", rv);
} // Destroy |file_io|.
if (rv == PP_OK_COMPLETIONPENDING) {
rv = callback.WaitForResult();
@@ -614,7 +668,7 @@ std::string TestFileIO::MatchOpenExpectations(pp::FileSystem_Dev* file_system,
bool open_if_exists = !!(expectations & OPEN_IF_EXISTS);
bool truncate_if_exists = !!(expectations & TRUNCATE_IF_EXISTS);
- TestCompletionCallback callback(instance_->pp_instance());
+ TestCompletionCallback callback(instance_->pp_instance(), force_async_);
pp::FileRef_Dev existent_file_ref(
*file_system, "/match_open_expectation_existent_non_empty_file");
pp::FileRef_Dev nonexistent_file_ref(
@@ -623,12 +677,16 @@ std::string TestFileIO::MatchOpenExpectations(pp::FileSystem_Dev* file_system,
// Setup files for test.
{
int32_t rv = existent_file_ref.Delete(callback);
+ if (force_async_ && rv != PP_OK_COMPLETIONPENDING)
+ return ReportError("FileRef::Delete force_async", rv);
if (rv == PP_OK_COMPLETIONPENDING)
rv = callback.WaitForResult();
if (rv != PP_OK && rv != PP_ERROR_FILENOTFOUND)
return ReportError("FileRef::Delete", rv);
rv = nonexistent_file_ref.Delete(callback);
+ if (force_async_ && rv != PP_OK_COMPLETIONPENDING)
+ return ReportError("FileRef::Delete force_async", rv);
if (rv == PP_OK_COMPLETIONPENDING)
rv = callback.WaitForResult();
if (rv != PP_OK && rv != PP_ERROR_FILENOTFOUND)
@@ -638,6 +696,8 @@ std::string TestFileIO::MatchOpenExpectations(pp::FileSystem_Dev* file_system,
rv = existent_file_io.Open(existent_file_ref,
PP_FILEOPENFLAG_CREATE | PP_FILEOPENFLAG_WRITE,
callback);
+ if (force_async_ && rv != PP_OK_COMPLETIONPENDING)
+ return ReportError("FileIO::Open force_async", rv);
if (rv == PP_OK_COMPLETIONPENDING)
rv = callback.WaitForResult();
if (rv != PP_OK)
@@ -651,6 +711,8 @@ std::string TestFileIO::MatchOpenExpectations(pp::FileSystem_Dev* file_system,
pp::FileIO_Dev existent_file_io(instance_);
int32_t rv = existent_file_io.Open(existent_file_ref, open_flags, callback);
+ if (force_async_ && rv != PP_OK_COMPLETIONPENDING)
+ return ReportError("FileIO::Open force_async", rv);
if (rv == PP_OK_COMPLETIONPENDING)
rv = callback.WaitForResult();
if ((invalid_combination && rv == PP_OK) ||
@@ -661,6 +723,8 @@ std::string TestFileIO::MatchOpenExpectations(pp::FileSystem_Dev* file_system,
if (!invalid_combination && open_if_exists) {
PP_FileInfo_Dev info;
rv = existent_file_io.Query(&info, callback);
+ if (force_async_ && rv != PP_OK_COMPLETIONPENDING)
+ return ReportError("FileIO::Query force_async", rv);
if (rv == PP_OK_COMPLETIONPENDING)
rv = callback.WaitForResult();
if (rv != PP_OK)
@@ -672,6 +736,8 @@ std::string TestFileIO::MatchOpenExpectations(pp::FileSystem_Dev* file_system,
pp::FileIO_Dev nonexistent_file_io(instance_);
rv = nonexistent_file_io.Open(nonexistent_file_ref, open_flags, callback);
+ if (force_async_ && rv != PP_OK_COMPLETIONPENDING)
+ return ReportError("FileIO::Open force_async", rv);
if (rv == PP_OK_COMPLETIONPENDING)
rv = callback.WaitForResult();
if ((invalid_combination && rv == PP_OK) ||
diff --git a/ppapi/tests/test_file_ref.cc b/ppapi/tests/test_file_ref.cc
index 2fa8e5b..7ca032f 100644
--- a/ppapi/tests/test_file_ref.cc
+++ b/ppapi/tests/test_file_ref.cc
@@ -44,14 +44,14 @@ bool TestFileRef::Init() {
}
void TestFileRef::RunTest() {
- RUN_TEST(GetFileSystemType);
- RUN_TEST(GetName);
- RUN_TEST(GetPath);
- RUN_TEST(GetParent);
- RUN_TEST(MakeDirectory);
- RUN_TEST(QueryAndTouchFile);
- RUN_TEST(DeleteFileAndDirectory);
- RUN_TEST(RenameFileAndDirectory);
+ RUN_TEST_FORCEASYNC_AND_NOT(GetFileSystemType);
+ RUN_TEST_FORCEASYNC_AND_NOT(GetName);
+ RUN_TEST_FORCEASYNC_AND_NOT(GetPath);
+ RUN_TEST_FORCEASYNC_AND_NOT(GetParent);
+ RUN_TEST_FORCEASYNC_AND_NOT(MakeDirectory);
+ RUN_TEST_FORCEASYNC_AND_NOT(QueryAndTouchFile);
+ RUN_TEST_FORCEASYNC_AND_NOT(DeleteFileAndDirectory);
+ RUN_TEST_FORCEASYNC_AND_NOT(RenameFileAndDirectory);
}
std::string TestFileRef::TestGetFileSystemType() {
@@ -72,10 +72,12 @@ std::string TestFileRef::TestGetFileSystemType() {
request.SetURL("test_url_loader_data/hello.txt");
request.SetStreamToFile(true);
- TestCompletionCallback callback(instance_->pp_instance());
+ TestCompletionCallback callback(instance_->pp_instance(), force_async_);
pp::URLLoader loader(instance_);
int32_t rv = loader.Open(request, callback);
+ if (force_async_ && rv != PP_OK_COMPLETIONPENDING)
+ return ReportError("URLLoader::Open force_async", rv);
if (rv == PP_OK_COMPLETIONPENDING)
rv = callback.WaitForResult();
if (rv != PP_OK)
@@ -121,10 +123,12 @@ std::string TestFileRef::TestGetName() {
request.SetURL("test_url_loader_data/hello.txt");
request.SetStreamToFile(true);
- TestCompletionCallback callback(instance_->pp_instance());
+ TestCompletionCallback callback(instance_->pp_instance(), force_async_);
pp::URLLoader loader(instance_);
int32_t rv = loader.Open(request, callback);
+ if (force_async_ && rv != PP_OK_COMPLETIONPENDING)
+ return ReportError("URLLoader::Open force_async", rv);
if (rv == PP_OK_COMPLETIONPENDING)
rv = callback.WaitForResult();
if (rv != PP_OK)
@@ -165,10 +169,12 @@ std::string TestFileRef::TestGetPath() {
request.SetURL("test_url_loader_data/hello.txt");
request.SetStreamToFile(true);
- TestCompletionCallback callback(instance_->pp_instance());
+ TestCompletionCallback callback(instance_->pp_instance(), force_async_);
pp::URLLoader loader(instance_);
int32_t rv = loader.Open(request, callback);
+ if (force_async_ && rv != PP_OK_COMPLETIONPENDING)
+ return ReportError("URLLoader::Open force_async", rv);
if (rv == PP_OK_COMPLETIONPENDING)
rv = callback.WaitForResult();
if (rv != PP_OK)
@@ -220,10 +226,12 @@ std::string TestFileRef::TestGetParent() {
request.SetURL("test_url_loader_data/hello.txt");
request.SetStreamToFile(true);
- TestCompletionCallback callback(instance_->pp_instance());
+ TestCompletionCallback callback(instance_->pp_instance(), force_async_);
pp::URLLoader loader(instance_);
int32_t rv = loader.Open(request, callback);
+ if (force_async_ && rv != PP_OK_COMPLETIONPENDING)
+ return ReportError("URLLoader::Open force_async", rv);
if (rv == PP_OK_COMPLETIONPENDING)
rv = callback.WaitForResult();
if (rv != PP_OK)
@@ -244,11 +252,13 @@ std::string TestFileRef::TestGetParent() {
}
std::string TestFileRef::TestMakeDirectory() {
- TestCompletionCallback callback(instance_->pp_instance());
+ TestCompletionCallback callback(instance_->pp_instance(), force_async_);
// Open.
pp::FileSystem_Dev file_system(instance_, PP_FILESYSTEMTYPE_LOCALTEMPORARY);
int32_t rv = file_system.Open(1024, callback);
+ if (force_async_ && rv != PP_OK_COMPLETIONPENDING)
+ return ReportError("FileSystem::Open force_async", rv);
if (rv == PP_OK_COMPLETIONPENDING)
rv = callback.WaitForResult();
if (rv != PP_OK)
@@ -257,6 +267,8 @@ std::string TestFileRef::TestMakeDirectory() {
// MakeDirectory.
pp::FileRef_Dev dir_ref(file_system, "/test_dir_make_directory");
rv = dir_ref.MakeDirectory(callback);
+ if (force_async_ && rv != PP_OK_COMPLETIONPENDING)
+ return ReportError("FileSystem::MakeDirectory force_async", rv);
if (rv == PP_OK_COMPLETIONPENDING)
rv = callback.WaitForResult();
if (rv != PP_OK)
@@ -268,6 +280,8 @@ std::string TestFileRef::TestMakeDirectory() {
.MakeDirectory(callback);
if (callback.run_count() > 0)
return "FileSystem::MakeDirectory ran callback synchronously.";
+ if (force_async_ && rv != PP_OK_COMPLETIONPENDING)
+ return ReportError("FileSystem::MakeDirectory force_async", rv);
if (rv == PP_OK_COMPLETIONPENDING) {
rv = callback.WaitForResult();
if (rv != PP_ERROR_ABORTED)
@@ -279,6 +293,8 @@ std::string TestFileRef::TestMakeDirectory() {
// MakeDirectoryIncludingAncestors.
dir_ref = pp::FileRef_Dev(file_system, "/dir_make_dir_1/dir_make_dir_2");
rv = dir_ref.MakeDirectoryIncludingAncestors(callback);
+ if (force_async_ && rv != PP_OK_COMPLETIONPENDING)
+ return ReportError("FileSystem::MakeDirectory force_async", rv);
if (rv == PP_OK_COMPLETIONPENDING)
rv = callback.WaitForResult();
if (rv != PP_OK)
@@ -292,6 +308,9 @@ std::string TestFileRef::TestMakeDirectory() {
return "FileSystem::MakeDirectoryIncludingAncestors "
"ran callback synchronously.";
}
+ if (force_async_ && rv != PP_OK_COMPLETIONPENDING)
+ return ReportError(
+ "FileSystem::MakeDirectoryIncludingAncestors force_async", rv);
if (rv == PP_OK_COMPLETIONPENDING) {
rv = callback.WaitForResult();
if (rv != PP_ERROR_ABORTED)
@@ -303,6 +322,8 @@ std::string TestFileRef::TestMakeDirectory() {
// MakeDirectory with nested path.
dir_ref = pp::FileRef_Dev(file_system, "/dir_make_dir_3/dir_make_dir_4");
rv = dir_ref.MakeDirectory(callback);
+ if (force_async_ && rv != PP_OK_COMPLETIONPENDING)
+ return ReportError("FileSystem::MakeDirectory force_async", rv);
if (rv == PP_OK_COMPLETIONPENDING)
rv = callback.WaitForResult();
if (rv == PP_OK) {
@@ -314,9 +335,11 @@ std::string TestFileRef::TestMakeDirectory() {
}
std::string TestFileRef::TestQueryAndTouchFile() {
- TestCompletionCallback callback(instance_->pp_instance());
+ TestCompletionCallback callback(instance_->pp_instance(), force_async_);
pp::FileSystem_Dev file_system(instance_, PP_FILESYSTEMTYPE_LOCALTEMPORARY);
int32_t rv = file_system.Open(1024, callback);
+ if (force_async_ && rv != PP_OK_COMPLETIONPENDING)
+ return ReportError("FileSystem::Open force_async", rv);
if (rv == PP_OK_COMPLETIONPENDING)
rv = callback.WaitForResult();
if (rv != PP_OK)
@@ -329,6 +352,8 @@ std::string TestFileRef::TestQueryAndTouchFile() {
PP_FILEOPENFLAG_TRUNCATE |
PP_FILEOPENFLAG_WRITE,
callback);
+ if (force_async_ && rv != PP_OK_COMPLETIONPENDING)
+ return ReportError("FileIO::Open force_async", rv);
if (rv == PP_OK_COMPLETIONPENDING)
rv = callback.WaitForResult();
if (rv != PP_OK)
@@ -336,6 +361,8 @@ std::string TestFileRef::TestQueryAndTouchFile() {
// Write some data to have a non-zero file size.
rv = file_io.Write(0, "test", 4, callback);
+ if (force_async_ && rv != PP_OK_COMPLETIONPENDING)
+ return ReportError("FileIO::Write force_async", rv);
if (rv == PP_OK_COMPLETIONPENDING)
rv = callback.WaitForResult();
if (rv != 4)
@@ -347,6 +374,8 @@ std::string TestFileRef::TestQueryAndTouchFile() {
const PP_Time last_access_time = 123 * 24 * 3600.0;
const PP_Time last_modified_time = 246.0;
rv = file_ref.Touch(last_access_time, last_modified_time, callback);
+ if (force_async_ && rv != PP_OK_COMPLETIONPENDING)
+ return ReportError("FileSystem::Touch force_async", rv);
if (rv == PP_OK_COMPLETIONPENDING)
rv = callback.WaitForResult();
if (rv != PP_OK)
@@ -358,6 +387,8 @@ std::string TestFileRef::TestQueryAndTouchFile() {
.Touch(last_access_time, last_modified_time, callback);
if (callback.run_count() > 0)
return "FileSystem::Touch ran callback synchronously.";
+ if (force_async_ && rv != PP_OK_COMPLETIONPENDING)
+ return ReportError("FileSystem::Touch force_async", rv);
if (rv == PP_OK_COMPLETIONPENDING) {
rv = callback.WaitForResult();
if (rv != PP_ERROR_ABORTED)
@@ -369,6 +400,8 @@ std::string TestFileRef::TestQueryAndTouchFile() {
// Query.
PP_FileInfo_Dev info;
rv = file_io.Query(&info, callback);
+ if (force_async_ && rv != PP_OK_COMPLETIONPENDING)
+ return ReportError("FileSystem::Query force_async", rv);
if (rv == PP_OK_COMPLETIONPENDING)
rv = callback.WaitForResult();
if (rv != PP_OK)
@@ -389,6 +422,8 @@ std::string TestFileRef::TestQueryAndTouchFile() {
last_access_time, last_modified_time, callback);
if (callback.run_count() > 0)
return "FileSystem::Touch ran callback synchronously.";
+ if (force_async_ && rv != PP_OK_COMPLETIONPENDING)
+ return ReportError("FileSystem::Touch force_async", rv);
if (rv == PP_OK_COMPLETIONPENDING) {
rv = callback.WaitForResult();
if (rv != PP_ERROR_ABORTED)
@@ -401,9 +436,11 @@ std::string TestFileRef::TestQueryAndTouchFile() {
}
std::string TestFileRef::TestDeleteFileAndDirectory() {
- TestCompletionCallback callback(instance_->pp_instance());
+ TestCompletionCallback callback(instance_->pp_instance(), force_async_);
pp::FileSystem_Dev file_system(instance_, PP_FILESYSTEMTYPE_LOCALTEMPORARY);
int32_t rv = file_system.Open(1024, callback);
+ if (force_async_ && rv != PP_OK_COMPLETIONPENDING)
+ return ReportError("FileSystem::Open force_async", rv);
if (rv == PP_OK_COMPLETIONPENDING)
rv = callback.WaitForResult();
if (rv != PP_OK)
@@ -412,57 +449,73 @@ std::string TestFileRef::TestDeleteFileAndDirectory() {
pp::FileRef_Dev file_ref(file_system, "/file_delete");
pp::FileIO_Dev file_io(instance_);
rv = file_io.Open(file_ref, PP_FILEOPENFLAG_CREATE, callback);
+ if (force_async_ && rv != PP_OK_COMPLETIONPENDING)
+ return ReportError("FileIO::Open force_async", rv);
if (rv == PP_OK_COMPLETIONPENDING)
rv = callback.WaitForResult();
if (rv != PP_OK)
return ReportError("FileIO::Open", rv);
rv = file_ref.Delete(callback);
+ if (force_async_ && rv != PP_OK_COMPLETIONPENDING)
+ return ReportError("FileRef::Delete force_async", rv);
if (rv == PP_OK_COMPLETIONPENDING)
rv = callback.WaitForResult();
if (rv != PP_OK)
- return ReportError("FileSystem::Delete", rv);
+ return ReportError("FileRef::Delete", rv);
pp::FileRef_Dev dir_ref(file_system, "/dir_delete");
rv = dir_ref.MakeDirectory(callback);
+ if (force_async_ && rv != PP_OK_COMPLETIONPENDING)
+ return ReportError("FileRef::MakeDirectory force_async", rv);
if (rv == PP_OK_COMPLETIONPENDING)
rv = callback.WaitForResult();
if (rv != PP_OK)
- return ReportError("FileSystem::MakeDirectory", rv);
+ return ReportError("FileRef::MakeDirectory", rv);
rv = dir_ref.Delete(callback);
+ if (force_async_ && rv != PP_OK_COMPLETIONPENDING)
+ return ReportError("FileRef::Open force_async", rv);
if (rv == PP_OK_COMPLETIONPENDING)
rv = callback.WaitForResult();
if (rv != PP_OK)
- return ReportError("FileSystem::Delete", rv);
+ return ReportError("FileRef::Delete", rv);
pp::FileRef_Dev nested_dir_ref(file_system, "/dir_delete_1/dir_delete_2");
rv = nested_dir_ref.MakeDirectoryIncludingAncestors(callback);
+ if (force_async_ && rv != PP_OK_COMPLETIONPENDING)
+ return ReportError("FileRef::Open force_async", rv);
if (rv == PP_OK_COMPLETIONPENDING)
rv = callback.WaitForResult();
if (rv != PP_OK)
- return ReportError("FileSystem::MakeDirectoryIncludingAncestors", rv);
+ return ReportError("FileRef::MakeDirectoryIncludingAncestors", rv);
// Hang on to a ref to the parent; otherwise the callback will be aborted.
pp::FileRef_Dev parent_dir_ref = nested_dir_ref.GetParent();
rv = parent_dir_ref.Delete(callback);
+ if (force_async_ && rv != PP_OK_COMPLETIONPENDING)
+ return ReportError("FileRef::Open force_async", rv);
if (rv == PP_OK_COMPLETIONPENDING)
rv = callback.WaitForResult();
if (rv != PP_ERROR_FAILED)
- return ReportError("FileSystem::Delete", rv);
+ return ReportError("FileRef::Delete", rv);
pp::FileRef_Dev nonexistent_file_ref(file_system, "/nonexistent_file_delete");
rv = nonexistent_file_ref.Delete(callback);
+ if (force_async_ && rv != PP_OK_COMPLETIONPENDING)
+ return ReportError("FileRef::Open force_async", rv);
if (rv == PP_OK_COMPLETIONPENDING)
rv = callback.WaitForResult();
if (rv != PP_ERROR_FILENOTFOUND)
- return ReportError("FileSystem::Delete", rv);
+ return ReportError("FileRef::Delete", rv);
// Delete aborted.
{
pp::FileRef_Dev file_ref_abort(file_system, "/file_delete_abort");
pp::FileIO_Dev file_io_abort(instance_);
rv = file_io_abort.Open(file_ref_abort, PP_FILEOPENFLAG_CREATE, callback);
+ if (force_async_ && rv != PP_OK_COMPLETIONPENDING)
+ return ReportError("FileIO::Open force_async", rv);
if (rv == PP_OK_COMPLETIONPENDING)
rv = callback.WaitForResult();
if (rv != PP_OK)
@@ -472,22 +525,26 @@ std::string TestFileRef::TestDeleteFileAndDirectory() {
rv = file_ref_abort.Delete(callback);
}
if (callback.run_count() > 0)
- return "FileSystem::Delete ran callback synchronously.";
+ return "FileRef::Delete ran callback synchronously.";
+ if (force_async_ && rv != PP_OK_COMPLETIONPENDING)
+ return ReportError("FileRef::Open force_async", rv);
if (rv == PP_OK_COMPLETIONPENDING) {
rv = callback.WaitForResult();
if (rv != PP_ERROR_ABORTED)
- return "FileSystem::Delete not aborted.";
+ return "FileRef::Delete not aborted.";
} else if (rv != PP_OK) {
- return ReportError("FileSystem::Delete", rv);
+ return ReportError("FileRef::Delete", rv);
}
PASS();
}
std::string TestFileRef::TestRenameFileAndDirectory() {
- TestCompletionCallback callback(instance_->pp_instance());
+ TestCompletionCallback callback(instance_->pp_instance(), force_async_);
pp::FileSystem_Dev file_system(instance_, PP_FILESYSTEMTYPE_LOCALTEMPORARY);
int32_t rv = file_system.Open(1024, callback);
+ if (force_async_ && rv != PP_OK_COMPLETIONPENDING)
+ return ReportError("FileSystem::Open force_async", rv);
if (rv == PP_OK_COMPLETIONPENDING)
rv = callback.WaitForResult();
if (rv != PP_OK)
@@ -496,6 +553,8 @@ std::string TestFileRef::TestRenameFileAndDirectory() {
pp::FileRef_Dev file_ref(file_system, "/file_rename");
pp::FileIO_Dev file_io(instance_);
rv = file_io.Open(file_ref, PP_FILEOPENFLAG_CREATE, callback);
+ if (force_async_ && rv != PP_OK_COMPLETIONPENDING)
+ return ReportError("FileIO::Open force_async", rv);
if (rv == PP_OK_COMPLETIONPENDING)
rv = callback.WaitForResult();
if (rv != PP_OK)
@@ -503,38 +562,48 @@ std::string TestFileRef::TestRenameFileAndDirectory() {
pp::FileRef_Dev target_file_ref(file_system, "/target_file_rename");
rv = file_ref.Rename(target_file_ref, callback);
+ if (force_async_ && rv != PP_OK_COMPLETIONPENDING)
+ return ReportError("FileRef::Rename force_async", rv);
if (rv == PP_OK_COMPLETIONPENDING)
rv = callback.WaitForResult();
if (rv != PP_OK)
- return ReportError("FileSystem::Rename", rv);
+ return ReportError("FileRef::Rename", rv);
pp::FileRef_Dev dir_ref(file_system, "/dir_rename");
rv = dir_ref.MakeDirectory(callback);
+ if (force_async_ && rv != PP_OK_COMPLETIONPENDING)
+ return ReportError("FileRef::MakeDirectory force_async", rv);
if (rv == PP_OK_COMPLETIONPENDING)
rv = callback.WaitForResult();
if (rv != PP_OK)
- return ReportError("FileSystem::MakeDirectory", rv);
+ return ReportError("FileRef::MakeDirectory", rv);
pp::FileRef_Dev target_dir_ref(file_system, "/target_dir_rename");
rv = dir_ref.Rename(target_dir_ref, callback);
+ if (force_async_ && rv != PP_OK_COMPLETIONPENDING)
+ return ReportError("FileRef::Rename force_async", rv);
if (rv == PP_OK_COMPLETIONPENDING)
rv = callback.WaitForResult();
if (rv != PP_OK)
- return ReportError("FileSystem::Rename", rv);
+ return ReportError("FileRef::Rename", rv);
pp::FileRef_Dev nested_dir_ref(file_system, "/dir_rename_1/dir_rename_2");
rv = nested_dir_ref.MakeDirectoryIncludingAncestors(callback);
+ if (force_async_ && rv != PP_OK_COMPLETIONPENDING)
+ return ReportError("FileRef::MakeDirectory force_async", rv);
if (rv == PP_OK_COMPLETIONPENDING)
rv = callback.WaitForResult();
if (rv != PP_OK)
- return ReportError("FileSystem::MakeDirectoryIncludingAncestors", rv);
+ return ReportError("FileRef::MakeDirectoryIncludingAncestors", rv);
pp::FileRef_Dev target_nested_dir_ref(file_system, "/dir_rename_1");
rv = nested_dir_ref.Rename(target_nested_dir_ref, callback);
+ if (force_async_ && rv != PP_OK_COMPLETIONPENDING)
+ return ReportError("FileRef::Open force_async", rv);
if (rv == PP_OK_COMPLETIONPENDING)
rv = callback.WaitForResult();
if (rv != PP_ERROR_FAILED)
- return ReportError("FileSystem::Rename", rv);
+ return ReportError("FileRef::Rename", rv);
// Rename aborted.
// TODO(viettrungluu): Figure out what we want to do if the target file
@@ -545,6 +614,8 @@ std::string TestFileRef::TestRenameFileAndDirectory() {
pp::FileRef_Dev file_ref_abort(file_system, "/file_rename_abort");
pp::FileIO_Dev file_io_abort(instance_);
rv = file_io_abort.Open(file_ref_abort, PP_FILEOPENFLAG_CREATE, callback);
+ if (force_async_ && rv != PP_OK_COMPLETIONPENDING)
+ return ReportError("FileIO::Open force_async", rv);
if (rv == PP_OK_COMPLETIONPENDING)
rv = callback.WaitForResult();
if (rv != PP_OK)
@@ -555,6 +626,8 @@ std::string TestFileRef::TestRenameFileAndDirectory() {
}
if (callback.run_count() > 0)
return "FileSystem::Rename ran callback synchronously.";
+ if (force_async_ && rv != PP_OK_COMPLETIONPENDING)
+ return ReportError("FileSystem::Rename force_async", rv);
if (rv == PP_OK_COMPLETIONPENDING) {
rv = callback.WaitForResult();
if (rv != PP_ERROR_ABORTED)
diff --git a/ppapi/tests/test_file_system.cc b/ppapi/tests/test_file_system.cc
index 7758f5f..fe5c902 100644
--- a/ppapi/tests/test_file_system.cc
+++ b/ppapi/tests/test_file_system.cc
@@ -18,12 +18,12 @@ bool TestFileSystem::Init() {
}
void TestFileSystem::RunTest() {
- RUN_TEST(Open);
- RUN_TEST(MultipleOpens);
+ RUN_TEST_FORCEASYNC_AND_NOT(Open);
+ RUN_TEST_FORCEASYNC_AND_NOT(MultipleOpens);
}
std::string TestFileSystem::TestOpen() {
- TestCompletionCallback callback(instance_->pp_instance());
+ TestCompletionCallback callback(instance_->pp_instance(), force_async_);
// Open.
pp::FileSystem_Dev file_system(instance_, PP_FILESYSTEMTYPE_LOCALTEMPORARY);
@@ -39,6 +39,8 @@ std::string TestFileSystem::TestOpen() {
.Open(1024, callback);
if (callback.run_count() > 0)
return "FileSystem::Open ran callback synchronously.";
+ if (force_async_ && rv != PP_OK_COMPLETIONPENDING)
+ return ReportError("FileSystem::Open force_async", rv);
if (rv == PP_OK_COMPLETIONPENDING) {
rv = callback.WaitForResult();
if (rv != PP_ERROR_ABORTED)
@@ -53,27 +55,32 @@ std::string TestFileSystem::TestOpen() {
std::string TestFileSystem::TestMultipleOpens() {
// Should not allow multiple opens, no matter the first open has completed or
// not.
- TestCompletionCallback callback_1(instance_->pp_instance());
+ TestCompletionCallback callback_1(instance_->pp_instance(), force_async_);
pp::FileSystem_Dev file_system(instance_, PP_FILESYSTEMTYPE_LOCALTEMPORARY);
int32_t rv_1 = file_system.Open(1024, callback_1);
if (callback_1.run_count() > 0)
- return "FileSystem::Open ran callback synchronously.";
+ return "FileSystem::Open1 ran callback synchronously.";
+ if (force_async_ && rv_1 != PP_OK_COMPLETIONPENDING)
+ return ReportError("FileSystem::Open1 force_async", rv_1);
- TestCompletionCallback callback_2(instance_->pp_instance());
+ TestCompletionCallback callback_2(instance_->pp_instance(), force_async_);
int32_t rv_2 = file_system.Open(1024, callback_2);
+ if (force_async_ && rv_2 != PP_OK_COMPLETIONPENDING)
+ return ReportError("FileSystem::Open2 force_async", rv_2);
if (rv_2 == PP_OK_COMPLETIONPENDING || rv_2 == PP_OK)
- return "FileSystem::Open should not allow multiple opens.";
+ return "FileSystem::Open2 should not allow multiple opens.";
if (rv_1 == PP_OK_COMPLETIONPENDING)
rv_1 = callback_1.WaitForResult();
if (rv_1 != PP_OK)
- return ReportError("FileSystem::Open", rv_1);
+ return ReportError("FileSystem::Open1", rv_1);
- TestCompletionCallback callback_3(instance_->pp_instance());
+ TestCompletionCallback callback_3(instance_->pp_instance(), force_async_);
int32_t rv_3 = file_system.Open(1024, callback_3);
+ if (force_async_ && rv_3 != PP_OK_COMPLETIONPENDING)
+ return ReportError("FileSystem::Open3 force_async", rv_3);
if (rv_3 == PP_OK_COMPLETIONPENDING || rv_3 == PP_OK)
- return "FileSystem::Open should not allow multiple opens.";
+ return "FileSystem::Open3 should not allow multiple opens.";
PASS();
}
-
diff --git a/ppapi/tests/test_graphics_2d.cc b/ppapi/tests/test_graphics_2d.cc
index 28483b4..2917180 100644
--- a/ppapi/tests/test_graphics_2d.cc
+++ b/ppapi/tests/test_graphics_2d.cc
@@ -43,15 +43,15 @@ bool TestGraphics2D::Init() {
}
void TestGraphics2D::RunTest() {
- instance_->LogTest("InvalidResource", TestInvalidResource());
- instance_->LogTest("InvalidSize", TestInvalidSize());
- instance_->LogTest("Humongous", TestHumongous());
- instance_->LogTest("InitToZero", TestInitToZero());
- instance_->LogTest("Describe", TestDescribe());
- instance_->LogTest("Paint", TestPaint());
- //instance_->LogTest("Scroll", TestScroll()); // TODO(brettw) implement.
- instance_->LogTest("Replace", TestReplace());
- instance_->LogTest("Flush", TestFlush());
+ RUN_TEST(InvalidResource);
+ RUN_TEST(InvalidSize);
+ RUN_TEST(Humongous);
+ RUN_TEST(InitToZero);
+ RUN_TEST(Describe);
+ RUN_TEST_FORCEASYNC_AND_NOT(Paint);
+ // RUN_TEST_FORCEASYNC_AND_NOT(Scroll); // TODO(brettw) implement.
+ RUN_TEST_FORCEASYNC_AND_NOT(Replace);
+ RUN_TEST_FORCEASYNC_AND_NOT(Flush);
}
void TestGraphics2D::QuitMessageLoop() {
@@ -79,8 +79,11 @@ bool TestGraphics2D::IsDCUniformColor(const pp::Graphics2D& dc,
}
bool TestGraphics2D::FlushAndWaitForDone(pp::Graphics2D* context) {
- pp::CompletionCallback cc(&FlushCallbackQuitMessageLoop, this);
+ int32_t flags = (force_async_ ? 0 : PP_COMPLETIONCALLBACK_FLAG_OPTIONAL);
+ pp::CompletionCallback cc(&FlushCallbackQuitMessageLoop, this, flags);
int32_t rv = context->Flush(cc);
+ if (force_async_ && rv != PP_OK_COMPLETIONPENDING)
+ return false;
if (rv == PP_OK)
return true;
if (rv != PP_OK_COMPLETIONPENDING)
@@ -209,11 +212,11 @@ std::string TestGraphics2D::TestInvalidResource() {
// Flush.
if (graphics_2d_interface_->Flush(
image.pp_resource(),
- PP_MakeCompletionCallback(&FlushCallbackNOP, NULL)) == PP_OK)
+ PP_MakeOptionalCompletionCallback(&FlushCallbackNOP, NULL)) == PP_OK)
return "Flush succeeded with a different resource";
if (graphics_2d_interface_->Flush(
null_context.pp_resource(),
- PP_MakeCompletionCallback(&FlushCallbackNOP, NULL)) == PP_OK)
+ PP_MakeOptionalCompletionCallback(&FlushCallbackNOP, NULL)) == PP_OK)
return "Flush succeeded with a NULL resource";
// ReadImageData.
@@ -526,16 +529,27 @@ std::string TestGraphics2D::TestFlush() {
if (!FlushAndWaitForDone(&dc_nopaints))
return "Couldn't flush the nopaint device";
+ int32_t flags = (force_async_ ? 0 : PP_COMPLETIONCALLBACK_FLAG_OPTIONAL);
+
// Test that multiple flushes fail if we don't get a callback in between.
- rv = dc_nopaints.Flush(pp::CompletionCallback(&FlushCallbackNOP, NULL));
+ rv = dc_nopaints.Flush(pp::CompletionCallback(&FlushCallbackNOP, NULL,
+ flags));
+ if (force_async_ && rv != PP_OK_COMPLETIONPENDING)
+ return "Flush must complete asynchronously.";
if (rv != PP_OK && rv != PP_OK_COMPLETIONPENDING)
return "Couldn't flush first time for multiple flush test.";
- if (rv != PP_OK) {
- // If the first flush would block, then a second should fail.
- rv = dc_nopaints.Flush(pp::CompletionCallback(&FlushCallbackNOP, NULL));
- if (rv == PP_OK || rv == PP_OK_COMPLETIONPENDING)
- return "Second flush succeeded before callback ran.";
+ if (rv == PP_OK_COMPLETIONPENDING) {
+ // If the first flush completes asynchronously, then a second should fail.
+ rv = dc_nopaints.Flush(pp::CompletionCallback(&FlushCallbackNOP, NULL,
+ flags));
+ if (force_async_) {
+ if (rv != PP_OK_COMPLETIONPENDING)
+ return "Second flush must fail asynchronously.";
+ } else {
+ if (rv == PP_OK || rv == PP_OK_COMPLETIONPENDING)
+ return "Second flush succeeded before callback ran.";
+ }
}
PASS();
diff --git a/ppapi/tests/test_transport.cc b/ppapi/tests/test_transport.cc
index fc41f17..d45112a 100644
--- a/ppapi/tests/test_transport.cc
+++ b/ppapi/tests/test_transport.cc
@@ -54,7 +54,7 @@ class StreamReader {
buffer_.resize(kReadBufferSize);
int result = transport_->Recv(
&buffer_[0], buffer_.size(),
- callback_factory_.NewCallback(&StreamReader::OnReadFinished));
+ callback_factory_.NewOptionalCallback(&StreamReader::OnReadFinished));
if (result > 0)
DidFinishRead(result);
else
@@ -104,7 +104,7 @@ bool TestTransport::Init() {
void TestTransport::RunTest() {
RUN_TEST(Create);
RUN_TEST(Connect);
- RUN_TEST(SendDataUdp);
+ RUN_TEST_FORCEASYNC(SendDataUdp);
RUN_TEST(SendDataTcp);
RUN_TEST(ConnectAndCloseUdp);
RUN_TEST(ConnectAndCloseTcp);
@@ -198,10 +198,15 @@ std::string TestTransport::TestSendDataUdp() {
// Put packet index in the beginning.
memcpy(&send_buffer[0], &i, sizeof(i));
- TestCompletionCallback send_cb(instance_->pp_instance());
- ASSERT_EQ(
- transport2_->Send(&send_buffer[0], send_buffer.size(), send_cb),
- static_cast<int>(send_buffer.size()));
+ TestCompletionCallback send_cb(instance_->pp_instance(), force_async_);
+ int32_t result = transport2_->Send(&send_buffer[0], send_buffer.size(),
+ send_cb);
+ if (force_async_) {
+ ASSERT_EQ(result, PP_OK_COMPLETIONPENDING);
+ ASSERT_EQ(send_cb.WaitForResult(), static_cast<int>(send_buffer.size()));
+ } else {
+ ASSERT_EQ(result, static_cast<int>(send_buffer.size()));
+ }
sent_packets[i] = send_buffer;
}
@@ -243,9 +248,11 @@ std::string TestTransport::TestSendDataTcp() {
int pos = 0;
while (pos < static_cast<int>(send_buffer.size())) {
- TestCompletionCallback send_cb(instance_->pp_instance());
+ TestCompletionCallback send_cb(instance_->pp_instance(), force_async_);
int result = transport2_->Send(
&send_buffer[0] + pos, send_buffer.size() - pos, send_cb);
+ if (force_async_)
+ ASSERT_EQ(result, PP_OK_COMPLETIONPENDING);
if (result == PP_OK_COMPLETIONPENDING)
result = send_cb.WaitForResult();
ASSERT_TRUE(result > 0);
diff --git a/ppapi/tests/test_url_loader.cc b/ppapi/tests/test_url_loader.cc
index 8fda286..6ecb15d 100644
--- a/ppapi/tests/test_url_loader.cc
+++ b/ppapi/tests/test_url_loader.cc
@@ -44,27 +44,29 @@ bool TestURLLoader::Init() {
void TestURLLoader::RunTest() {
RUN_TEST(BasicGET);
- RUN_TEST(BasicPOST);
- RUN_TEST(CompoundBodyPOST);
- RUN_TEST(EmptyDataPOST);
+ RUN_TEST_FORCEASYNC(BasicPOST);
+ RUN_TEST_FORCEASYNC_AND_NOT(CompoundBodyPOST);
+ RUN_TEST_FORCEASYNC(EmptyDataPOST);
RUN_TEST(BinaryDataPOST);
- RUN_TEST(CustomRequestHeader);
- RUN_TEST(IgnoresBogusContentLength);
+ RUN_TEST_FORCEASYNC_AND_NOT(CustomRequestHeader);
+ RUN_TEST_FORCEASYNC(IgnoresBogusContentLength);
RUN_TEST(SameOriginRestriction);
- RUN_TEST(CrossOriginRequest);
- RUN_TEST(StreamToFile);
+ RUN_TEST_FORCEASYNC(CrossOriginRequest);
+ RUN_TEST_FORCEASYNC_AND_NOT(StreamToFile);
RUN_TEST(AuditURLRedirect);
- RUN_TEST(AbortCalls);
+ RUN_TEST_FORCEASYNC(AbortCalls);
}
std::string TestURLLoader::ReadEntireFile(pp::FileIO_Dev* file_io,
std::string* data) {
- TestCompletionCallback callback(instance_->pp_instance());
+ TestCompletionCallback callback(instance_->pp_instance(), force_async_);
char buf[256];
int64_t offset = 0;
for (;;) {
int32_t rv = file_io->Read(offset, buf, sizeof(buf), callback);
+ if (force_async_ && rv != PP_OK_COMPLETIONPENDING)
+ return ReportError("FileIO::Read force_async", rv);
if (rv == PP_OK_COMPLETIONPENDING)
rv = callback.WaitForResult();
if (rv < 0)
@@ -80,11 +82,13 @@ std::string TestURLLoader::ReadEntireFile(pp::FileIO_Dev* file_io,
std::string TestURLLoader::ReadEntireResponseBody(pp::URLLoader* loader,
std::string* body) {
- TestCompletionCallback callback(instance_->pp_instance());
+ TestCompletionCallback callback(instance_->pp_instance(), force_async_);
char buf[2]; // Small so that multiple reads are needed.
for (;;) {
int32_t rv = loader->ReadResponseBody(buf, sizeof(buf), callback);
+ if (force_async_ && rv != PP_OK_COMPLETIONPENDING)
+ return ReportError("URLLoader::ReadResponseBody force_async", rv);
if (rv == PP_OK_COMPLETIONPENDING)
rv = callback.WaitForResult();
if (rv < 0)
@@ -100,10 +104,12 @@ std::string TestURLLoader::ReadEntireResponseBody(pp::URLLoader* loader,
std::string TestURLLoader::LoadAndCompareBody(
const pp::URLRequestInfo& request,
const std::string& expected_body) {
- TestCompletionCallback callback(instance_->pp_instance());
+ TestCompletionCallback callback(instance_->pp_instance(), force_async_);
pp::URLLoader loader(*instance_);
int32_t rv = loader.Open(request, callback);
+ if (force_async_ && rv != PP_OK_COMPLETIONPENDING)
+ return ReportError("URLLoader::Open force_async", rv);
if (rv == PP_OK_COMPLETIONPENDING)
rv = callback.WaitForResult();
if (rv != PP_OK)
@@ -197,10 +203,12 @@ std::string TestURLLoader::TestStreamToFile() {
request.SetURL("test_url_loader_data/hello.txt");
request.SetStreamToFile(true);
- TestCompletionCallback callback(instance_->pp_instance());
+ TestCompletionCallback callback(instance_->pp_instance(), force_async_);
pp::URLLoader loader(*instance_);
int32_t rv = loader.Open(request, callback);
+ if (force_async_ && rv != PP_OK_COMPLETIONPENDING)
+ return ReportError("URLLoader::Open force_async", rv);
if (rv == PP_OK_COMPLETIONPENDING)
rv = callback.WaitForResult();
if (rv != PP_OK)
@@ -218,6 +226,8 @@ std::string TestURLLoader::TestStreamToFile() {
return "URLResponseInfo::GetBody returned null";
rv = loader.FinishStreamingToFile(callback);
+ if (force_async_ && rv != PP_OK_COMPLETIONPENDING)
+ return ReportError("URLLoader::FinishStreamingToFile force_async", rv);
if (rv == PP_OK_COMPLETIONPENDING)
rv = callback.WaitForResult();
if (rv != PP_OK)
@@ -225,6 +235,8 @@ std::string TestURLLoader::TestStreamToFile() {
pp::FileIO_Dev reader(instance_);
rv = reader.Open(body, PP_FILEOPENFLAG_READ, callback);
+ if (force_async_ && rv != PP_OK_COMPLETIONPENDING)
+ return ReportError("FileIO::Open force_async", rv);
if (rv == PP_OK_COMPLETIONPENDING)
rv = callback.WaitForResult();
if (rv != PP_OK)
@@ -253,10 +265,12 @@ std::string TestURLLoader::TestSameOriginRestriction() {
pp::URLRequestInfo request(instance_);
request.SetURL("http://www.google.com/");
- TestCompletionCallback callback(instance_->pp_instance());
+ TestCompletionCallback callback(instance_->pp_instance(), force_async_);
pp::URLLoader loader(*instance_);
int32_t rv = loader.Open(request, callback);
+ if (force_async_ && rv != PP_OK_COMPLETIONPENDING)
+ return ReportError("URLLoader::Open force_async", rv);
if (rv == PP_OK_COMPLETIONPENDING)
rv = callback.WaitForResult();
@@ -290,11 +304,13 @@ std::string TestURLLoader::TestCrossOriginRequest() {
request.SetURL(cross_origin_url);
request.SetAllowCrossOriginRequests(true);
- TestCompletionCallback callback(instance_->pp_instance());
+ TestCompletionCallback callback(instance_->pp_instance(), force_async_);
pp::URLLoader loader(*instance_);
int32_t rv = loader.Open(request, callback);
- if (rv == PP_ERROR_WOULDBLOCK)
+ if (force_async_ && rv != PP_OK_COMPLETIONPENDING)
+ return ReportError("URLLoader::Open force_async", rv);
+ if (rv == PP_OK_COMPLETIONPENDING)
rv = callback.WaitForResult();
// We expect success since we allowed a cross-origin request.
@@ -312,10 +328,12 @@ std::string TestURLLoader::TestAuditURLRedirect() {
request.SetURL("/server-redirect?www.google.com");
request.SetFollowRedirects(false);
- TestCompletionCallback callback(instance_->pp_instance());
+ TestCompletionCallback callback(instance_->pp_instance(), force_async_);
pp::URLLoader loader(*instance_);
int32_t rv = loader.Open(request, callback);
+ if (force_async_ && rv != PP_OK_COMPLETIONPENDING)
+ return ReportError("URLLoader::Open force_async", rv);
if (rv == PP_OK_COMPLETIONPENDING)
rv = callback.WaitForResult();
if (rv != PP_OK)
@@ -339,13 +357,15 @@ std::string TestURLLoader::TestAbortCalls() {
pp::URLRequestInfo request(instance_);
request.SetURL("test_url_loader_data/hello.txt");
- TestCompletionCallback callback(instance_->pp_instance());
+ TestCompletionCallback callback(instance_->pp_instance(), force_async_);
int32_t rv;
// Abort |Open()|.
{
callback.reset_run_count();
rv = pp::URLLoader(*instance_).Open(request, callback);
+ if (force_async_ && rv != PP_OK_COMPLETIONPENDING)
+ return ReportError("URLLoader::Open force_async", rv);
if (callback.run_count() > 0)
return "URLLoader::Open ran callback synchronously.";
if (rv == PP_OK_COMPLETIONPENDING) {
@@ -363,6 +383,8 @@ std::string TestURLLoader::TestAbortCalls() {
{
pp::URLLoader loader(*instance_);
rv = loader.Open(request, callback);
+ if (force_async_ && rv != PP_OK_COMPLETIONPENDING)
+ return ReportError("URLLoader::Open force_async", rv);
if (rv == PP_OK_COMPLETIONPENDING)
rv = callback.WaitForResult();
if (rv != PP_OK)
@@ -370,6 +392,8 @@ std::string TestURLLoader::TestAbortCalls() {
callback.reset_run_count();
rv = loader.ReadResponseBody(buf, sizeof(buf), callback);
+ if (force_async_ && rv != PP_OK_COMPLETIONPENDING)
+ return ReportError("URLLoader::ReadResponseBody force_async", rv);
} // Destroy |loader|.
if (rv == PP_OK_COMPLETIONPENDING) {
// Save a copy and make sure |buf| doesn't get written to.
diff --git a/ppapi/tests/test_utils.cc b/ppapi/tests/test_utils.cc
index 01557ce..b51634bc 100644
--- a/ppapi/tests/test_utils.cc
+++ b/ppapi/tests/test_utils.cc
@@ -29,6 +29,17 @@ std::string ReportError(const char* method, int32_t error) {
TestCompletionCallback::TestCompletionCallback(PP_Instance instance)
: have_result_(false),
result_(PP_OK_COMPLETIONPENDING),
+ force_async_(false),
+ post_quit_task_(false),
+ run_count_(0),
+ instance_(instance) {
+}
+
+TestCompletionCallback::TestCompletionCallback(PP_Instance instance,
+ bool force_async)
+ : have_result_(false),
+ result_(PP_OK_COMPLETIONPENDING),
+ force_async_(force_async),
post_quit_task_(false),
run_count_(0),
instance_(instance) {
@@ -45,8 +56,10 @@ int32_t TestCompletionCallback::WaitForResult() {
}
TestCompletionCallback::operator pp::CompletionCallback() const {
+ int32_t flags = (force_async_ ? 0 : PP_COMPLETIONCALLBACK_FLAG_OPTIONAL);
return pp::CompletionCallback(&TestCompletionCallback::Handler,
- const_cast<TestCompletionCallback*>(this));
+ const_cast<TestCompletionCallback*>(this),
+ flags);
}
// static
diff --git a/ppapi/tests/test_utils.h b/ppapi/tests/test_utils.h
index 721a048..e786aa8 100644
--- a/ppapi/tests/test_utils.h
+++ b/ppapi/tests/test_utils.h
@@ -1,4 +1,4 @@
-// Copyright (c) 2010 The Chromium Authors. All rights reserved.
+// Copyright (c) 2011 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.
@@ -18,6 +18,7 @@ std::string ReportError(const char* method, int32_t error);
class TestCompletionCallback {
public:
TestCompletionCallback(PP_Instance instance);
+ TestCompletionCallback(PP_Instance instance, bool force_async);
// Waits for the callback to be called and returns the
// result. Returns immediately if the callback was previously called
@@ -38,6 +39,7 @@ class TestCompletionCallback {
bool have_result_;
int32_t result_;
+ bool force_async_;
bool post_quit_task_;
unsigned run_count_;
PP_Instance instance_;
diff --git a/ppapi/thunk/common.cc b/ppapi/thunk/common.cc
new file mode 100644
index 0000000..b59f139
--- /dev/null
+++ b/ppapi/thunk/common.cc
@@ -0,0 +1,30 @@
+// Copyright (c) 2011 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.
+
+#include "ppapi/thunk/common.h"
+
+#include "base/message_loop.h"
+#include "ppapi/c/pp_errors.h"
+
+namespace ppapi {
+namespace thunk {
+
+int32_t MayForceCallback(PP_CompletionCallback callback, int32_t result) {
+ if (result == PP_OK_COMPLETIONPENDING)
+ return result;
+
+ if (callback.func == NULL ||
+ (callback.flags & PP_COMPLETIONCALLBACK_FLAG_OPTIONAL) != 0)
+ return result;
+
+ // TODO(polina): make this work off the main thread as well
+ // (At this point this should not be an issue because PPAPI is only supported
+ // on the main thread).
+ MessageLoop::current()->PostTask(FROM_HERE, NewRunnableFunction(
+ callback.func, callback.user_data, result));
+ return PP_OK_COMPLETIONPENDING;
+}
+
+} // namespace thunk
+} // namespace ppapi
diff --git a/ppapi/thunk/common.h b/ppapi/thunk/common.h
new file mode 100644
index 0000000..7966da4
--- /dev/null
+++ b/ppapi/thunk/common.h
@@ -0,0 +1,21 @@
+// Copyright (c) 2011 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.
+
+#ifndef PPAPI_THUNK_COMMON_H_
+#define PPAPI_THUNK_COMMON_H_
+
+#include "ppapi/c/pp_completion_callback.h"
+
+namespace ppapi {
+namespace thunk {
+
+// Skips callback invocation and returns |result| if callback function is NULL
+// or PP_COMPLETIONCALLBACK_FLAG_OPTIONAL is set. Otherwise, schedules the
+// callback with |result| as an argument and returns PP_OK_COMPLETIONPENDING.
+int32_t MayForceCallback(PP_CompletionCallback callback, int32_t result);
+
+} // namespace thunk
+} // namespace ppapi
+
+#endif // PPAPI_THUNK_COMMON_H_
diff --git a/ppapi/thunk/ppb_audio_trusted_thunk.cc b/ppapi/thunk/ppb_audio_trusted_thunk.cc
index 5cb0bfd..05c1b4e 100644
--- a/ppapi/thunk/ppb_audio_trusted_thunk.cc
+++ b/ppapi/thunk/ppb_audio_trusted_thunk.cc
@@ -3,8 +3,9 @@
// found in the LICENSE file.
#include "ppapi/c/pp_errors.h"
-#include "ppapi/thunk/thunk.h"
+#include "ppapi/thunk/common.h"
#include "ppapi/thunk/enter.h"
+#include "ppapi/thunk/thunk.h"
#include "ppapi/thunk/ppb_audio_trusted_api.h"
#include "ppapi/thunk/resource_creation_api.h"
@@ -22,11 +23,12 @@ PP_Resource Create(PP_Instance instance_id) {
int32_t Open(PP_Resource audio_id,
PP_Resource config_id,
- PP_CompletionCallback created) {
+ PP_CompletionCallback create_callback) {
EnterResource<PPB_AudioTrusted_API> enter(audio_id, true);
if (enter.failed())
- return PP_ERROR_BADRESOURCE;
- return enter.object()->OpenTrusted(config_id, created);
+ return MayForceCallback(create_callback, PP_ERROR_BADRESOURCE);
+ int32_t result = enter.object()->OpenTrusted(config_id, create_callback);
+ return MayForceCallback(create_callback, result);
}
int32_t GetSyncSocket(PP_Resource audio_id, int* sync_socket) {
diff --git a/ppapi/thunk/ppb_broker_thunk.cc b/ppapi/thunk/ppb_broker_thunk.cc
index 1394ee9..1bfcea0 100644
--- a/ppapi/thunk/ppb_broker_thunk.cc
+++ b/ppapi/thunk/ppb_broker_thunk.cc
@@ -4,8 +4,9 @@
#include "ppapi/c/trusted/ppb_broker_trusted.h"
#include "ppapi/c/pp_errors.h"
-#include "ppapi/thunk/thunk.h"
+#include "ppapi/thunk/common.h"
#include "ppapi/thunk/enter.h"
+#include "ppapi/thunk/thunk.h"
#include "ppapi/thunk/ppb_broker_api.h"
#include "ppapi/thunk/resource_creation_api.h"
@@ -30,8 +31,9 @@ int32_t Connect(PP_Resource resource,
PP_CompletionCallback connect_callback) {
EnterResource<PPB_Broker_API> enter(resource, true);
if (enter.failed())
- return PP_ERROR_BADRESOURCE;
- return enter.object()->Connect(connect_callback);
+ return MayForceCallback(connect_callback, PP_ERROR_BADRESOURCE);
+ int32_t result = enter.object()->Connect(connect_callback);
+ return MayForceCallback(connect_callback, result);
}
int32_t GetHandle(PP_Resource resource, int32_t* handle) {
diff --git a/ppapi/thunk/ppb_directory_reader_thunk.cc b/ppapi/thunk/ppb_directory_reader_thunk.cc
index d1dfed4..c631194 100644
--- a/ppapi/thunk/ppb_directory_reader_thunk.cc
+++ b/ppapi/thunk/ppb_directory_reader_thunk.cc
@@ -5,8 +5,9 @@
#include "ppapi/c/dev/ppb_directory_reader_dev.h"
#include "ppapi/c/pp_completion_callback.h"
#include "ppapi/c/pp_errors.h"
-#include "ppapi/thunk/thunk.h"
+#include "ppapi/thunk/common.h"
#include "ppapi/thunk/enter.h"
+#include "ppapi/thunk/thunk.h"
#include "ppapi/thunk/ppb_directory_reader_api.h"
#include "ppapi/thunk/resource_creation_api.h"
@@ -32,8 +33,9 @@ int32_t GetNextEntry(PP_Resource directory_reader,
PP_CompletionCallback callback) {
EnterResource<PPB_DirectoryReader_API> enter(directory_reader, true);
if (enter.failed())
- return PP_ERROR_BADRESOURCE;
- return enter.object()->GetNextEntry(entry, callback);
+ return MayForceCallback(callback, PP_ERROR_BADRESOURCE);
+ int32_t result = enter.object()->GetNextEntry(entry, callback);
+ return MayForceCallback(callback, result);
}
const PPB_DirectoryReader_Dev g_ppb_directory_reader_thunk = {
diff --git a/ppapi/thunk/ppb_file_chooser_thunk.cc b/ppapi/thunk/ppb_file_chooser_thunk.cc
index 8389725..224d248 100644
--- a/ppapi/thunk/ppb_file_chooser_thunk.cc
+++ b/ppapi/thunk/ppb_file_chooser_thunk.cc
@@ -5,8 +5,9 @@
#include "ppapi/c/dev/ppb_file_chooser_dev.h"
#include "ppapi/c/pp_completion_callback.h"
#include "ppapi/c/pp_errors.h"
-#include "ppapi/thunk/thunk.h"
+#include "ppapi/thunk/common.h"
#include "ppapi/thunk/enter.h"
+#include "ppapi/thunk/thunk.h"
#include "ppapi/thunk/ppb_file_chooser_api.h"
#include "ppapi/thunk/resource_creation_api.h"
@@ -31,8 +32,9 @@ PP_Bool IsFileChooser(PP_Resource resource) {
int32_t Show(PP_Resource chooser, PP_CompletionCallback callback) {
EnterResource<PPB_FileChooser_API> enter(chooser, true);
if (enter.failed())
- return PP_ERROR_BADRESOURCE;
- return enter.object()->Show(callback);
+ return MayForceCallback(callback, PP_ERROR_BADRESOURCE);
+ int32_t result = enter.object()->Show(callback);
+ return MayForceCallback(callback, result);
}
PP_Resource GetNextChosenFile(PP_Resource chooser) {
diff --git a/ppapi/thunk/ppb_file_io_thunk.cc b/ppapi/thunk/ppb_file_io_thunk.cc
index 2aaaaa4..5c1f935 100644
--- a/ppapi/thunk/ppb_file_io_thunk.cc
+++ b/ppapi/thunk/ppb_file_io_thunk.cc
@@ -5,8 +5,9 @@
#include "ppapi/c/dev/ppb_file_io_dev.h"
#include "ppapi/c/pp_completion_callback.h"
#include "ppapi/c/pp_errors.h"
-#include "ppapi/thunk/thunk.h"
+#include "ppapi/thunk/common.h"
#include "ppapi/thunk/enter.h"
+#include "ppapi/thunk/thunk.h"
#include "ppapi/thunk/ppb_file_io_api.h"
#include "ppapi/thunk/resource_creation_api.h"
@@ -33,8 +34,9 @@ int32_t Open(PP_Resource file_io,
PP_CompletionCallback callback) {
EnterResource<PPB_FileIO_API> enter(file_io, true);
if (enter.failed())
- return PP_ERROR_BADRESOURCE;
- return enter.object()->Open(file_ref, open_flags, callback);
+ return MayForceCallback(callback, PP_ERROR_BADRESOURCE);
+ int32_t result = enter.object()->Open(file_ref, open_flags, callback);
+ return MayForceCallback(callback, result);
}
int32_t Query(PP_Resource file_io,
@@ -42,8 +44,9 @@ int32_t Query(PP_Resource file_io,
PP_CompletionCallback callback) {
EnterResource<PPB_FileIO_API> enter(file_io, true);
if (enter.failed())
- return PP_ERROR_BADRESOURCE;
- return enter.object()->Query(info, callback);
+ return MayForceCallback(callback, PP_ERROR_BADRESOURCE);
+ int32_t result = enter.object()->Query(info, callback);
+ return MayForceCallback(callback, result);
}
int32_t Touch(PP_Resource file_io,
@@ -52,8 +55,10 @@ int32_t Touch(PP_Resource file_io,
PP_CompletionCallback callback) {
EnterResource<PPB_FileIO_API> enter(file_io, true);
if (enter.failed())
- return PP_ERROR_BADRESOURCE;
- return enter.object()->Touch(last_access_time, last_modified_time, callback);
+ return MayForceCallback(callback, PP_ERROR_BADRESOURCE);
+ int32_t result = enter.object()->Touch(last_access_time, last_modified_time,
+ callback);
+ return MayForceCallback(callback, result);
}
int32_t Read(PP_Resource file_io,
@@ -63,8 +68,10 @@ int32_t Read(PP_Resource file_io,
PP_CompletionCallback callback) {
EnterResource<PPB_FileIO_API> enter(file_io, true);
if (enter.failed())
- return PP_ERROR_BADRESOURCE;
- return enter.object()->Read(offset, buffer, bytes_to_read, callback);
+ return MayForceCallback(callback, PP_ERROR_BADRESOURCE);
+ int32_t result = enter.object()->Read(offset, buffer, bytes_to_read,
+ callback);
+ return MayForceCallback(callback, result);
}
int32_t Write(PP_Resource file_io,
@@ -74,8 +81,10 @@ int32_t Write(PP_Resource file_io,
PP_CompletionCallback callback) {
EnterResource<PPB_FileIO_API> enter(file_io, true);
if (enter.failed())
- return PP_ERROR_BADRESOURCE;
- return enter.object()->Write(offset, buffer, bytes_to_write, callback);
+ return MayForceCallback(callback, PP_ERROR_BADRESOURCE);
+ int32_t result = enter.object()->Write(offset, buffer, bytes_to_write,
+ callback);
+ return MayForceCallback(callback, result);
}
int32_t SetLength(PP_Resource file_io,
@@ -83,16 +92,18 @@ int32_t SetLength(PP_Resource file_io,
PP_CompletionCallback callback) {
EnterResource<PPB_FileIO_API> enter(file_io, true);
if (enter.failed())
- return PP_ERROR_BADRESOURCE;
- return enter.object()->SetLength(length, callback);
+ return MayForceCallback(callback, PP_ERROR_BADRESOURCE);
+ int32_t result = enter.object()->SetLength(length, callback);
+ return MayForceCallback(callback, result);
}
int32_t Flush(PP_Resource file_io,
PP_CompletionCallback callback) {
EnterResource<PPB_FileIO_API> enter(file_io, true);
if (enter.failed())
- return PP_ERROR_BADRESOURCE;
- return enter.object()->Flush(callback);
+ return MayForceCallback(callback, PP_ERROR_BADRESOURCE);
+ int32_t result = enter.object()->Flush(callback);
+ return MayForceCallback(callback, result);
}
void Close(PP_Resource file_io) {
diff --git a/ppapi/thunk/ppb_file_io_trusted_thunk.cc b/ppapi/thunk/ppb_file_io_trusted_thunk.cc
index 1cba025..38ad460 100644
--- a/ppapi/thunk/ppb_file_io_trusted_thunk.cc
+++ b/ppapi/thunk/ppb_file_io_trusted_thunk.cc
@@ -5,8 +5,9 @@
#include "ppapi/c/dev/ppb_file_io_trusted_dev.h"
#include "ppapi/c/pp_completion_callback.h"
#include "ppapi/c/pp_errors.h"
-#include "ppapi/thunk/thunk.h"
+#include "ppapi/thunk/common.h"
#include "ppapi/thunk/enter.h"
+#include "ppapi/thunk/thunk.h"
#include "ppapi/thunk/ppb_file_io_api.h"
#include "ppapi/thunk/resource_creation_api.h"
@@ -28,8 +29,9 @@ int32_t WillWrite(PP_Resource file_io,
PP_CompletionCallback callback) {
EnterResource<PPB_FileIO_API> enter(file_io, true);
if (enter.failed())
- return PP_ERROR_BADRESOURCE;
- return enter.object()->WillWrite(offset, bytes_to_write, callback);
+ return MayForceCallback(callback, PP_ERROR_BADRESOURCE);
+ int32_t result = enter.object()->WillWrite(offset, bytes_to_write, callback);
+ return MayForceCallback(callback, result);
}
int32_t WillSetLength(PP_Resource file_io,
@@ -37,8 +39,9 @@ int32_t WillSetLength(PP_Resource file_io,
PP_CompletionCallback callback) {
EnterResource<PPB_FileIO_API> enter(file_io, true);
if (enter.failed())
- return PP_ERROR_BADRESOURCE;
- return enter.object()->WillSetLength(length, callback);
+ return MayForceCallback(callback, PP_ERROR_BADRESOURCE);
+ int32_t result = enter.object()->WillSetLength(length, callback);
+ return MayForceCallback(callback, result);
}
const PPB_FileIOTrusted_Dev g_ppb_file_io_trusted_thunk = {
diff --git a/ppapi/thunk/ppb_file_ref_thunk.cc b/ppapi/thunk/ppb_file_ref_thunk.cc
index aeac135..af8de13 100644
--- a/ppapi/thunk/ppb_file_ref_thunk.cc
+++ b/ppapi/thunk/ppb_file_ref_thunk.cc
@@ -6,8 +6,9 @@
#include "ppapi/c/dev/ppb_file_ref_dev.h"
#include "ppapi/c/pp_completion_callback.h"
#include "ppapi/c/pp_errors.h"
-#include "ppapi/thunk/thunk.h"
+#include "ppapi/thunk/common.h"
#include "ppapi/thunk/enter.h"
+#include "ppapi/thunk/thunk.h"
#include "ppapi/thunk/ppb_file_ref_api.h"
#include "ppapi/thunk/resource_creation_api.h"
@@ -61,8 +62,9 @@ int32_t MakeDirectory(PP_Resource directory_ref,
PP_CompletionCallback callback) {
EnterResource<PPB_FileRef_API> enter(directory_ref, true);
if (enter.failed())
- return PP_ERROR_BADRESOURCE;
- return enter.object()->MakeDirectory(make_ancestors, callback);
+ return MayForceCallback(callback, PP_ERROR_BADRESOURCE);
+ int32_t result = enter.object()->MakeDirectory(make_ancestors, callback);
+ return MayForceCallback(callback, result);
}
int32_t Touch(PP_Resource file_ref,
@@ -71,16 +73,19 @@ int32_t Touch(PP_Resource file_ref,
PP_CompletionCallback callback) {
EnterResource<PPB_FileRef_API> enter(file_ref, true);
if (enter.failed())
- return PP_ERROR_BADRESOURCE;
- return enter.object()->Touch(last_access_time, last_modified_time, callback);
+ return MayForceCallback(callback, PP_ERROR_BADRESOURCE);
+ int32_t result = enter.object()->Touch(last_access_time, last_modified_time,
+ callback);
+ return MayForceCallback(callback, result);
}
int32_t Delete(PP_Resource file_ref,
PP_CompletionCallback callback) {
EnterResource<PPB_FileRef_API> enter(file_ref, true);
if (enter.failed())
- return PP_ERROR_BADRESOURCE;
- return enter.object()->Delete(callback);
+ return MayForceCallback(callback, PP_ERROR_BADRESOURCE);
+ int32_t result = enter.object()->Delete(callback);
+ return MayForceCallback(callback, result);
}
int32_t Rename(PP_Resource file_ref,
@@ -88,8 +93,9 @@ int32_t Rename(PP_Resource file_ref,
PP_CompletionCallback callback) {
EnterResource<PPB_FileRef_API> enter(file_ref, true);
if (enter.failed())
- return PP_ERROR_BADRESOURCE;
- return enter.object()->Rename(new_file_ref, callback);
+ return MayForceCallback(callback, PP_ERROR_BADRESOURCE);
+ int32_t result = enter.object()->Rename(new_file_ref, callback);
+ return MayForceCallback(callback, result);
}
const PPB_FileRef_Dev g_ppb_file_ref_thunk = {
diff --git a/ppapi/thunk/ppb_file_system_thunk.cc b/ppapi/thunk/ppb_file_system_thunk.cc
index e1c4f6a..0d4099e 100644
--- a/ppapi/thunk/ppb_file_system_thunk.cc
+++ b/ppapi/thunk/ppb_file_system_thunk.cc
@@ -5,8 +5,9 @@
#include "ppapi/c/dev/ppb_file_system_dev.h"
#include "ppapi/c/pp_completion_callback.h"
#include "ppapi/c/pp_errors.h"
-#include "ppapi/thunk/thunk.h"
+#include "ppapi/thunk/common.h"
#include "ppapi/thunk/enter.h"
+#include "ppapi/thunk/thunk.h"
#include "ppapi/thunk/ppb_file_system_api.h"
#include "ppapi/thunk/resource_creation_api.h"
@@ -32,8 +33,9 @@ int32_t Open(PP_Resource file_system,
PP_CompletionCallback callback) {
EnterResource<PPB_FileSystem_API> enter(file_system, true);
if (enter.failed())
- return PP_ERROR_BADRESOURCE;
- return enter.object()->Open(expected_size, callback);
+ return MayForceCallback(callback, PP_ERROR_BADRESOURCE);
+ int32_t result = enter.object()->Open(expected_size, callback);
+ return MayForceCallback(callback, result);
}
PP_FileSystemType_Dev GetType(PP_Resource file_system) {
diff --git a/ppapi/thunk/ppb_flash_menu_thunk.cc b/ppapi/thunk/ppb_flash_menu_thunk.cc
index f24ff72..3641e1e 100644
--- a/ppapi/thunk/ppb_flash_menu_thunk.cc
+++ b/ppapi/thunk/ppb_flash_menu_thunk.cc
@@ -5,8 +5,9 @@
#include "ppapi/c/private/ppb_flash_menu.h"
#include "ppapi/c/pp_completion_callback.h"
#include "ppapi/c/pp_errors.h"
-#include "ppapi/thunk/thunk.h"
+#include "ppapi/thunk/common.h"
#include "ppapi/thunk/enter.h"
+#include "ppapi/thunk/thunk.h"
#include "ppapi/thunk/ppb_flash_menu_api.h"
#include "ppapi/thunk/resource_creation_api.h"
@@ -33,8 +34,9 @@ int32_t Show(PP_Resource resource,
PP_CompletionCallback callback) {
EnterResource<PPB_Flash_Menu_API> enter(resource, true);
if (enter.failed())
- return PP_ERROR_BADRESOURCE;
- return enter.object()->Show(location, selected_id, callback);
+ return MayForceCallback(callback, PP_ERROR_BADRESOURCE);
+ int32_t result = enter.object()->Show(location, selected_id, callback);
+ return MayForceCallback(callback, result);
}
const PPB_Flash_Menu g_ppb_flash_menu_thunk = {
@@ -51,4 +53,3 @@ const PPB_Flash_Menu* GetPPB_Flash_Menu_Thunk() {
} // namespace thunk
} // namespace ppapi
-
diff --git a/ppapi/thunk/ppb_flash_net_connector_thunk.cc b/ppapi/thunk/ppb_flash_net_connector_thunk.cc
index e0bb05c..14cf751 100644
--- a/ppapi/thunk/ppb_flash_net_connector_thunk.cc
+++ b/ppapi/thunk/ppb_flash_net_connector_thunk.cc
@@ -5,8 +5,9 @@
#include "ppapi/c/private/ppb_flash_net_connector.h"
#include "ppapi/c/pp_completion_callback.h"
#include "ppapi/c/pp_errors.h"
-#include "ppapi/thunk/thunk.h"
+#include "ppapi/thunk/common.h"
#include "ppapi/thunk/enter.h"
+#include "ppapi/thunk/thunk.h"
#include "ppapi/thunk/ppb_flash_net_connector_api.h"
#include "ppapi/thunk/resource_creation_api.h"
@@ -36,9 +37,11 @@ int32_t ConnectTcp(PP_Resource resource,
PP_CompletionCallback callback) {
EnterResource<PPB_Flash_NetConnector_API> enter(resource, true);
if (enter.failed())
- return PP_ERROR_BADRESOURCE;
- return enter.object()->ConnectTcp(host, port, socket_out, local_addr_out,
- remote_addr_out, callback);
+ return MayForceCallback(callback, PP_ERROR_BADRESOURCE);
+ int32_t result =
+ enter.object()->ConnectTcp(host, port, socket_out, local_addr_out,
+ remote_addr_out, callback);
+ return MayForceCallback(callback, result);
}
int32_t ConnectTcpAddress(PP_Resource resource,
@@ -49,9 +52,11 @@ int32_t ConnectTcpAddress(PP_Resource resource,
PP_CompletionCallback callback) {
EnterResource<PPB_Flash_NetConnector_API> enter(resource, true);
if (enter.failed())
- return PP_ERROR_BADRESOURCE;
- return enter.object()->ConnectTcpAddress(addr, socket_out, local_addr_out,
+ return MayForceCallback(callback, PP_ERROR_BADRESOURCE);
+ int32_t result =
+ enter.object()->ConnectTcpAddress(addr, socket_out, local_addr_out,
remote_addr_out, callback);
+ return MayForceCallback(callback, result);
}
const PPB_Flash_NetConnector g_ppb_flash_net_connector_thunk = {
@@ -69,4 +74,3 @@ const PPB_Flash_NetConnector* GetPPB_Flash_NetConnector_Thunk() {
} // namespace thunk
} // namespace ppapi
-
diff --git a/ppapi/thunk/ppb_graphics_2d_thunk.cc b/ppapi/thunk/ppb_graphics_2d_thunk.cc
index c26cac8..65aa4b0 100644
--- a/ppapi/thunk/ppb_graphics_2d_thunk.cc
+++ b/ppapi/thunk/ppb_graphics_2d_thunk.cc
@@ -5,6 +5,7 @@
#include "ppapi/c/pp_completion_callback.h"
#include "ppapi/c/pp_errors.h"
#include "ppapi/c/ppb_graphics_2d.h"
+#include "ppapi/thunk/common.h"
#include "ppapi/thunk/enter.h"
#include "ppapi/thunk/ppb_graphics_2d_api.h"
#include "ppapi/thunk/resource_creation_api.h"
@@ -71,8 +72,9 @@ int32_t Flush(PP_Resource graphics_2d,
PP_CompletionCallback callback) {
EnterResource<PPB_Graphics2D_API> enter(graphics_2d, true);
if (enter.failed())
- return PP_ERROR_BADRESOURCE;
- return enter.object()->Flush(callback);
+ return MayForceCallback(callback, PP_ERROR_BADRESOURCE);
+ int32_t result = enter.object()->Flush(callback);
+ return MayForceCallback(callback, result);
}
const PPB_Graphics2D g_ppb_graphics_2d_thunk = {
diff --git a/ppapi/thunk/ppb_graphics_3d_thunk.cc b/ppapi/thunk/ppb_graphics_3d_thunk.cc
index edac937..c3363f20 100644
--- a/ppapi/thunk/ppb_graphics_3d_thunk.cc
+++ b/ppapi/thunk/ppb_graphics_3d_thunk.cc
@@ -4,8 +4,9 @@
#include "ppapi/c/pp_completion_callback.h"
#include "ppapi/c/pp_errors.h"
-#include "ppapi/thunk/thunk.h"
+#include "ppapi/thunk/common.h"
#include "ppapi/thunk/enter.h"
+#include "ppapi/thunk/thunk.h"
#include "ppapi/thunk/ppb_graphics_3d_api.h"
#include "ppapi/thunk/resource_creation_api.h"
@@ -66,8 +67,9 @@ int32_t SetAttribs(PP_Resource graphics_3d, int32_t* attrib_list) {
int32_t SwapBuffers(PP_Resource graphics_3d, PP_CompletionCallback callback) {
EnterGraphics3D enter(graphics_3d, true);
if (enter.failed())
- return PP_ERROR_BADRESOURCE;
- return enter.object()->SwapBuffers(callback);
+ return MayForceCallback(callback, PP_ERROR_BADRESOURCE);
+ int32_t result = enter.object()->SwapBuffers(callback);
+ return MayForceCallback(callback, result);
}
const PPB_Graphics3D_Dev g_ppb_graphics_3d_thunk = {
diff --git a/ppapi/thunk/ppb_layer_compositor_thunk.cc b/ppapi/thunk/ppb_layer_compositor_thunk.cc
index 3e5cbef..783ad4d 100644
--- a/ppapi/thunk/ppb_layer_compositor_thunk.cc
+++ b/ppapi/thunk/ppb_layer_compositor_thunk.cc
@@ -4,8 +4,9 @@
#include "ppapi/c/pp_errors.h"
#include "ppapi/c/dev/ppb_layer_compositor_dev.h"
-#include "ppapi/thunk/thunk.h"
+#include "ppapi/thunk/common.h"
#include "ppapi/thunk/enter.h"
+#include "ppapi/thunk/thunk.h"
#include "ppapi/thunk/ppb_layer_compositor_api.h"
#include "ppapi/thunk/resource_creation_api.h"
@@ -45,7 +46,7 @@ void MarkAsDirty(PP_Resource compositor, PP_Resource layer) {
int32_t SwapBuffers(PP_Resource compositor,
struct PP_CompletionCallback callback) {
- return PP_ERROR_FAILED;
+ return MayForceCallback(callback, PP_ERROR_FAILED);
}
const PPB_LayerCompositor_Dev g_ppb_layer_compositor_thunk = {
diff --git a/ppapi/thunk/ppb_surface_3d_thunk.cc b/ppapi/thunk/ppb_surface_3d_thunk.cc
index 0c6d9e6..e7034cb 100644
--- a/ppapi/thunk/ppb_surface_3d_thunk.cc
+++ b/ppapi/thunk/ppb_surface_3d_thunk.cc
@@ -3,8 +3,9 @@
// found in the LICENSE file.
#include "ppapi/c/pp_errors.h"
-#include "ppapi/thunk/thunk.h"
+#include "ppapi/thunk/common.h"
#include "ppapi/thunk/enter.h"
+#include "ppapi/thunk/thunk.h"
#include "ppapi/thunk/ppb_surface_3d_api.h"
#include "ppapi/thunk/resource_creation_api.h"
@@ -47,8 +48,9 @@ int32_t SwapBuffers(PP_Resource surface,
PP_CompletionCallback callback) {
EnterResource<PPB_Surface3D_API> enter(surface, true);
if (enter.failed())
- return PP_ERROR_BADRESOURCE;
- return enter.object()->SwapBuffers(callback);
+ return MayForceCallback(callback, PP_ERROR_BADRESOURCE);
+ int32_t result = enter.object()->SwapBuffers(callback);
+ return MayForceCallback(callback, result);
}
const PPB_Surface3D_Dev g_ppb_surface_3d_thunk = {
diff --git a/ppapi/thunk/ppb_transport_thunk.cc b/ppapi/thunk/ppb_transport_thunk.cc
index 50ad4aa..cf573c5 100644
--- a/ppapi/thunk/ppb_transport_thunk.cc
+++ b/ppapi/thunk/ppb_transport_thunk.cc
@@ -4,8 +4,9 @@
#include "ppapi/c/pp_completion_callback.h"
#include "ppapi/c/pp_errors.h"
-#include "ppapi/thunk/thunk.h"
+#include "ppapi/thunk/common.h"
#include "ppapi/thunk/enter.h"
+#include "ppapi/thunk/thunk.h"
#include "ppapi/thunk/ppb_transport_api.h"
#include "ppapi/thunk/resource_creation_api.h"
@@ -38,16 +39,18 @@ PP_Bool IsWritable(PP_Resource transport) {
int32_t Connect(PP_Resource transport, PP_CompletionCallback callback) {
EnterTransport enter(transport, true);
if (enter.failed())
- return PP_ERROR_BADRESOURCE;
- return enter.object()->Connect(callback);
+ return MayForceCallback(callback, PP_ERROR_BADRESOURCE);
+ int32_t result = enter.object()->Connect(callback);
+ return MayForceCallback(callback, result);
}
int32_t GetNextAddress(PP_Resource transport, PP_Var* address,
PP_CompletionCallback callback) {
EnterTransport enter(transport, true);
if (enter.failed())
- return PP_ERROR_BADRESOURCE;
- return enter.object()->GetNextAddress(address, callback);
+ return MayForceCallback(callback, PP_ERROR_BADRESOURCE);
+ int32_t result = enter.object()->GetNextAddress(address, callback);
+ return MayForceCallback(callback, result);
}
int32_t ReceiveRemoteAddress(PP_Resource transport, PP_Var address) {
@@ -61,16 +64,18 @@ int32_t Recv(PP_Resource transport, void* data, uint32_t len,
PP_CompletionCallback callback) {
EnterTransport enter(transport, true);
if (enter.failed())
- return PP_ERROR_BADRESOURCE;
- return enter.object()->Recv(data, len, callback);
+ return MayForceCallback(callback, PP_ERROR_BADRESOURCE);
+ int32_t result = enter.object()->Recv(data, len, callback);
+ return MayForceCallback(callback, result);
}
int32_t Send(PP_Resource transport, const void* data, uint32_t len,
PP_CompletionCallback callback) {
EnterTransport enter(transport, true);
if (enter.failed())
- return PP_ERROR_BADRESOURCE;
- return enter.object()->Send(data, len, callback);
+ return MayForceCallback(callback, PP_ERROR_BADRESOURCE);
+ int32_t result = enter.object()->Send(data, len, callback);
+ return MayForceCallback(callback, result);
}
int32_t Close(PP_Resource transport) {
diff --git a/ppapi/thunk/ppb_url_loader_thunk.cc b/ppapi/thunk/ppb_url_loader_thunk.cc
index e5c0b5a..236144f 100644
--- a/ppapi/thunk/ppb_url_loader_thunk.cc
+++ b/ppapi/thunk/ppb_url_loader_thunk.cc
@@ -4,8 +4,9 @@
#include "ppapi/c/pp_completion_callback.h"
#include "ppapi/c/pp_errors.h"
-#include "ppapi/thunk/thunk.h"
+#include "ppapi/thunk/common.h"
#include "ppapi/thunk/enter.h"
+#include "ppapi/thunk/thunk.h"
#include "ppapi/thunk/ppb_url_loader_api.h"
#include "ppapi/thunk/resource_creation_api.h"
@@ -31,16 +32,18 @@ int32_t Open(PP_Resource loader,
PP_CompletionCallback callback) {
EnterResource<PPB_URLLoader_API> enter(loader, true);
if (enter.failed())
- return PP_ERROR_BADRESOURCE;
- return enter.object()->Open(request_id, callback);
+ return MayForceCallback(callback, PP_ERROR_BADRESOURCE);
+ int32_t result = enter.object()->Open(request_id, callback);
+ return MayForceCallback(callback, result);
}
int32_t FollowRedirect(PP_Resource loader,
PP_CompletionCallback callback) {
EnterResource<PPB_URLLoader_API> enter(loader, true);
if (enter.failed())
- return PP_ERROR_BADRESOURCE;
- return enter.object()->FollowRedirect(callback);
+ return MayForceCallback(callback, PP_ERROR_BADRESOURCE);
+ int32_t result = enter.object()->FollowRedirect(callback);
+ return MayForceCallback(callback, result);
}
PP_Bool GetUploadProgress(PP_Resource loader,
@@ -82,16 +85,19 @@ int32_t ReadResponseBody(PP_Resource loader,
PP_CompletionCallback callback) {
EnterResource<PPB_URLLoader_API> enter(loader, true);
if (enter.failed())
- return PP_ERROR_BADRESOURCE;
- return enter.object()->ReadResponseBody(buffer, bytes_to_read, callback);
+ return MayForceCallback(callback, PP_ERROR_BADRESOURCE);
+ int32_t result = enter.object()->ReadResponseBody(buffer, bytes_to_read,
+ callback);
+ return MayForceCallback(callback, result);
}
int32_t FinishStreamingToFile(PP_Resource loader,
PP_CompletionCallback callback) {
EnterResource<PPB_URLLoader_API> enter(loader, true);
if (enter.failed())
- return PP_ERROR_BADRESOURCE;
- return enter.object()->FinishStreamingToFile(callback);
+ return MayForceCallback(callback, PP_ERROR_BADRESOURCE);
+ int32_t result = enter.object()->FinishStreamingToFile(callback);
+ return MayForceCallback(callback, result);
}
void Close(PP_Resource loader) {
diff --git a/ppapi/thunk/ppb_video_decoder_thunk.cc b/ppapi/thunk/ppb_video_decoder_thunk.cc
index f12a5b3..9d82113 100644
--- a/ppapi/thunk/ppb_video_decoder_thunk.cc
+++ b/ppapi/thunk/ppb_video_decoder_thunk.cc
@@ -3,8 +3,9 @@
// found in the LICENSE file.
#include "ppapi/c/pp_errors.h"
-#include "ppapi/thunk/thunk.h"
+#include "ppapi/thunk/common.h"
#include "ppapi/thunk/enter.h"
+#include "ppapi/thunk/thunk.h"
#include "ppapi/thunk/ppb_video_decoder_api.h"
#include "ppapi/thunk/resource_creation_api.h"
@@ -46,8 +47,10 @@ int32_t Initialize(PP_Resource video_decoder,
PP_CompletionCallback callback) {
EnterVideoDecoder enter(video_decoder, true);
if (enter.failed())
- return PP_ERROR_BADRESOURCE;
- return enter.object()->Initialize(context_id, decoder_config, callback);
+ return MayForceCallback(callback, PP_ERROR_BADRESOURCE);
+ int32_t result =
+ enter.object()->Initialize(context_id, decoder_config, callback);
+ return MayForceCallback(callback, result);
}
int32_t Decode(PP_Resource video_decoder,
@@ -55,8 +58,9 @@ int32_t Decode(PP_Resource video_decoder,
PP_CompletionCallback callback) {
EnterVideoDecoder enter(video_decoder, true);
if (enter.failed())
- return PP_ERROR_BADRESOURCE;
- return enter.object()->Decode(bitstream_buffer, callback);
+ return MayForceCallback(callback, PP_ERROR_BADRESOURCE);
+ int32_t result = enter.object()->Decode(bitstream_buffer, callback);
+ return MayForceCallback(callback, result);
}
void AssignGLESBuffers(PP_Resource video_decoder,
@@ -84,16 +88,18 @@ void ReusePictureBuffer(PP_Resource video_decoder, int32_t picture_buffer_id) {
int32_t Flush(PP_Resource video_decoder, PP_CompletionCallback callback) {
EnterVideoDecoder enter(video_decoder, true);
if (enter.failed())
- return PP_ERROR_BADRESOURCE;
- return enter.object()->Flush(callback);
+ return MayForceCallback(callback, PP_ERROR_BADRESOURCE);
+ int32_t result = enter.object()->Flush(callback);
+ return MayForceCallback(callback, result);
}
int32_t Abort(PP_Resource video_decoder,
PP_CompletionCallback callback) {
EnterVideoDecoder enter(video_decoder, true);
if (enter.failed())
- return PP_ERROR_BADRESOURCE;
- return enter.object()->Abort(callback);
+ return MayForceCallback(callback, PP_ERROR_BADRESOURCE);
+ int32_t result = enter.object()->Abort(callback);
+ return MayForceCallback(callback, result);
}
const PPB_VideoDecoder_Dev g_ppb_videodecoder_thunk = {
diff --git a/remoting/client/plugin/pepper_port_allocator_session.cc b/remoting/client/plugin/pepper_port_allocator_session.cc
index 8c5c598..ec7544e9 100644
--- a/remoting/client/plugin/pepper_port_allocator_session.cc
+++ b/remoting/client/plugin/pepper_port_allocator_session.cc
@@ -121,7 +121,7 @@ class PepperURLFetcher {
fetch_callback_.reset(fetch_callback);
pp::CompletionCallback callback =
- callback_factory_.NewCallback(&PepperURLFetcher::DidOpen);
+ callback_factory_.NewOptionalCallback(&PepperURLFetcher::DidOpen);
int rv = loader_.Open(request, callback);
if (rv != PP_OK_COMPLETIONPENDING)
callback.Run(rv);
@@ -130,7 +130,7 @@ class PepperURLFetcher {
private:
void ReadMore() {
pp::CompletionCallback callback =
- callback_factory_.NewCallback(&PepperURLFetcher::DidRead);
+ callback_factory_.NewOptionalCallback(&PepperURLFetcher::DidRead);
int rv = loader_.ReadResponseBody(buf_, sizeof(buf_), callback);
if (rv != PP_OK_COMPLETIONPENDING)
callback.Run(rv);