diff options
author | Andras Becsi <andras.becsi@digia.com> | 2013-12-11 21:33:03 +0100 |
---|---|---|
committer | Andras Becsi <andras.becsi@digia.com> | 2013-12-13 12:34:07 +0100 |
commit | f2a33ff9cbc6d19943f1c7fbddd1f23d23975577 (patch) | |
tree | 0586a32aa390ade8557dfd6b4897f43a07449578 /chromium/ppapi | |
parent | 5362912cdb5eea702b68ebe23702468d17c3017a (diff) | |
download | qtwebengine-chromium-f2a33ff9cbc6d19943f1c7fbddd1f23d23975577.tar.gz |
Update Chromium to branch 1650 (31.0.1650.63)
Change-Id: I57d8c832eaec1eb2364e0a8e7352a6dd354db99f
Reviewed-by: Jocelyn Turcotte <jocelyn.turcotte@digia.com>
Diffstat (limited to 'chromium/ppapi')
247 files changed, 6120 insertions, 5803 deletions
diff --git a/chromium/ppapi/OWNERS b/chromium/ppapi/OWNERS index a114912608e..c4871e2a789 100644 --- a/chromium/ppapi/OWNERS +++ b/chromium/ppapi/OWNERS @@ -1,3 +1,4 @@ +bbudge@chromium.org brettw@chromium.org dmichael@chromium.org raymes@chromium.org diff --git a/chromium/ppapi/PRESUBMIT.py b/chromium/ppapi/PRESUBMIT.py index 0ae9b0e37e4..7d6a400bd4d 100644 --- a/chromium/ppapi/PRESUBMIT.py +++ b/chromium/ppapi/PRESUBMIT.py @@ -159,6 +159,7 @@ def CheckChange(input_api, output_api): files = input_api.LocalPaths() h_files = [] idl_files = [] + generators_changed = False # Find all relevant .h and .idl files. for filename in files: @@ -166,8 +167,10 @@ def CheckChange(input_api, output_api): name_parts = name.split(os.sep) if name_parts[0:2] == ['ppapi', 'c'] and ext == '.h': h_files.append('/'.join(name_parts[2:])) - if name_parts[0:2] == ['ppapi', 'api'] and ext == '.idl': + elif name_parts[0:2] == ['ppapi', 'api'] and ext == '.idl': idl_files.append('/'.join(name_parts[2:])) + elif name_parts[0:2] == ['ppapi', 'generators']: + generators_changed = True # Generate a list of all appropriate *.h and *.idl changes in this CL. both = h_files + idl_files @@ -247,10 +250,20 @@ def CheckChange(input_api, output_api): long_text='\n'.join(missing_dev))) if missing_stable: - results.append( - output_api.PresubmitError( - 'Missing PPAPI IDL for stable interface:', - long_text='\n'.join(missing_stable))) + # It might be okay that the header changed without a corresponding IDL + # change. E.g., comment indenting may have been changed. Treat this as a + # warning. + if generators_changed: + results.append( + output_api.PresubmitPromptWarning( + 'Missing PPAPI IDL for stable interface (due to change in ' + + 'generators?):', + long_text='\n'.join(missing_stable))) + else: + results.append( + output_api.PresubmitError( + 'Missing PPAPI IDL for stable interface:', + long_text='\n'.join(missing_stable))) # Verify all *.h files match *.idl definitions, use: # --test to prevent output to disk diff --git a/chromium/ppapi/api/dev/ppb_keyboard_input_event_dev.idl b/chromium/ppapi/api/dev/ppb_keyboard_input_event_dev.idl index 02f20b3e803..0612b99411d 100644 --- a/chromium/ppapi/api/dev/ppb_keyboard_input_event_dev.idl +++ b/chromium/ppapi/api/dev/ppb_keyboard_input_event_dev.idl @@ -10,14 +10,14 @@ */ label Chrome { - M19 = 0.1 + M31 = 0.2 }; /** * The <code>PPB_KeyboardInputEvent_Dev</code> interface is an extension to the * PPB_KeyboardInputEvent</code> interface that provides */ -[version=0.1, macro="PPB_KEYBOARD_INPUT_EVENT_DEV_INTERFACE"] +[macro="PPB_KEYBOARD_INPUT_EVENT_DEV_INTERFACE"] interface PPB_KeyboardInputEvent_Dev { /** * This sets a USB key code in the given <code>PP_Resource</code>. It is @@ -33,7 +33,7 @@ interface PPB_KeyboardInputEvent_Dev { * @return <code>PP_TRUE</code> if the USB key code was set successfully. */ PP_Bool SetUsbKeyCode([in] PP_Resource key_event, - [in] uint32_t usb_key_code); + [in] uint32_t usb_key_code); /** * GetUsbKeyCode() returns the USB key code associated with this keyboard @@ -47,4 +47,14 @@ interface PPB_KeyboardInputEvent_Dev { * a 0 is returned. */ uint32_t GetUsbKeyCode([in] PP_Resource key_event); + + /** + * GetCode() returns the DOM |code| field for this keyboard event, as + * defined by the UI Events spec: http://www.w3.org/TR/uievents/ + * + * @param[in] key_event The key event for which to return the key code. + * + * @return The string that contains the DOM |code| for the keyboard event. + */ + PP_Var GetCode([in] PP_Resource key_event); }; diff --git a/chromium/ppapi/api/dev/ppb_url_util_dev.idl b/chromium/ppapi/api/dev/ppb_url_util_dev.idl index 0e4b5408f85..6cd0e756740 100644 --- a/chromium/ppapi/api/dev/ppb_url_util_dev.idl +++ b/chromium/ppapi/api/dev/ppb_url_util_dev.idl @@ -7,8 +7,11 @@ * This file defines the <code>PPB_URLUtil_Dev</code> interface. */ +[generate_thunk] + label Chrome { - M17 = 0.6 + M17 = 0.6, + M31 = 0.7 }; /* @@ -146,4 +149,16 @@ interface PPB_URLUtil_Dev { */ PP_Var GetPluginInstanceURL([in] PP_Instance instance, [out] PP_URLComponents_Dev components); + + /* + * Returns the Referrer URL of the HTTP request that loaded the plugin. This + * is the value of the 'Referer' header of the request. An undefined value + * means the 'Referer' header was absent. + * The components pointer, if non-NULL and the canonicalized URL is valid, + * will identify the components of the resulting URL. Components may be NULL + * to specify that no component information is necessary. + */ + [version=0.7] + PP_Var GetPluginReferrerURL([in] PP_Instance instance, + [out] PP_URLComponents_Dev components); }; diff --git a/chromium/ppapi/api/pp_var.idl b/chromium/ppapi/api/pp_var.idl index fda2332b895..425d99ba7bf 100644 --- a/chromium/ppapi/api/pp_var.idl +++ b/chromium/ppapi/api/pp_var.idl @@ -44,23 +44,33 @@ enum PP_VarType { /** * The Var represents a string. The <code>as_id</code> field is used to * identify the string, which may be created and retrieved from the - * <code>PPB_Var</code> interface. + * <code>PPB_Var</code> interface. These objects are reference counted, so + * AddRef and Release must be used properly to avoid memory leaks. */ PP_VARTYPE_STRING = 5, /** * Represents a JavaScript object. This vartype is not currently usable - * from modules, although it is used internally for some tasks. + * from modules, although it is used internally for some tasks. These objects + * are reference counted, so AddRef and Release must be used properly to avoid + * memory leaks. */ PP_VARTYPE_OBJECT = 6, /** - * Arrays and dictionaries are not currently supported but will be added - * in future revisions. These objects are reference counted so be sure - * to properly AddRef/Release them as you would with strings to ensure your - * module will continue to work with future versions of the API. + * Represents an array of Vars. The <code>as_id</code> field is used to + * identify the array, which may be created and manipulated from the + * <code>PPB_VarArray</code> interface. These objects are reference counted, + * so AddRef and Release must be used properly to avoid memory leaks. */ PP_VARTYPE_ARRAY = 7, + + /** + * Represents a mapping from strings to Vars. The <code>as_id</code> field is + * used to identify the dictionary, which may be created and manipulated from + * the <code>PPB_VarDictionary</code> interface. These objects are reference + * counted, so AddRef and Release must be used properly to avoid memory leaks. + */ PP_VARTYPE_DICTIONARY = 8, /** @@ -68,9 +78,17 @@ enum PP_VarType { * represents Typed Arrays in JavaScript. Unlike JavaScript 'Array', it is * only meant to contain basic numeric types, and is always stored * contiguously. See PPB_VarArrayBuffer_Dev for functions special to - * ArrayBuffer vars. + * ArrayBuffer vars. These objects are reference counted, so AddRef and + * Release must be used properly to avoid memory leaks. + */ + PP_VARTYPE_ARRAY_BUFFER = 9, + + /** + * Resources are not currently supported but will be added in the future + * These objects are reference counted, so AddRef and Release must be used + * properly to avoid memory leaks. */ - PP_VARTYPE_ARRAY_BUFFER = 9 + PP_VARTYPE_RESOURCE = 10 }; @@ -102,12 +120,12 @@ enum PP_VarType { /** * If <code>type</code> is <code>PP_VARTYPE_STRING</code>, - * <code>PP_VARTYPE_OBJECT</code>, <code>PP_VARTYPE_ARRAY</code>, or - * <code>PP_VARTYPE_DICTIONARY</code>, - * <code>as_id</code> represents the value of this <code>PP_Var</code> as - * an opaque handle assigned by the browser. This handle is guaranteed - * never to be 0, so a module can initialize this ID to 0 to indicate a - * "NULL handle." + * <code>PP_VARTYPE_OBJECT</code>, <code>PP_VARTYPE_ARRAY</code>, + * <code>PP_VARTYPE_DICTIONARY</code>, <code>PP_VARTYPE_ARRAY_BUFFER</code>, + * or <code>PP_VARTYPE_RESOURCE</code>, <code>as_id</code> represents the + * value of this <code>PP_Var</code> as an opaque handle assigned by the + * browser. This handle is guaranteed never to be 0, so a module can + * initialize this ID to 0 to indicate a "NULL handle." */ int64_t as_id; }; diff --git a/chromium/ppapi/api/ppb_audio.idl b/chromium/ppapi/api/ppb_audio.idl index 6d0dcb8d2b1..7a996badd0b 100644 --- a/chromium/ppapi/api/ppb_audio.idl +++ b/chromium/ppapi/api/ppb_audio.idl @@ -8,10 +8,9 @@ * realtime stereo audio streaming capabilities. */ -[generate_thunk] - label Chrome { - M14 = 1.0 + M14 = 1.0, + M31 = 1.1 }; /** @@ -19,9 +18,16 @@ label Chrome { * function used to fill the audio buffer with data. Please see the * Create() function in the <code>PPB_Audio</code> interface for * more details on this callback. + * + * @param[in] sample_buffer A buffer to fill with audio data. + * @param[in] buffer_size_in_bytes The size of the buffer in bytes. + * @param[in] latency How long before the audio data is to be presented. + * @param[inout] user_data An opaque pointer that was passed into + * <code>PPB_Audio.Create()</code>. */ typedef void PPB_Audio_Callback([out] mem_t sample_buffer, [in] uint32_t buffer_size_in_bytes, + [in, version=1.1] PP_TimeDelta latency, [inout] mem_t user_data); /** diff --git a/chromium/ppapi/api/ppb_file_ref.idl b/chromium/ppapi/api/ppb_file_ref.idl index 8e4b81d6cdb..d9226471a9f 100644 --- a/chromium/ppapi/api/ppb_file_ref.idl +++ b/chromium/ppapi/api/ppb_file_ref.idl @@ -25,7 +25,7 @@ interface PPB_FileRef { * * @param[in] resource A <code>PP_Resource</code> corresponding to a file * system. - * @param[in] path A path to the file. + * @param[in] path A path to the file. Must begin with a '/' character. * * @return A <code>PP_Resource</code> corresponding to a file reference if * successful or 0 if the path is malformed. diff --git a/chromium/ppapi/api/ppb_graphics_3d.idl b/chromium/ppapi/api/ppb_graphics_3d.idl index 28a0c40d7a6..b39ad24e38d 100644 --- a/chromium/ppapi/api/ppb_graphics_3d.idl +++ b/chromium/ppapi/api/ppb_graphics_3d.idl @@ -29,14 +29,17 @@ label Chrome { * int32_t attribs[] = {PP_GRAPHICS3DATTRIB_WIDTH, 800, * PP_GRAPHICS3DATTRIB_HEIGHT, 800, * PP_GRAPHICS3DATTRIB_NONE}; - * context = g3d->Create(instance, attribs, &context); + * context = g3d->Create(instance, 0, attribs); * inst->BindGraphics(instance, context); * @endcode * * <strong>Present one frame:</strong> * @code - * gles2->Clear(context, GL_COLOR_BUFFER); - * g3d->SwapBuffers(context); + * PP_CompletionCallback callback = { + * DidFinishSwappingBuffers, 0, PP_COMPLETIONCALLBACK_FLAG_NONE, + * }; + * gles2->Clear(context, GL_COLOR_BUFFER_BIT); + * g3d->SwapBuffers(context, callback); * @endcode * * <strong>Shutdown:</strong> @@ -92,7 +95,7 @@ interface PPB_Graphics3D { * already shares with, and the newly created context. An arbitrary number of * <code>PPB_Graphics3D</code> can share data in this fashion. * - * @param[out] attrib_list specifies a list of attributes for the context. + * @param[in] attrib_list specifies a list of attributes for the context. * It is a list of attribute name-value pairs in which each attribute is * immediately followed by the corresponding desired value. The list is * terminated with <code>PP_GRAPHICS3DATTRIB_NONE</code>. diff --git a/chromium/ppapi/api/ppb_network_list.idl b/chromium/ppapi/api/ppb_network_list.idl new file mode 100644 index 00000000000..70c301f8754 --- /dev/null +++ b/chromium/ppapi/api/ppb_network_list.idl @@ -0,0 +1,172 @@ +/* Copyright (c) 2012 The Chromium Authors. All rights reserved. + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +/** + * This file defines the <code>PPB_NetworkList</code> interface. + */ + +[generate_thunk] + +label Chrome { + M31 = 1.0 +}; + +/** + * Type of a network interface. + */ +[assert_size(4)] +enum PP_NetworkList_Type { + /** + * Type of the network interface is not known. + */ + PP_NETWORKLIST_TYPE_UNKNOWN = 0, + + /** + * Wired Ethernet network. + */ + PP_NETWORKLIST_TYPE_ETHERNET = 1, + + /** + * Wireless Wi-Fi network. + */ + PP_NETWORKLIST_TYPE_WIFI = 2, + + /** + * Cellular network (e.g. LTE). + */ + PP_NETWORKLIST_TYPE_CELLULAR = 3 +}; + +/** + * State of a network interface. + */ +[assert_size(4)] +enum PP_NetworkList_State { + /** + * Network interface is down. + */ + PP_NETWORKLIST_STATE_DOWN = 0, + + /** + * Network interface is up. + */ + PP_NETWORKLIST_STATE_UP = 1 +}; + +/** + * The <code>PPB_NetworkList</code> is used to represent a list of + * network interfaces and their configuration. The content of the list + * is immutable. The current networks configuration can be received + * using the <code>PPB_NetworkMonitor</code> interface. + */ +interface PPB_NetworkList { + /** + * Determines if the specified <code>resource</code> is a + * <code>NetworkList</code> object. + * + * @param[in] resource A <code>PP_Resource</code> resource. + * + * @return Returns <code>PP_TRUE</code> if <code>resource</code> is + * a <code>PPB_NetworkList</code>, <code>PP_FALSE</code> + * otherwise. + */ + PP_Bool IsNetworkList([in] PP_Resource resource); + + /** + * Gets number of interfaces in the list. + * + * @param[in] resource A <code>PP_Resource</code> corresponding to a + * network list. + * + * @return Returns number of available network interfaces or 0 if + * the list has never been updated. + */ + uint32_t GetCount([in] PP_Resource resource); + + /** + * Gets name of a network interface. + * + * @param[in] resource A <code>PP_Resource</code> corresponding to a + * network list. + * @param[in] index Index of the network interface. + * + * @return Returns name for the network interface with the specified + * <code>index</code>. + */ + PP_Var GetName([in] PP_Resource resource, + [in] uint32_t index); + + /** + * Gets type of a network interface. + * + * @param[in] resource A <code>PP_Resource</code> corresponding to a + * network list. + * @param[in] index Index of the network interface. + * + * @return Returns type of the network interface with the specified + * <code>index</code>. + */ + [on_failure=PP_NETWORKLIST_TYPE_UNKNOWN] + PP_NetworkList_Type GetType([in] PP_Resource resource, + [in] uint32_t index); + + /** + * Gets state of a network interface. + * + * @param[in] resource A <code>PP_Resource</code> corresponding to a + * network list. + * @param[in] index Index of the network interface. + * + * @return Returns current state of the network interface with the + * specified <code>index</code>. + */ + [on_failure=PP_NETWORKLIST_STATE_DOWN] + PP_NetworkList_State GetState([in] PP_Resource resource, + [in] uint32_t index); + + /** + * Gets list of IP addresses for a network interface. + * + * @param[in] resource A <code>PP_Resource</code> corresponding to a + * network list. + * @param[in] index Index of the network interface. + * @param[in] output An output array which will receive + * <code>PPB_NetAddress</code> resources on success. Please note that the + * ref count of those resources has already been increased by 1 for the + * caller. + * + * @return An error code from <code>pp_errors.h</code>. + */ + int32_t GetIpAddresses([in] PP_Resource resource, + [in] uint32_t index, + [in] PP_ArrayOutput output); + + /** + * Gets display name of a network interface. + * + * @param[in] resource A <code>PP_Resource</code> corresponding to a + * network list. + * @param[in] index Index of the network interface. + * + * @return Returns display name for the network interface with the + * specified <code>index</code>. + */ + PP_Var GetDisplayName([in] PP_Resource resource, + [in] uint32_t index); + + /** + * Gets MTU (Maximum Transmission Unit) of a network interface. + * + * @param[in] resource A <code>PP_Resource</code> corresponding to a + * network list. + * @param[in] index Index of the network interface. + * + * @return Returns MTU for the network interface with the specified + * <code>index</code> or 0 if MTU is unknown. + */ + uint32_t GetMTU([in] PP_Resource resource, + [in] uint32_t index); + +}; diff --git a/chromium/ppapi/api/ppb_network_monitor.idl b/chromium/ppapi/api/ppb_network_monitor.idl new file mode 100644 index 00000000000..361f7cbbeb4 --- /dev/null +++ b/chromium/ppapi/api/ppb_network_monitor.idl @@ -0,0 +1,69 @@ +/* Copyright (c) 2012 The Chromium Authors. All rights reserved. + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +/** + * This file defines the <code>PPB_NetworkMonitor</code> interface. + */ + +[generate_thunk] + +label Chrome { + M31 = 1.0 +}; + +/** + * The <code>PPB_NetworkMonitor</code> allows to get network interfaces + * configuration and monitor network configuration changes. + * + * Permissions: Apps permission <code>socket</code> with subrule + * <code>network-state</code> is required for <code>UpdateNetworkList()</code>. + * For more details about network communication permissions, please see: + * http://developer.chrome.com/apps/app_network.html + */ +interface PPB_NetworkMonitor { + /** + * Creates a Network Monitor resource. + * + * @param[in] instance A <code>PP_Instance</code> identifying one instance of + * a module. + * + * @return A <code>PP_Resource</code> corresponding to a network monitor or 0 + * on failure. + */ + PP_Resource Create([in] PP_Instance instance); + + + /** + * Gets current network configuration. When called for the first time, + * completes as soon as the current network configuration is received from + * the browser. Each consequent call will wait for network list changes, + * returning a new <code>PPB_NetworkList</code> resource every time. + * + * @param[in] network_monitor A <code>PP_Resource</code> corresponding to a + * network monitor. + * @param[out] network_list The <code>PPB_NetworkList<code> resource with the + * current state of network interfaces. + * @param[in] callback A <code>PP_CompletionCallback</code> to be called upon + * completion. + * + * @return An int32_t containing an error code from <code>pp_errors.h</code>. + * <code>PP_ERROR_NOACCESS</code> will be returned if the caller doesn't have + * required permissions. + */ + int32_t UpdateNetworkList([in] PP_Resource network_monitor, + [out] PP_Resource network_list, + [in] PP_CompletionCallback callback); + + /** + * Determines if the specified <code>resource</code> is a + * <code>NetworkMonitor</code> object. + * + * @param[in] resource A <code>PP_Resource</code> resource. + * + * @return Returns <code>PP_TRUE</code> if <code>resource</code> is a + * <code>PPB_NetworkMonitor</code>, <code>PP_FALSE</code> otherwise. + */ + PP_Bool IsNetworkMonitor([in] PP_Resource resource); +}; diff --git a/chromium/ppapi/api/ppb_tcp_socket.idl b/chromium/ppapi/api/ppb_tcp_socket.idl index 833879c67e1..543cd305191 100644 --- a/chromium/ppapi/api/ppb_tcp_socket.idl +++ b/chromium/ppapi/api/ppb_tcp_socket.idl @@ -7,10 +7,9 @@ * This file defines the <code>PPB_TCPSocket</code> interface. */ -[generate_thunk] - label Chrome { - M29 = 1.0 + M29 = 1.0, + M31 = 1.1 }; /** @@ -52,7 +51,8 @@ enum PP_TCPSocket_Option { * The <code>PPB_TCPSocket</code> interface provides TCP socket operations. * * Permissions: Apps permission <code>socket</code> with subrule - * <code>tcp-connect</code> is required for <code>Connect()</code>. + * <code>tcp-connect</code> is required for <code>Connect()</code>; subrule + * <code>tcp-listen</code> is required for <code>Listen()</code>. * For more details about network communication permissions, please see: * http://developer.chrome.com/apps/app_network.html */ @@ -79,7 +79,27 @@ interface PPB_TCPSocket { PP_Bool IsTCPSocket([in] PP_Resource resource); /** - * Connects the socket to the given address. + * Binds the socket to the given address. The socket must not be bound. + * + * @param[in] tcp_socket A <code>PP_Resource</code> corresponding to a TCP + * socket. + * @param[in] addr A <code>PPB_NetAddress</code> resource. + * @param[in] callback A <code>PP_CompletionCallback</code> to be called upon + * completion. + * + * @return An int32_t containing an error code from <code>pp_errors.h</code>, + * including (but not limited to): + * - <code>PP_ERROR_ADDRESS_IN_USE</code>: the address is already in use. + * - <code>PP_ERROR_ADDRESS_INVALID</code>: the address is invalid. + */ + [version=1.1] + int32_t Bind([in] PP_Resource tcp_socket, + [in] PP_Resource addr, + [in] PP_CompletionCallback callback); + + /** + * Connects the socket to the given address. The socket must not be listening. + * Binding the socket beforehand is optional. * * @param[in] tcp_socket A <code>PP_Resource</code> corresponding to a TCP * socket. @@ -98,13 +118,18 @@ interface PPB_TCPSocket { * - <code>PP_ERROR_CONNECTION_FAILED</code>: the connection attempt failed. * - <code>PP_ERROR_CONNECTION_TIMEDOUT</code>: the connection attempt timed * out. + * + * Since version 1.1, if the socket is listening/connected or has a pending + * listen/connect request, <code>Connect()</code> will fail without starting a + * connection attempt; otherwise, any failure during the connection attempt + * will cause the socket to be closed. */ int32_t Connect([in] PP_Resource tcp_socket, [in] PP_Resource addr, [in] PP_CompletionCallback callback); /** - * Gets the local address of the socket, if it is connected. + * Gets the local address of the socket, if it is bound. * * @param[in] tcp_socket A <code>PP_Resource</code> corresponding to a TCP * socket. @@ -162,13 +187,53 @@ interface PPB_TCPSocket { [in] str_t buffer, [in] int32_t bytes_to_write, [in] PP_CompletionCallback callback); + /** + * Starts listening. The socket must be bound and not connected. + * + * @param[in] tcp_socket A <code>PP_Resource</code> corresponding to a TCP + * socket. + * @param[in] backlog A hint to determine the maximum length to which the + * queue of pending connections may grow. + * @param[in] callback A <code>PP_CompletionCallback</code> to be called upon + * completion. + * + * @return An int32_t containing an error code from <code>pp_errors.h</code>, + * including (but not limited to): + * - <code>PP_ERROR_NOACCESS</code>: the caller doesn't have required + * permissions. + * - <code>PP_ERROR_ADDRESS_IN_USE</code>: Another socket is already listening + * on the same port. + */ + [version=1.1] + int32_t Listen([in] PP_Resource tcp_socket, + [in] int32_t backlog, + [in] PP_CompletionCallback callback); + + /** + * Accepts a connection. The socket must be listening. + * + * @param[in] tcp_socket A <code>PP_Resource</code> corresponding to a TCP + * socket. + * @param[out] accepted_tcp_socket Stores the accepted TCP socket on success. + * @param[in] callback A <code>PP_CompletionCallback</code> to be called upon + * completion. + * + * @return An int32_t containing an error code from <code>pp_errors.h</code>, + * including (but not limited to): + * - <code>PP_ERROR_CONNECTION_ABORTED</code>: A connection has been aborted. + */ + [version=1.1] + int32_t Accept([in] PP_Resource tcp_socket, + [out] PP_Resource accepted_tcp_socket, + [in] PP_CompletionCallback callback); /** - * Cancels all pending reads and writes and disconnects the socket. Any - * pending callbacks will still run, reporting <code>PP_ERROR_ABORTED</code> - * if pending IO was interrupted. After a call to this method, no output - * buffer pointers passed into previous <code>Read()</code> calls will be - * accessed. It is not valid to call <code>Connect()</code> again. + * Cancels all pending operations and closes the socket. Any pending callbacks + * will still run, reporting <code>PP_ERROR_ABORTED</code> if pending IO was + * interrupted. After a call to this method, no output buffer pointers passed + * into previous <code>Read()</code> or <code>Accept()</code> calls will be + * accessed. It is not valid to call <code>Connect()</code> or + * <code>Listen()</code> again. * * The socket is implicitly closed if it is destroyed, so you are not required * to call this method. diff --git a/chromium/ppapi/api/private/finish_writing_these/ppb_pdf.idl b/chromium/ppapi/api/private/finish_writing_these/ppb_pdf.idl index b428386f9dc..3038d92b30d 100644 --- a/chromium/ppapi/api/private/finish_writing_these/ppb_pdf.idl +++ b/chromium/ppapi/api/private/finish_writing_these/ppb_pdf.idl @@ -138,4 +138,12 @@ interface PPB_PDF_0_1 { /* Notifies the browser that the PDF has an unsupported feature. */ void HasUnsupportedFeature( [in] PP_Instance instance); + + /* Tells the browser to open a dialog box to receive a password from the + * user, masking input characters. Returns the value entered by the user, or + * an empty string if the user cancels instead. + */ + PP_Var ModalPromptForPassword( + [in] PP_Instance instance, + [in] PP_Var message); }; diff --git a/chromium/ppapi/api/private/ppb_content_decryptor_private.idl b/chromium/ppapi/api/private/ppb_content_decryptor_private.idl index 9a6422dfcea..8859448d689 100644 --- a/chromium/ppapi/api/private/ppb_content_decryptor_private.idl +++ b/chromium/ppapi/api/private/ppb_content_decryptor_private.idl @@ -12,7 +12,7 @@ [generate_thunk] label Chrome { - M24 = 0.6 + M31 = 0.7 }; /** @@ -24,35 +24,6 @@ label Chrome { */ interface PPB_ContentDecryptor_Private { /** - * The decryptor requires a key that has not been provided. - * - * Sent when the decryptor encounters encrypted content, but it does not have - * the key required to decrypt the data. The plugin will call this method in - * response to a call to the <code>Decrypt()</code> method on the - * <code>PPP_ContentDecryptor_Private<code> interface. - * - * The browser must notify the application that a key is needed, and, in - * response, the web application must direct the browser to call - * <code>AddKey()</code> on the <code>PPP_ContentDecryptor_Private</code> - * interface. - * - * @param[in] key_system A <code>PP_Var</code> of type - * <code>PP_VARTYPE_STRING</code> containing the name of the key system. - * - * @param[in] session_id A <code>PP_Var</code> of type - * <code>PP_VARTYPE_STRING</code> containing the session ID. - * - * @param[in] init_data A <code>PP_Var</code> of type - * <code>PP_VARTYPE_ARRAY_BUFFER</code> containing container-specific - * initialization data. - */ - void NeedKey( - [in] PP_Instance instance, - [in] PP_Var key_system, - [in] PP_Var session_id, - [in] PP_Var init_data); - - /** * A key has been added as the result of a call to the <code>AddKey()</code> * method on the <code>PPP_ContentDecryptor_Private</code> interface. * diff --git a/chromium/ppapi/api/private/ppb_gpu_blacklist_private.idl b/chromium/ppapi/api/private/ppb_gpu_blacklist_private.idl deleted file mode 100644 index ef8e1b5f0b0..00000000000 --- a/chromium/ppapi/api/private/ppb_gpu_blacklist_private.idl +++ /dev/null @@ -1,23 +0,0 @@ -/* Copyright (c) 2012 The Chromium Authors. All rights reserved. - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -/* This file contains the <code>PPB_FileRefPrivate</code> interface. */ -label Chrome { - M24 = 0.2 -}; - -/** PPB_GpuBlacklist_Private interface */ -interface PPB_GpuBlacklist_Private { - /** - * Returns true if the current system's GPU is blacklisted and 3D in Chrome - * will be emulated via software rendering. - * - * This is used internally by the SRPC NaCl proxy (not exposed to plugins) to - * determine if the 3D interfaces should be exposed to plugins. We don't - * expose the 3D interfaces if the 3D support is software-emulated. When the - * SRPC proxy is removed, this interface can also be removed. - */ - PP_Bool IsGpuBlacklisted(); -}; diff --git a/chromium/ppapi/api/private/ppb_nacl_private.idl b/chromium/ppapi/api/private/ppb_nacl_private.idl index bf2918b2570..4bb602f59c8 100644 --- a/chromium/ppapi/api/private/ppb_nacl_private.idl +++ b/chromium/ppapi/api/private/ppb_nacl_private.idl @@ -6,6 +6,10 @@ /* This file contains NaCl private interfaces. This interface is not versioned * and is for internal Chrome use. It may change without notice. */ +label Chrome { + M25 = 1.0 +}; + #inline c #include "ppapi/c/private/pp_file_handle.h" #include "ppapi/c/private/ppb_instance_private.h" @@ -35,6 +39,9 @@ interface PPB_NaCl_Private { * will be able to use dynamic code system calls (e.g., mmap with PROT_EXEC). * The |enable_exception_handling| flag indicates whether or not the nexe * will be able to use hardware exception handling. + * The |enable_crash_throttling| flag indicates whether or not crashes of + * the nexe contribute to crash throttling statisics and whether nexe starts + * are throttled by crash throttling. */ PP_ExternalPluginResult LaunchSelLdr([in] PP_Instance instance, [in] str_t alleged_url, @@ -43,6 +50,7 @@ interface PPB_NaCl_Private { [in] PP_Bool enable_ppapi_dev, [in] PP_Bool enable_dyncode_syscalls, [in] PP_Bool enable_exception_handling, + [in] PP_Bool enable_crash_throttling, [out] mem_t imc_handle, [out] PP_Var error_message); @@ -98,18 +106,19 @@ interface PPB_NaCl_Private { */ PP_FileHandle CreateTemporaryFile([in] PP_Instance instance); - /* Create a temporary file, which will be deleted by the time the last - * handle is closed (or earlier on POSIX systems), to use for the nexe - * with the cache information given by |pexe_url|, |abi_version|, |opt_level|, - * |last_modified|, and |etag|. If the nexe is already present - * in the cache, |is_hit| is set to PP_TRUE and the contents of the nexe - * will be copied into the temporary file. Otherwise |is_hit| is set to - * PP_FALSE and the temporary file will be writeable. - * Currently the implementation is a stub, which always sets is_hit to false - * and calls the implementation of CreateTemporaryFile. In a subsequent CL - * it will call into the browser which will remember the association between - * the cache key and the fd, and copy the nexe into the cache after the - * translation finishes. + /* Create a temporary file, which will be deleted by the time the + * last handle is closed (or earlier on POSIX systems), to use for + * the nexe with the cache information given by |pexe_url|, + * |abi_version|, |opt_level|, |last_modified|, |etag|, and + * |has_no_store_header|. If the nexe is already present in the + * cache, |is_hit| is set to PP_TRUE and the contents of the nexe + * will be copied into the temporary file. Otherwise |is_hit| is set + * to PP_FALSE and the temporary file will be writeable. Currently + * the implementation is a stub, which always sets is_hit to false + * and calls the implementation of CreateTemporaryFile. In a + * subsequent CL it will call into the browser which will remember + * the association between the cache key and the fd, and copy the + * nexe into the cache after the translation finishes. */ int32_t GetNexeFd([in] PP_Instance instance, [in] str_t pexe_url, @@ -117,6 +126,7 @@ interface PPB_NaCl_Private { [in] uint32_t opt_level, [in] str_t last_modified, [in] str_t etag, + [in] PP_Bool has_no_store_header, [out] PP_Bool is_hit, [out] PP_FileHandle nexe_handle, [in] PP_CompletionCallback callback); diff --git a/chromium/ppapi/api/private/ppb_network_list_private.idl b/chromium/ppapi/api/private/ppb_network_list_private.idl deleted file mode 100644 index 8ec330fb888..00000000000 --- a/chromium/ppapi/api/private/ppb_network_list_private.idl +++ /dev/null @@ -1,137 +0,0 @@ -/* Copyright (c) 2012 The Chromium Authors. All rights reserved. - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -/** - * This file defines the <code>PPB_NetworkList_Private</code> interface. - */ - -[generate_thunk] - -label Chrome { - M19 = 0.2 -}; - -/** - * Type of a network interface. - */ -[assert_size(4)] -enum PP_NetworkListType_Private { - /** - * Type of the network interface is not known. - */ - PP_NETWORKLIST_UNKNOWN = 0, - - /** - * Wired Ethernet network. - */ - PP_NETWORKLIST_ETHERNET = 1, - - /** - * Wireless Wi-Fi network. - */ - PP_NETWORKLIST_WIFI = 2, - - /** - * Cellular network (e.g. LTE). - */ - PP_NETWORKLIST_CELLULAR = 3 -}; - -/** - * State of a network interface. - */ -[assert_size(4)] -enum PP_NetworkListState_Private { - /** - * Network interface is down. - */ - PP_NETWORKLIST_DOWN = 0, - - /** - * Network interface is up. - */ - PP_NETWORKLIST_UP = 1 -}; - -/** - * The <code>PPB_NetworkList_Private</code> is used to represent a - * list of network interfaces and their configuration. The content of - * the list is immutable. The current networks configuration can be - * received using the <code>PPB_NetworkMonitor_Private</code> - * interface. - */ -interface PPB_NetworkList_Private { - /** - * Determines if the specified <code>resource</code> is a - * <code>NetworkList</code> object. - * - * @param[in] resource A <code>PP_Resource</code> resource. - * - * @return Returns <code>PP_TRUE</code> if <code>resource</code> is - * a <code>PPB_NetworkList_Private</code>, <code>PP_FALSE</code> - * otherwise. - */ - PP_Bool IsNetworkList([in] PP_Resource resource); - - /** - * @return Returns number of available network interfaces or 0 if - * the list has never been updated. - */ - uint32_t GetCount([in] PP_Resource resource); - - /** - * @return Returns name for the network interface with the specified - * <code>index</code>. - */ - PP_Var GetName([in] PP_Resource resource, - [in] uint32_t index); - - /** - * @return Returns type of the network interface with the specified - * <code>index</code>. - */ - [on_failure=PP_NETWORKLIST_UNKNOWN] - PP_NetworkListType_Private GetType([in] PP_Resource resource, - [in] uint32_t index); - - /** - * @return Returns current state of the network interface with the - * specified <code>index</code>. - */ - [on_failure=PP_NETWORKLIST_DOWN] - PP_NetworkListState_Private GetState([in] PP_Resource resource, - [in] uint32_t index); - - /** - * Gets list of IP addresses for the network interface with the - * specified <code>index</code> and stores them in - * <code>addresses</code>. If the caller didn't allocate sufficient - * space to store all addresses, then only the first - * <code>count</code> addresses are filled in. - * - * @return Returns total number of IP addresses assigned to the - * network interface or a negative error code. - */ - int32_t GetIpAddresses( - [in] PP_Resource resource, - [in] uint32_t index, - [inout, size_is(count)] PP_NetAddress_Private[] addresses, - [in] uint32_t count); - - /** - * @return Returns display name for the network interface with the - * specified <code>index</code>. - */ - PP_Var GetDisplayName([in] PP_Resource resource, - [in] uint32_t index); - - /** - * @return Returns MTU for the network interface with the specified - * <code>index</code> or 0 if MTU is unknown. - */ - uint32_t GetMTU([in] PP_Resource resource, - [in] uint32_t index); - -}; diff --git a/chromium/ppapi/api/private/ppb_network_monitor_private.idl b/chromium/ppapi/api/private/ppb_network_monitor_private.idl deleted file mode 100644 index fe264a616bc..00000000000 --- a/chromium/ppapi/api/private/ppb_network_monitor_private.idl +++ /dev/null @@ -1,64 +0,0 @@ -/* Copyright (c) 2012 The Chromium Authors. All rights reserved. - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -/** - * This file defines the <code>PPB_NetworkMonitor_Private</code> interface. - */ - -label Chrome { - M19 = 0.2 -}; - -/** - * <code>PPB_NetworkMonitor_Callback</code> is a callback function - * type that is used to receive notifications about network - * configuration changes. The <code>network_list</code> passed to this - * callback is a <code>PPB_NetworkList_Private</code> resource that - * contains current configuration of network interfaces. - */ -typedef void PPB_NetworkMonitor_Callback([inout] mem_t user_data, - [in] PP_Resource network_list); - - -/** - * The <code>PPB_NetworkMonitor_Private</code> provides access to - * notifications of network configuration changes. - */ -interface PPB_NetworkMonitor_Private { - /** - * Starts network change monitoring. The specified - * <code>callback</code> will be called on the main thread once - * after this method is called (to supply the initial network - * configuration) and then later every time network configuration - * changes. Notifications are stopped when the returned resource is - * destroyed. If the plugin doesn't have access to the network list - * then the callback will be called once with the - * <code>network_list</code> parameter is set to 0. - * - * @param[in] callback The callback that will be called every time - * network configuration changes or NULL to stop network monitoring. - * - * @param[inout] user_data The data to be passed to the callback on - * each call. - * - * @return A <code>PP_Resource</code> containing the created - * NetworkMonitor resource. - */ - PP_Resource Create([in] PP_Instance instance, - [in] PPB_NetworkMonitor_Callback callback, - [inout] mem_t user_data); - - /** - * Determines if the specified <code>resource</code> is a - * <code>NetworkMonitor</code> object. - * - * @param[in] resource A <code>PP_Resource</code> resource. - * - * @return Returns <code>PP_TRUE</code> if <code>resource</code> is - * a <code>PPB_NetworkMonitor_Private</code>, <code>PP_FALSE</code> - * otherwise. - */ - PP_Bool IsNetworkMonitor([in] PP_Resource resource); -}; diff --git a/chromium/ppapi/api/private/ppb_output_protection_private.idl b/chromium/ppapi/api/private/ppb_output_protection_private.idl new file mode 100644 index 00000000000..395d2533991 --- /dev/null +++ b/chromium/ppapi/api/private/ppb_output_protection_private.idl @@ -0,0 +1,137 @@ +/* Copyright 2013 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. + */ + +/** + * This file defines the API for output protection. Currently, it only supports + * Chrome OS. + */ + +[generate_thunk] + +label Chrome { + M31 = 0.1 +}; + +/** + * Content protection methods applied on video output link. + */ +[assert_size(4)] enum PP_OutputProtectionMethod_Private { + PP_OUTPUT_PROTECTION_METHOD_PRIVATE_NONE = 0, + PP_OUTPUT_PROTECTION_METHOD_PRIVATE_HDCP = 1 << 0 +}; + +/** + * Video output link types. + */ +[assert_size(4)] enum PP_OutputProtectionLinkType_Private { + PP_OUTPUT_PROTECTION_LINK_TYPE_PRIVATE_NONE = 0, + PP_OUTPUT_PROTECTION_LINK_TYPE_PRIVATE_UNKNOWN = 1 << 0, + PP_OUTPUT_PROTECTION_LINK_TYPE_PRIVATE_INTERNAL = 1 << 1, + PP_OUTPUT_PROTECTION_LINK_TYPE_PRIVATE_VGA = 1 << 2, + PP_OUTPUT_PROTECTION_LINK_TYPE_PRIVATE_HDMI = 1 << 3, + PP_OUTPUT_PROTECTION_LINK_TYPE_PRIVATE_DVI = 1 << 4, + PP_OUTPUT_PROTECTION_LINK_TYPE_PRIVATE_DISPLAYPORT = 1 << 5 +}; + +/** + * The <code>PPB_OutputProtection_Private</code> interface allows controlling + * output protection. + * + * <strong>Example:</strong> + * + * @code + * op = output_protection->Create(instance); + * output_protection->QueryStatus(op, &link_mask, &protection_mask, + * done_callback); + * @endcode + * + * In this example, the plugin wants to enforce HDCP for HDMI link. + * @code + * if (link_mask & PP_OUTPUT_PROTECTION_LINK_TYPE_PRIVATE_HDMI) { + * output_protection->EnableProtection( + * op, PP_OUTPUT_PROTECTION_METHOD_PRIVATE_HDCP, done_callback); + * } + * @endcode + * + * After EnableProtection() completes, the plugin has to query protection + * status periodically to make sure the protection is enabled and remains + * enabled. + */ +interface PPB_OutputProtection_Private { + /** + * Create() creates a new <code>PPB_OutputProtection_Private</code> object. + * + * @pram[in] instance A <code>PP_Instance</code> identifying one instance of + * a module. + * + * @return A <code>PP_Resource</code> corresponding to a + * <code>PPB_OutputProtection_Private</code> if successful, 0 if creation + * failed. + */ + PP_Resource Create([in] PP_Instance instance); + + /** + * IsOutputProtection() determines if the provided resource is a + * <code>PPB_OutputProtection_Private</code>. + * + * @param[in] resource A <code>PP_Resource</code> corresponding to a + * <code>PPB_OutputProtection_Private</code>. + * + * @return <code>PP_TRUE</code> if the resource is a + * <code>PPB_OutputProtection_Private</code>, <code>PP_FALSE</code> if the + * resource is invalid or some type other than + * <code>PPB_OutputProtection_Private</code>. + */ + PP_Bool IsOutputProtection([in] PP_Resource resource); + + /** + * Query link status and protection status. + * Clients have to query status periodically in order to detect changes. + * + * @param[in] resource A <code>PP_Resource</code> corresponding to a + * <code>PPB_OutputProtection_Private</code>. + * @param[out] link_mask The type of connected output links, which is a + * bit-mask of the <code>PP_OutputProtectionLinkType_Private</code> values. + * @param[out] protection_mask Enabled protection methods, which is a + * bit-mask of the <code>PP_OutputProtectionMethod_Private</code> values. + * @param[in] callback A <code>PP_CompletionCallback</code> to run on + * asynchronous completion of QueryStatus(). This callback will only run if + * QueryStatus() returns <code>PP_OK_COMPLETIONPENDING</code>. + * + * @return An int32_t containing an error code from <code>pp_errors.h</code>. + */ + int32_t QueryStatus( + [in] PP_Resource resource, + [out] uint32_t link_mask, + [out] uint32_t protection_mask, + [in] PP_CompletionCallback callback); + + /** + * Set desired protection methods. + * + * When the desired protection method(s) have been applied to all applicable + * output links, the relevant bit(s) of the protection_mask returned by + * QueryStatus() will be set. Otherwise, the relevant bit(s) of + * protection_mask will not be set; there is no separate error code or + * callback. + * + * Protections will be disabled if no longer desired by all instances. + * + * @param[in] resource A <code>PP_Resource</code> corresponding to a + * <code>PPB_OutputProtection_Private</code>. + * @param[in] desired_protection_mask The desired protection methods, which + * is a bit-mask of the <code>PP_OutputProtectionMethod_Private</code> + * values. + * @param[in] callback A <code>PP_CompletionCallback</code> to be called when + * the protection request has been made. This may be before the protection + * have actually been applied. Call QueryStatus to get protection status. + * + * @return An int32_t containing an error code from <code>pp_errors.h</code>. + */ + int32_t EnableProtection( + [in] PP_Resource resource, + [in] uint32_t desired_protection_mask, + [in] PP_CompletionCallback callback); +}; diff --git a/chromium/ppapi/api/private/ppb_platform_verification_private.idl b/chromium/ppapi/api/private/ppb_platform_verification_private.idl new file mode 100644 index 00000000000..86e4d16685b --- /dev/null +++ b/chromium/ppapi/api/private/ppb_platform_verification_private.idl @@ -0,0 +1,104 @@ +/* Copyright 2013 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. + */ + +/** + * This file defines the API for platform verification. Currently, it only + * supports Chrome OS. + */ + +[generate_thunk] + +label Chrome { + M31 = 0.1 +}; + +/** + * The <code>PPB_PlatformVerification_Private</code> interface allows authorized + * services to verify that the underlying platform is trusted. An example of a + * trusted platform is a Chrome OS device in verified boot mode. + */ + +interface PPB_PlatformVerification_Private { + /** + * Create() creates a <code>PPB_PlatformVerification_Private</code> object. + * + * @pram[in] instance A <code>PP_Instance</code> identifying one instance of + * a module. + * + * @return A <code>PP_Resource</code> corresponding to a + * <code>PPB_PlatformVerification_Private</code> if successful, 0 if creation + * failed. + */ + PP_Resource Create([in] PP_Instance instance); + + /** + * IsPlatformVerification() determines if the provided resource is a + * <code>PPB_PlatformVerification_Private</code>. + * + * @param[in] resource A <code>PP_Resource</code> corresponding to a + * <code>PPB_PlatformVerification_Private</code>. + * + * @return <code>PP_TRUE</code> if the resource is a + * <code>PPB_PlatformVerification_Private</code>, <code>PP_FALSE</code> if the + * resource is invalid or some type other than + * <code>PPB_PlatformVerification_Private</code>. + */ + PP_Bool IsPlatformVerification([in] PP_Resource resource); + + /** + * Check if the underlying host platform can be challenged; i.e., verified as + * a trusted platform. Useful for avoiding unnecessary work on platforms + * which will always fail; i.e. dev mode Chrome OS. + + * @param[out] can_challenge_platform A <code>PP_Bool</code> which is set to + * <code>PP_TRUE</code> if a platform challenge might pass and + * <code>PP_FALSE</code> if it definitely won't. + * + * @param[in] callback A <code>PP_CompletionCallback</code> to be called after + * the method has been completed. This callback will only run if the return + * code is <code>PP_OK_COMPLETIONPENDING</code>. + * + * @return An int32_t containing an error code from <code>pp_errors.h</code>. + */ + int32_t CanChallengePlatform([in] PP_Resource instance, + [out] PP_Bool can_challenge_platform, + [in] PP_CompletionCallback callback); + + /** + * Requests a platform challenge for a given service id. + * + * @param[in] service_id A <code>PP_Var</code> of type + * <code>PP_VARTYPE_STRING</code> containing the service_id for the challenge. + * + * @param[in] challenge A <code>PP_Var</code> of type + * <code>PP_VARTYPE_ARRAY_BUFFER</code> that contains the challenge data. + * + * @param[out] signed_data A <code>PP_Var</code> of type + * <code>PP_VARTYPE_ARRAY_BUFFER</code> that contains the data signed by the + * platform. + * + * @param[out] signed_data_signature A <code>PP_Var</code> of type + * <code>PP_VARTYPE_ARRAY_BUFFER</code> that contains the signature of the + * signed data block. + * + * @param[out] platform_key_certificate A <code>PP_Var</code> of type + * <code>PP_VARTYPE_STRING</code> that contains the device specific + * certificate for the requested service_id. + * + * @param[in] callback A <code>PP_CompletionCallback</code> to be called after + * the platform challenge has been completed. This callback will only run if + * the return code is <code>PP_OK_COMPLETIONPENDING</code>. + * + * @return An int32_t containing an error code from <code>pp_errors.h</code>. + */ + int32_t ChallengePlatform( + [in] PP_Resource instance, + [in] PP_Var service_id, + [in] PP_Var challenge, + [out] PP_Var signed_data, + [out] PP_Var signed_data_signature, + [out] PP_Var platform_key_certificate, + [in] PP_CompletionCallback callback); +}; diff --git a/chromium/ppapi/api/private/ppp_content_decryptor_private.idl b/chromium/ppapi/api/private/ppp_content_decryptor_private.idl index c36259a90de..5eba37a8c2a 100644 --- a/chromium/ppapi/api/private/ppp_content_decryptor_private.idl +++ b/chromium/ppapi/api/private/ppp_content_decryptor_private.idl @@ -9,7 +9,7 @@ * Decryption Modules, not normal plugins. */ label Chrome { - M24 = 0.6 + M31 = 0.7 }; /** @@ -21,6 +21,21 @@ label Chrome { */ interface PPP_ContentDecryptor_Private { /** + * Initialize for the specified key system. + * + * @param[in] key_system A <code>PP_Var</code> of type + * <code>PP_VARTYPE_STRING</code> containing the name of the key system. + * + * @param[in] can_challenge_platform A <code>PP_Bool</code> that + * indicates if the underlying host platform can be challenged; + * i.e., verified as a trusted platform. + */ + void Initialize( + [in] PP_Instance instance, + [in] PP_Var key_system, + [in] PP_Bool can_challenge_platform); + + /** * Generates a key request. key_system specifies the key or licensing system * to use. type contains the MIME type of init_data. init_data is a data * buffer containing data for use in generating the request. @@ -30,9 +45,6 @@ interface PPP_ContentDecryptor_Private { * browser by the CDM via <code>KeyMessage()</code> on the * <code>PPB_ContentDecryptor_Private</code> interface. * - * @param[in] key_system A <code>PP_Var</code> of type - * <code>PP_VARTYPE_STRING</code> containing the name of the key system. - * * @param[in] type A <code>PP_Var</code> of type * <code>PP_VARTYPE_STRING</code> containing the MIME type for init_data. * @@ -42,7 +54,6 @@ interface PPP_ContentDecryptor_Private { */ void GenerateKeyRequest( [in] PP_Instance instance, - [in] PP_Var key_system, [in] PP_Var type, [in] PP_Var init_data); diff --git a/chromium/ppapi/c/dev/ppb_keyboard_input_event_dev.h b/chromium/ppapi/c/dev/ppb_keyboard_input_event_dev.h index c3c8fe29bd3..a921bd9f36f 100644 --- a/chromium/ppapi/c/dev/ppb_keyboard_input_event_dev.h +++ b/chromium/ppapi/c/dev/ppb_keyboard_input_event_dev.h @@ -4,7 +4,7 @@ */ /* From dev/ppb_keyboard_input_event_dev.idl, - * modified Tue Feb 21 08:56:59 2012. + * modified Fri Sep 6 10:00:04 2013. */ #ifndef PPAPI_C_DEV_PPB_KEYBOARD_INPUT_EVENT_DEV_H_ @@ -14,11 +14,12 @@ #include "ppapi/c/pp_macros.h" #include "ppapi/c/pp_resource.h" #include "ppapi/c/pp_stdint.h" +#include "ppapi/c/pp_var.h" -#define PPB_KEYBOARD_INPUT_EVENT_DEV_INTERFACE_0_1 \ - "PPB_KeyboardInputEvent(Dev);0.1" +#define PPB_KEYBOARD_INPUT_EVENT_DEV_INTERFACE_0_2 \ + "PPB_KeyboardInputEvent(Dev);0.2" #define PPB_KEYBOARD_INPUT_EVENT_DEV_INTERFACE \ - PPB_KEYBOARD_INPUT_EVENT_DEV_INTERFACE_0_1 + PPB_KEYBOARD_INPUT_EVENT_DEV_INTERFACE_0_2 /** * @file @@ -36,7 +37,7 @@ * The <code>PPB_KeyboardInputEvent_Dev</code> interface is an extension to the * PPB_KeyboardInputEvent</code> interface that provides */ -struct PPB_KeyboardInputEvent_Dev_0_1 { +struct PPB_KeyboardInputEvent_Dev_0_2 { /** * This sets a USB key code in the given <code>PP_Resource</code>. It is * intended that this method be called immediately after any call to @@ -63,9 +64,18 @@ struct PPB_KeyboardInputEvent_Dev_0_1 { * a 0 is returned. */ uint32_t (*GetUsbKeyCode)(PP_Resource key_event); + /** + * GetCode() returns the DOM |code| field for this keyboard event, as + * defined by the UI Events spec: http://www.w3.org/TR/uievents/ + * + * @param[in] key_event The key event for which to return the key code. + * + * @return The string that contains the DOM |code| for the keyboard event. + */ + struct PP_Var (*GetCode)(PP_Resource key_event); }; -typedef struct PPB_KeyboardInputEvent_Dev_0_1 PPB_KeyboardInputEvent_Dev; +typedef struct PPB_KeyboardInputEvent_Dev_0_2 PPB_KeyboardInputEvent_Dev; /** * @} */ diff --git a/chromium/ppapi/c/dev/ppb_url_util_dev.h b/chromium/ppapi/c/dev/ppb_url_util_dev.h index 78e3b0a9008..c40114f019f 100644 --- a/chromium/ppapi/c/dev/ppb_url_util_dev.h +++ b/chromium/ppapi/c/dev/ppb_url_util_dev.h @@ -3,7 +3,7 @@ * found in the LICENSE file. */ -/* From dev/ppb_url_util_dev.idl modified Fri Dec 16 17:34:59 2011. */ +/* From dev/ppb_url_util_dev.idl modified Wed Aug 28 19:09:17 2013. */ #ifndef PPAPI_C_DEV_PPB_URL_UTIL_DEV_H_ #define PPAPI_C_DEV_PPB_URL_UTIL_DEV_H_ @@ -15,7 +15,8 @@ #include "ppapi/c/pp_var.h" #define PPB_URLUTIL_DEV_INTERFACE_0_6 "PPB_URLUtil(Dev);0.6" -#define PPB_URLUTIL_DEV_INTERFACE PPB_URLUTIL_DEV_INTERFACE_0_6 +#define PPB_URLUTIL_DEV_INTERFACE_0_7 "PPB_URLUtil(Dev);0.7" +#define PPB_URLUTIL_DEV_INTERFACE PPB_URLUTIL_DEV_INTERFACE_0_7 /** * @file @@ -77,7 +78,7 @@ PP_COMPILE_ASSERT_STRUCT_SIZE_IN_BYTES(PP_URLComponents_Dev, 64); * except for the reference fragment (stuff after the '#') which will be * encoded as UTF-8. */ -struct PPB_URLUtil_Dev_0_6 { +struct PPB_URLUtil_Dev_0_7 { /* * Canonicalizes the given URL string according to the rules of the host * browser. If the URL is invalid or the var is not a string, this will @@ -163,9 +164,41 @@ struct PPB_URLUtil_Dev_0_6 { struct PP_Var (*GetPluginInstanceURL)( PP_Instance instance, struct PP_URLComponents_Dev* components); + /* + * Returns the Referrer URL of the HTTP request that loaded the plugin. This + * is the value of the 'Referer' header of the request. An undefined value + * means the 'Referer' header was absent. + * The components pointer, if non-NULL and the canonicalized URL is valid, + * will identify the components of the resulting URL. Components may be NULL + * to specify that no component information is necessary. + */ + struct PP_Var (*GetPluginReferrerURL)( + PP_Instance instance, + struct PP_URLComponents_Dev* components); }; -typedef struct PPB_URLUtil_Dev_0_6 PPB_URLUtil_Dev; +typedef struct PPB_URLUtil_Dev_0_7 PPB_URLUtil_Dev; + +struct PPB_URLUtil_Dev_0_6 { + struct PP_Var (*Canonicalize)(struct PP_Var url, + struct PP_URLComponents_Dev* components); + struct PP_Var (*ResolveRelativeToURL)( + struct PP_Var base_url, + struct PP_Var relative_string, + struct PP_URLComponents_Dev* components); + struct PP_Var (*ResolveRelativeToDocument)( + PP_Instance instance, + struct PP_Var relative_string, + struct PP_URLComponents_Dev* components); + PP_Bool (*IsSameSecurityOrigin)(struct PP_Var url_a, struct PP_Var url_b); + PP_Bool (*DocumentCanRequest)(PP_Instance instance, struct PP_Var url); + PP_Bool (*DocumentCanAccessDocument)(PP_Instance active, PP_Instance target); + struct PP_Var (*GetDocumentURL)(PP_Instance instance, + struct PP_URLComponents_Dev* components); + struct PP_Var (*GetPluginInstanceURL)( + PP_Instance instance, + struct PP_URLComponents_Dev* components); +}; /** * @} */ diff --git a/chromium/ppapi/c/pp_macros.h b/chromium/ppapi/c/pp_macros.h index 97a4229dfe7..a552885ea1d 100644 --- a/chromium/ppapi/c/pp_macros.h +++ b/chromium/ppapi/c/pp_macros.h @@ -3,13 +3,13 @@ * found in the LICENSE file. */ -/* From pp_macros.idl modified Tue Jul 2 14:15:05 2013. */ +/* From pp_macros.idl modified Wed Apr 10 11:57:14 2013. */ #ifndef PPAPI_C_PP_MACROS_H_ #define PPAPI_C_PP_MACROS_H_ -#define PPAPI_RELEASE 30 +#define PPAPI_RELEASE 31 /** * @file diff --git a/chromium/ppapi/c/pp_var.h b/chromium/ppapi/c/pp_var.h index 2138f93c2bd..0648c652c3c 100644 --- a/chromium/ppapi/c/pp_var.h +++ b/chromium/ppapi/c/pp_var.h @@ -3,7 +3,7 @@ * found in the LICENSE file. */ -/* From pp_var.idl modified Mon Feb 11 15:41:10 2013. */ +/* From pp_var.idl modified Thu Sep 12 16:41:36 2013. */ #ifndef PPAPI_C_PP_VAR_H_ #define PPAPI_C_PP_VAR_H_ @@ -53,30 +53,46 @@ typedef enum { /** * The Var represents a string. The <code>as_id</code> field is used to * identify the string, which may be created and retrieved from the - * <code>PPB_Var</code> interface. + * <code>PPB_Var</code> interface. These objects are reference counted, so + * AddRef and Release must be used properly to avoid memory leaks. */ PP_VARTYPE_STRING = 5, /** * Represents a JavaScript object. This vartype is not currently usable - * from modules, although it is used internally for some tasks. + * from modules, although it is used internally for some tasks. These objects + * are reference counted, so AddRef and Release must be used properly to avoid + * memory leaks. */ PP_VARTYPE_OBJECT = 6, /** - * Arrays and dictionaries are not currently supported but will be added - * in future revisions. These objects are reference counted so be sure - * to properly AddRef/Release them as you would with strings to ensure your - * module will continue to work with future versions of the API. + * Represents an array of Vars. The <code>as_id</code> field is used to + * identify the array, which may be created and manipulated from the + * <code>PPB_VarArray</code> interface. These objects are reference counted, + * so AddRef and Release must be used properly to avoid memory leaks. */ PP_VARTYPE_ARRAY = 7, + /** + * Represents a mapping from strings to Vars. The <code>as_id</code> field is + * used to identify the dictionary, which may be created and manipulated from + * the <code>PPB_VarDictionary</code> interface. These objects are reference + * counted, so AddRef and Release must be used properly to avoid memory leaks. + */ PP_VARTYPE_DICTIONARY = 8, /** * ArrayBuffer represents a JavaScript ArrayBuffer. This is the type which * represents Typed Arrays in JavaScript. Unlike JavaScript 'Array', it is * only meant to contain basic numeric types, and is always stored * contiguously. See PPB_VarArrayBuffer_Dev for functions special to - * ArrayBuffer vars. + * ArrayBuffer vars. These objects are reference counted, so AddRef and + * Release must be used properly to avoid memory leaks. + */ + PP_VARTYPE_ARRAY_BUFFER = 9, + /** + * Resources are not currently supported but will be added in the future + * These objects are reference counted, so AddRef and Release must be used + * properly to avoid memory leaks. */ - PP_VARTYPE_ARRAY_BUFFER = 9 + PP_VARTYPE_RESOURCE = 10 } PP_VarType; PP_COMPILE_ASSERT_SIZE_IN_BYTES(PP_VarType, 4); /** @@ -112,12 +128,12 @@ union PP_VarValue { double as_double; /** * If <code>type</code> is <code>PP_VARTYPE_STRING</code>, - * <code>PP_VARTYPE_OBJECT</code>, <code>PP_VARTYPE_ARRAY</code>, or - * <code>PP_VARTYPE_DICTIONARY</code>, - * <code>as_id</code> represents the value of this <code>PP_Var</code> as - * an opaque handle assigned by the browser. This handle is guaranteed - * never to be 0, so a module can initialize this ID to 0 to indicate a - * "NULL handle." + * <code>PP_VARTYPE_OBJECT</code>, <code>PP_VARTYPE_ARRAY</code>, + * <code>PP_VARTYPE_DICTIONARY</code>, <code>PP_VARTYPE_ARRAY_BUFFER</code>, + * or <code>PP_VARTYPE_RESOURCE</code>, <code>as_id</code> represents the + * value of this <code>PP_Var</code> as an opaque handle assigned by the + * browser. This handle is guaranteed never to be 0, so a module can + * initialize this ID to 0 to indicate a "NULL handle." */ int64_t as_id; }; diff --git a/chromium/ppapi/c/ppb_audio.h b/chromium/ppapi/c/ppb_audio.h index b71d59f62a1..d41839a177d 100644 --- a/chromium/ppapi/c/ppb_audio.h +++ b/chromium/ppapi/c/ppb_audio.h @@ -3,7 +3,7 @@ * found in the LICENSE file. */ -/* From ppb_audio.idl modified Mon Jul 9 12:03:36 2012. */ +/* From ppb_audio.idl modified Thu Aug 01 13:19:46 2013. */ #ifndef PPAPI_C_PPB_AUDIO_H_ #define PPAPI_C_PPB_AUDIO_H_ @@ -13,9 +13,11 @@ #include "ppapi/c/pp_macros.h" #include "ppapi/c/pp_resource.h" #include "ppapi/c/pp_stdint.h" +#include "ppapi/c/pp_time.h" #define PPB_AUDIO_INTERFACE_1_0 "PPB_Audio;1.0" -#define PPB_AUDIO_INTERFACE PPB_AUDIO_INTERFACE_1_0 +#define PPB_AUDIO_INTERFACE_1_1 "PPB_Audio;1.1" +#define PPB_AUDIO_INTERFACE PPB_AUDIO_INTERFACE_1_1 /** * @file @@ -33,10 +35,21 @@ * function used to fill the audio buffer with data. Please see the * Create() function in the <code>PPB_Audio</code> interface for * more details on this callback. + * + * @param[in] sample_buffer A buffer to fill with audio data. + * @param[in] buffer_size_in_bytes The size of the buffer in bytes. + * @param[in] latency How long before the audio data is to be presented. + * @param[inout] user_data An opaque pointer that was passed into + * <code>PPB_Audio.Create()</code>. */ typedef void (*PPB_Audio_Callback)(void* sample_buffer, uint32_t buffer_size_in_bytes, + PP_TimeDelta latency, void* user_data); + +typedef void (*PPB_Audio_Callback_1_0)(void* sample_buffer, + uint32_t buffer_size_in_bytes, + void* user_data); /** * @} */ @@ -78,7 +91,7 @@ typedef void (*PPB_Audio_Callback)(void* sample_buffer, * ...audio_callback() will now be periodically invoked on a separate thread... * @endcode */ -struct PPB_Audio_1_0 { +struct PPB_Audio_1_1 { /** * Create() creates an audio resource. No sound will be heard until * StartPlayback() is called. The callback is called with the buffer address @@ -157,7 +170,18 @@ struct PPB_Audio_1_0 { PP_Bool (*StopPlayback)(PP_Resource audio); }; -typedef struct PPB_Audio_1_0 PPB_Audio; +typedef struct PPB_Audio_1_1 PPB_Audio; + +struct PPB_Audio_1_0 { + PP_Resource (*Create)(PP_Instance instance, + PP_Resource config, + PPB_Audio_Callback_1_0 audio_callback, + void* user_data); + PP_Bool (*IsAudio)(PP_Resource resource); + PP_Resource (*GetCurrentConfig)(PP_Resource audio); + PP_Bool (*StartPlayback)(PP_Resource audio); + PP_Bool (*StopPlayback)(PP_Resource audio); +}; /** * @} */ diff --git a/chromium/ppapi/c/ppb_file_ref.h b/chromium/ppapi/c/ppb_file_ref.h index 0f35e2c9376..873ef188868 100644 --- a/chromium/ppapi/c/ppb_file_ref.h +++ b/chromium/ppapi/c/ppb_file_ref.h @@ -3,7 +3,7 @@ * found in the LICENSE file. */ -/* From ppb_file_ref.idl modified Wed May 22 15:08:49 2013. */ +/* From ppb_file_ref.idl modified Thu Aug 15 10:50:43 2013. */ #ifndef PPAPI_C_PPB_FILE_REF_H_ #define PPAPI_C_PPB_FILE_REF_H_ @@ -45,7 +45,7 @@ struct PPB_FileRef_1_1 { * * @param[in] resource A <code>PP_Resource</code> corresponding to a file * system. - * @param[in] path A path to the file. + * @param[in] path A path to the file. Must begin with a '/' character. * * @return A <code>PP_Resource</code> corresponding to a file reference if * successful or 0 if the path is malformed. diff --git a/chromium/ppapi/c/ppb_file_system.h b/chromium/ppapi/c/ppb_file_system.h index 28b8cca4f9a..95608322959 100644 --- a/chromium/ppapi/c/ppb_file_system.h +++ b/chromium/ppapi/c/ppb_file_system.h @@ -3,7 +3,7 @@ * found in the LICENSE file. */ -/* From ppb_file_system.idl modified Thu May 2 16:44:38 2013. */ +/* From ppb_file_system.idl modified Thu Jun 13 14:30:40 2013. */ #ifndef PPAPI_C_PPB_FILE_SYSTEM_H_ #define PPAPI_C_PPB_FILE_SYSTEM_H_ @@ -66,9 +66,7 @@ struct PPB_FileSystem_1_0 { * @param[in] expected_size The expected size of the file system. Note that * this does not request quota; to do that, you must either invoke * requestQuota from JavaScript: - - - * http://www.html5rocks.com/en/tutorials/file/filesystem/#toc-requesting-quota + * http://www.html5rocks.com/en/tutorials/file/filesystem/#toc-requesting-quota * or set the unlimitedStorage permission for Chrome Web Store apps: * http://code.google.com/chrome/extensions/manifest.html#permissions * diff --git a/chromium/ppapi/c/ppb_graphics_3d.h b/chromium/ppapi/c/ppb_graphics_3d.h index 1da70a068eb..c9ed91cba21 100644 --- a/chromium/ppapi/c/ppb_graphics_3d.h +++ b/chromium/ppapi/c/ppb_graphics_3d.h @@ -3,7 +3,7 @@ * found in the LICENSE file. */ -/* From ppb_graphics_3d.idl modified Thu Mar 28 10:12:11 2013. */ +/* From ppb_graphics_3d.idl modified Fri Aug 30 08:36:16 2013. */ #ifndef PPAPI_C_PPB_GRAPHICS_3D_H_ #define PPAPI_C_PPB_GRAPHICS_3D_H_ @@ -42,14 +42,17 @@ * int32_t attribs[] = {PP_GRAPHICS3DATTRIB_WIDTH, 800, * PP_GRAPHICS3DATTRIB_HEIGHT, 800, * PP_GRAPHICS3DATTRIB_NONE}; - * context = g3d->Create(instance, attribs, &context); + * context = g3d->Create(instance, 0, attribs); * inst->BindGraphics(instance, context); * @endcode * * <strong>Present one frame:</strong> * @code - * gles2->Clear(context, GL_COLOR_BUFFER); - * g3d->SwapBuffers(context); + * PP_CompletionCallback callback = { + * DidFinishSwappingBuffers, 0, PP_COMPLETIONCALLBACK_FLAG_NONE, + * }; + * gles2->Clear(context, GL_COLOR_BUFFER_BIT); + * g3d->SwapBuffers(context, callback); * @endcode * * <strong>Shutdown:</strong> @@ -102,7 +105,7 @@ struct PPB_Graphics3D_1_0 { * already shares with, and the newly created context. An arbitrary number of * <code>PPB_Graphics3D</code> can share data in this fashion. * - * @param[out] attrib_list specifies a list of attributes for the context. + * @param[in] attrib_list specifies a list of attributes for the context. * It is a list of attribute name-value pairs in which each attribute is * immediately followed by the corresponding desired value. The list is * terminated with <code>PP_GRAPHICS3DATTRIB_NONE</code>. diff --git a/chromium/ppapi/c/ppb_network_list.h b/chromium/ppapi/c/ppb_network_list.h new file mode 100644 index 00000000000..d7b2265d9e4 --- /dev/null +++ b/chromium/ppapi/c/ppb_network_list.h @@ -0,0 +1,183 @@ +/* Copyright (c) 2012 The Chromium Authors. All rights reserved. + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +/* From ppb_network_list.idl modified Mon Sep 9 11:16:26 2013. */ + +#ifndef PPAPI_C_PPB_NETWORK_LIST_H_ +#define PPAPI_C_PPB_NETWORK_LIST_H_ + +#include "ppapi/c/pp_array_output.h" +#include "ppapi/c/pp_bool.h" +#include "ppapi/c/pp_macros.h" +#include "ppapi/c/pp_resource.h" +#include "ppapi/c/pp_stdint.h" +#include "ppapi/c/pp_var.h" + +#define PPB_NETWORKLIST_INTERFACE_1_0 "PPB_NetworkList;1.0" +#define PPB_NETWORKLIST_INTERFACE PPB_NETWORKLIST_INTERFACE_1_0 + +/** + * @file + * This file defines the <code>PPB_NetworkList</code> interface. + */ + + +/** + * @addtogroup Enums + * @{ + */ +/** + * Type of a network interface. + */ +typedef enum { + /** + * Type of the network interface is not known. + */ + PP_NETWORKLIST_TYPE_UNKNOWN = 0, + /** + * Wired Ethernet network. + */ + PP_NETWORKLIST_TYPE_ETHERNET = 1, + /** + * Wireless Wi-Fi network. + */ + PP_NETWORKLIST_TYPE_WIFI = 2, + /** + * Cellular network (e.g. LTE). + */ + PP_NETWORKLIST_TYPE_CELLULAR = 3 +} PP_NetworkList_Type; +PP_COMPILE_ASSERT_SIZE_IN_BYTES(PP_NetworkList_Type, 4); + +/** + * State of a network interface. + */ +typedef enum { + /** + * Network interface is down. + */ + PP_NETWORKLIST_STATE_DOWN = 0, + /** + * Network interface is up. + */ + PP_NETWORKLIST_STATE_UP = 1 +} PP_NetworkList_State; +PP_COMPILE_ASSERT_SIZE_IN_BYTES(PP_NetworkList_State, 4); +/** + * @} + */ + +/** + * @addtogroup Interfaces + * @{ + */ +/** + * The <code>PPB_NetworkList</code> is used to represent a list of + * network interfaces and their configuration. The content of the list + * is immutable. The current networks configuration can be received + * using the <code>PPB_NetworkMonitor</code> interface. + */ +struct PPB_NetworkList_1_0 { + /** + * Determines if the specified <code>resource</code> is a + * <code>NetworkList</code> object. + * + * @param[in] resource A <code>PP_Resource</code> resource. + * + * @return Returns <code>PP_TRUE</code> if <code>resource</code> is + * a <code>PPB_NetworkList</code>, <code>PP_FALSE</code> + * otherwise. + */ + PP_Bool (*IsNetworkList)(PP_Resource resource); + /** + * Gets number of interfaces in the list. + * + * @param[in] resource A <code>PP_Resource</code> corresponding to a + * network list. + * + * @return Returns number of available network interfaces or 0 if + * the list has never been updated. + */ + uint32_t (*GetCount)(PP_Resource resource); + /** + * Gets name of a network interface. + * + * @param[in] resource A <code>PP_Resource</code> corresponding to a + * network list. + * @param[in] index Index of the network interface. + * + * @return Returns name for the network interface with the specified + * <code>index</code>. + */ + struct PP_Var (*GetName)(PP_Resource resource, uint32_t index); + /** + * Gets type of a network interface. + * + * @param[in] resource A <code>PP_Resource</code> corresponding to a + * network list. + * @param[in] index Index of the network interface. + * + * @return Returns type of the network interface with the specified + * <code>index</code>. + */ + PP_NetworkList_Type (*GetType)(PP_Resource resource, uint32_t index); + /** + * Gets state of a network interface. + * + * @param[in] resource A <code>PP_Resource</code> corresponding to a + * network list. + * @param[in] index Index of the network interface. + * + * @return Returns current state of the network interface with the + * specified <code>index</code>. + */ + PP_NetworkList_State (*GetState)(PP_Resource resource, uint32_t index); + /** + * Gets list of IP addresses for a network interface. + * + * @param[in] resource A <code>PP_Resource</code> corresponding to a + * network list. + * @param[in] index Index of the network interface. + * @param[in] output An output array which will receive + * <code>PPB_NetAddress</code> resources on success. Please note that the + * ref count of those resources has already been increased by 1 for the + * caller. + * + * @return An error code from <code>pp_errors.h</code>. + */ + int32_t (*GetIpAddresses)(PP_Resource resource, + uint32_t index, + struct PP_ArrayOutput output); + /** + * Gets display name of a network interface. + * + * @param[in] resource A <code>PP_Resource</code> corresponding to a + * network list. + * @param[in] index Index of the network interface. + * + * @return Returns display name for the network interface with the + * specified <code>index</code>. + */ + struct PP_Var (*GetDisplayName)(PP_Resource resource, uint32_t index); + /** + * Gets MTU (Maximum Transmission Unit) of a network interface. + * + * @param[in] resource A <code>PP_Resource</code> corresponding to a + * network list. + * @param[in] index Index of the network interface. + * + * @return Returns MTU for the network interface with the specified + * <code>index</code> or 0 if MTU is unknown. + */ + uint32_t (*GetMTU)(PP_Resource resource, uint32_t index); +}; + +typedef struct PPB_NetworkList_1_0 PPB_NetworkList; +/** + * @} + */ + +#endif /* PPAPI_C_PPB_NETWORK_LIST_H_ */ + diff --git a/chromium/ppapi/c/ppb_network_monitor.h b/chromium/ppapi/c/ppb_network_monitor.h new file mode 100644 index 00000000000..6408a453b91 --- /dev/null +++ b/chromium/ppapi/c/ppb_network_monitor.h @@ -0,0 +1,89 @@ +/* Copyright (c) 2012 The Chromium Authors. All rights reserved. + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +/* From ppb_network_monitor.idl modified Thu Sep 19 16:42:34 2013. */ + +#ifndef PPAPI_C_PPB_NETWORK_MONITOR_H_ +#define PPAPI_C_PPB_NETWORK_MONITOR_H_ + +#include "ppapi/c/pp_bool.h" +#include "ppapi/c/pp_completion_callback.h" +#include "ppapi/c/pp_instance.h" +#include "ppapi/c/pp_macros.h" +#include "ppapi/c/pp_resource.h" +#include "ppapi/c/pp_stdint.h" + +#define PPB_NETWORKMONITOR_INTERFACE_1_0 "PPB_NetworkMonitor;1.0" +#define PPB_NETWORKMONITOR_INTERFACE PPB_NETWORKMONITOR_INTERFACE_1_0 + +/** + * @file + * This file defines the <code>PPB_NetworkMonitor</code> interface. + */ + + +/** + * @addtogroup Interfaces + * @{ + */ +/** + * The <code>PPB_NetworkMonitor</code> allows to get network interfaces + * configuration and monitor network configuration changes. + * + * Permissions: Apps permission <code>socket</code> with subrule + * <code>network-state</code> is required for <code>UpdateNetworkList()</code>. + * For more details about network communication permissions, please see: + * http://developer.chrome.com/apps/app_network.html + */ +struct PPB_NetworkMonitor_1_0 { + /** + * Creates a Network Monitor resource. + * + * @param[in] instance A <code>PP_Instance</code> identifying one instance of + * a module. + * + * @return A <code>PP_Resource</code> corresponding to a network monitor or 0 + * on failure. + */ + PP_Resource (*Create)(PP_Instance instance); + /** + * Gets current network configuration. When called for the first time, + * completes as soon as the current network configuration is received from + * the browser. Each consequent call will wait for network list changes, + * returning a new <code>PPB_NetworkList</code> resource every time. + * + * @param[in] network_monitor A <code>PP_Resource</code> corresponding to a + * network monitor. + * @param[out] network_list The <code>PPB_NetworkList<code> resource with the + * current state of network interfaces. + * @param[in] callback A <code>PP_CompletionCallback</code> to be called upon + * completion. + * + * @return An int32_t containing an error code from <code>pp_errors.h</code>. + * <code>PP_ERROR_NOACCESS</code> will be returned if the caller doesn't have + * required permissions. + */ + int32_t (*UpdateNetworkList)(PP_Resource network_monitor, + PP_Resource* network_list, + struct PP_CompletionCallback callback); + /** + * Determines if the specified <code>resource</code> is a + * <code>NetworkMonitor</code> object. + * + * @param[in] resource A <code>PP_Resource</code> resource. + * + * @return Returns <code>PP_TRUE</code> if <code>resource</code> is a + * <code>PPB_NetworkMonitor</code>, <code>PP_FALSE</code> otherwise. + */ + PP_Bool (*IsNetworkMonitor)(PP_Resource resource); +}; + +typedef struct PPB_NetworkMonitor_1_0 PPB_NetworkMonitor; +/** + * @} + */ + +#endif /* PPAPI_C_PPB_NETWORK_MONITOR_H_ */ + diff --git a/chromium/ppapi/c/ppb_tcp_socket.h b/chromium/ppapi/c/ppb_tcp_socket.h index 467656fe88a..a6fe111f71e 100644 --- a/chromium/ppapi/c/ppb_tcp_socket.h +++ b/chromium/ppapi/c/ppb_tcp_socket.h @@ -3,7 +3,7 @@ * found in the LICENSE file. */ -/* From ppb_tcp_socket.idl modified Sat Jun 22 11:17:34 2013. */ +/* From ppb_tcp_socket.idl modified Fri Sep 20 09:58:19 2013. */ #ifndef PPAPI_C_PPB_TCP_SOCKET_H_ #define PPAPI_C_PPB_TCP_SOCKET_H_ @@ -17,7 +17,8 @@ #include "ppapi/c/pp_var.h" #define PPB_TCPSOCKET_INTERFACE_1_0 "PPB_TCPSocket;1.0" -#define PPB_TCPSOCKET_INTERFACE PPB_TCPSOCKET_INTERFACE_1_0 +#define PPB_TCPSOCKET_INTERFACE_1_1 "PPB_TCPSocket;1.1" +#define PPB_TCPSOCKET_INTERFACE PPB_TCPSOCKET_INTERFACE_1_1 /** * @file @@ -73,11 +74,12 @@ PP_COMPILE_ASSERT_SIZE_IN_BYTES(PP_TCPSocket_Option, 4); * The <code>PPB_TCPSocket</code> interface provides TCP socket operations. * * Permissions: Apps permission <code>socket</code> with subrule - * <code>tcp-connect</code> is required for <code>Connect()</code>. + * <code>tcp-connect</code> is required for <code>Connect()</code>; subrule + * <code>tcp-listen</code> is required for <code>Listen()</code>. * For more details about network communication permissions, please see: * http://developer.chrome.com/apps/app_network.html */ -struct PPB_TCPSocket_1_0 { +struct PPB_TCPSocket_1_1 { /** * Creates a TCP socket resource. * @@ -98,7 +100,25 @@ struct PPB_TCPSocket_1_0 { */ PP_Bool (*IsTCPSocket)(PP_Resource resource); /** - * Connects the socket to the given address. + * Binds the socket to the given address. The socket must not be bound. + * + * @param[in] tcp_socket A <code>PP_Resource</code> corresponding to a TCP + * socket. + * @param[in] addr A <code>PPB_NetAddress</code> resource. + * @param[in] callback A <code>PP_CompletionCallback</code> to be called upon + * completion. + * + * @return An int32_t containing an error code from <code>pp_errors.h</code>, + * including (but not limited to): + * - <code>PP_ERROR_ADDRESS_IN_USE</code>: the address is already in use. + * - <code>PP_ERROR_ADDRESS_INVALID</code>: the address is invalid. + */ + int32_t (*Bind)(PP_Resource tcp_socket, + PP_Resource addr, + struct PP_CompletionCallback callback); + /** + * Connects the socket to the given address. The socket must not be listening. + * Binding the socket beforehand is optional. * * @param[in] tcp_socket A <code>PP_Resource</code> corresponding to a TCP * socket. @@ -117,12 +137,17 @@ struct PPB_TCPSocket_1_0 { * - <code>PP_ERROR_CONNECTION_FAILED</code>: the connection attempt failed. * - <code>PP_ERROR_CONNECTION_TIMEDOUT</code>: the connection attempt timed * out. + * + * Since version 1.1, if the socket is listening/connected or has a pending + * listen/connect request, <code>Connect()</code> will fail without starting a + * connection attempt; otherwise, any failure during the connection attempt + * will cause the socket to be closed. */ int32_t (*Connect)(PP_Resource tcp_socket, PP_Resource addr, struct PP_CompletionCallback callback); /** - * Gets the local address of the socket, if it is connected. + * Gets the local address of the socket, if it is bound. * * @param[in] tcp_socket A <code>PP_Resource</code> corresponding to a TCP * socket. @@ -178,11 +203,48 @@ struct PPB_TCPSocket_1_0 { int32_t bytes_to_write, struct PP_CompletionCallback callback); /** - * Cancels all pending reads and writes and disconnects the socket. Any - * pending callbacks will still run, reporting <code>PP_ERROR_ABORTED</code> - * if pending IO was interrupted. After a call to this method, no output - * buffer pointers passed into previous <code>Read()</code> calls will be - * accessed. It is not valid to call <code>Connect()</code> again. + * Starts listening. The socket must be bound and not connected. + * + * @param[in] tcp_socket A <code>PP_Resource</code> corresponding to a TCP + * socket. + * @param[in] backlog A hint to determine the maximum length to which the + * queue of pending connections may grow. + * @param[in] callback A <code>PP_CompletionCallback</code> to be called upon + * completion. + * + * @return An int32_t containing an error code from <code>pp_errors.h</code>, + * including (but not limited to): + * - <code>PP_ERROR_NOACCESS</code>: the caller doesn't have required + * permissions. + * - <code>PP_ERROR_ADDRESS_IN_USE</code>: Another socket is already listening + * on the same port. + */ + int32_t (*Listen)(PP_Resource tcp_socket, + int32_t backlog, + struct PP_CompletionCallback callback); + /** + * Accepts a connection. The socket must be listening. + * + * @param[in] tcp_socket A <code>PP_Resource</code> corresponding to a TCP + * socket. + * @param[out] accepted_tcp_socket Stores the accepted TCP socket on success. + * @param[in] callback A <code>PP_CompletionCallback</code> to be called upon + * completion. + * + * @return An int32_t containing an error code from <code>pp_errors.h</code>, + * including (but not limited to): + * - <code>PP_ERROR_CONNECTION_ABORTED</code>: A connection has been aborted. + */ + int32_t (*Accept)(PP_Resource tcp_socket, + PP_Resource* accepted_tcp_socket, + struct PP_CompletionCallback callback); + /** + * Cancels all pending operations and closes the socket. Any pending callbacks + * will still run, reporting <code>PP_ERROR_ABORTED</code> if pending IO was + * interrupted. After a call to this method, no output buffer pointers passed + * into previous <code>Read()</code> or <code>Accept()</code> calls will be + * accessed. It is not valid to call <code>Connect()</code> or + * <code>Listen()</code> again. * * The socket is implicitly closed if it is destroyed, so you are not required * to call this method. @@ -211,7 +273,30 @@ struct PPB_TCPSocket_1_0 { struct PP_CompletionCallback callback); }; -typedef struct PPB_TCPSocket_1_0 PPB_TCPSocket; +typedef struct PPB_TCPSocket_1_1 PPB_TCPSocket; + +struct PPB_TCPSocket_1_0 { + PP_Resource (*Create)(PP_Instance instance); + PP_Bool (*IsTCPSocket)(PP_Resource resource); + int32_t (*Connect)(PP_Resource tcp_socket, + PP_Resource addr, + struct PP_CompletionCallback callback); + PP_Resource (*GetLocalAddress)(PP_Resource tcp_socket); + PP_Resource (*GetRemoteAddress)(PP_Resource tcp_socket); + int32_t (*Read)(PP_Resource tcp_socket, + char* buffer, + int32_t bytes_to_read, + struct PP_CompletionCallback callback); + int32_t (*Write)(PP_Resource tcp_socket, + const char* buffer, + int32_t bytes_to_write, + struct PP_CompletionCallback callback); + void (*Close)(PP_Resource tcp_socket); + int32_t (*SetOption)(PP_Resource tcp_socket, + PP_TCPSocket_Option name, + struct PP_Var value, + struct PP_CompletionCallback callback); +}; /** * @} */ diff --git a/chromium/ppapi/c/private/ppb_content_decryptor_private.h b/chromium/ppapi/c/private/ppb_content_decryptor_private.h index e42c3c9e3d5..86f239aab10 100644 --- a/chromium/ppapi/c/private/ppb_content_decryptor_private.h +++ b/chromium/ppapi/c/private/ppb_content_decryptor_private.h @@ -4,7 +4,7 @@ */ /* From private/ppb_content_decryptor_private.idl, - * modified Thu Mar 28 15:22:02 2013. + * modified Tue Sep 17 11:31:05 2013. */ #ifndef PPAPI_C_PRIVATE_PPB_CONTENT_DECRYPTOR_PRIVATE_H_ @@ -18,10 +18,10 @@ #include "ppapi/c/pp_var.h" #include "ppapi/c/private/pp_content_decryptor.h" -#define PPB_CONTENTDECRYPTOR_PRIVATE_INTERFACE_0_6 \ - "PPB_ContentDecryptor_Private;0.6" +#define PPB_CONTENTDECRYPTOR_PRIVATE_INTERFACE_0_7 \ + "PPB_ContentDecryptor_Private;0.7" #define PPB_CONTENTDECRYPTOR_PRIVATE_INTERFACE \ - PPB_CONTENTDECRYPTOR_PRIVATE_INTERFACE_0_6 + PPB_CONTENTDECRYPTOR_PRIVATE_INTERFACE_0_7 /** * @file @@ -42,34 +42,7 @@ * browser side support for the Content Decryption Module (CDM) for v0.1 of the * proposed Encrypted Media Extensions: http://goo.gl/rbdnR */ -struct PPB_ContentDecryptor_Private_0_6 { - /** - * The decryptor requires a key that has not been provided. - * - * Sent when the decryptor encounters encrypted content, but it does not have - * the key required to decrypt the data. The plugin will call this method in - * response to a call to the <code>Decrypt()</code> method on the - * <code>PPP_ContentDecryptor_Private<code> interface. - * - * The browser must notify the application that a key is needed, and, in - * response, the web application must direct the browser to call - * <code>AddKey()</code> on the <code>PPP_ContentDecryptor_Private</code> - * interface. - * - * @param[in] key_system A <code>PP_Var</code> of type - * <code>PP_VARTYPE_STRING</code> containing the name of the key system. - * - * @param[in] session_id A <code>PP_Var</code> of type - * <code>PP_VARTYPE_STRING</code> containing the session ID. - * - * @param[in] init_data A <code>PP_Var</code> of type - * <code>PP_VARTYPE_ARRAY_BUFFER</code> containing container-specific - * initialization data. - */ - void (*NeedKey)(PP_Instance instance, - struct PP_Var key_system, - struct PP_Var session_id, - struct PP_Var init_data); +struct PPB_ContentDecryptor_Private_0_7 { /** * A key has been added as the result of a call to the <code>AddKey()</code> * method on the <code>PPP_ContentDecryptor_Private</code> interface. @@ -271,7 +244,7 @@ struct PPB_ContentDecryptor_Private_0_6 { const struct PP_DecryptedBlockInfo* decrypted_block_info); }; -typedef struct PPB_ContentDecryptor_Private_0_6 PPB_ContentDecryptor_Private; +typedef struct PPB_ContentDecryptor_Private_0_7 PPB_ContentDecryptor_Private; /** * @} */ diff --git a/chromium/ppapi/c/private/ppb_gpu_blacklist_private.h b/chromium/ppapi/c/private/ppb_gpu_blacklist_private.h deleted file mode 100644 index f37106ef343..00000000000 --- a/chromium/ppapi/c/private/ppb_gpu_blacklist_private.h +++ /dev/null @@ -1,49 +0,0 @@ -/* Copyright (c) 2012 The Chromium Authors. All rights reserved. - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -/* From private/ppb_gpu_blacklist_private.idl, - * modified Wed Oct 24 14:41:20 2012. - */ - -#ifndef PPAPI_C_PRIVATE_PPB_GPU_BLACKLIST_PRIVATE_H_ -#define PPAPI_C_PRIVATE_PPB_GPU_BLACKLIST_PRIVATE_H_ - -#include "ppapi/c/pp_bool.h" -#include "ppapi/c/pp_macros.h" - -#define PPB_GPUBLACKLIST_PRIVATE_INTERFACE_0_2 "PPB_GpuBlacklist_Private;0.2" -#define PPB_GPUBLACKLIST_PRIVATE_INTERFACE \ - PPB_GPUBLACKLIST_PRIVATE_INTERFACE_0_2 - -/** - * @file - * This file contains the <code>PPB_FileRefPrivate</code> interface. */ - - -/** - * @addtogroup Interfaces - * @{ - */ -/** PPB_GpuBlacklist_Private interface */ -struct PPB_GpuBlacklist_Private_0_2 { - /** - * Returns true if the current system's GPU is blacklisted and 3D in Chrome - * will be emulated via software rendering. - * - * This is used internally by the SRPC NaCl proxy (not exposed to plugins) to - * determine if the 3D interfaces should be exposed to plugins. We don't - * expose the 3D interfaces if the 3D support is software-emulated. When the - * SRPC proxy is removed, this interface can also be removed. - */ - PP_Bool (*IsGpuBlacklisted)(void); -}; - -typedef struct PPB_GpuBlacklist_Private_0_2 PPB_GpuBlacklist_Private; -/** - * @} - */ - -#endif /* PPAPI_C_PRIVATE_PPB_GPU_BLACKLIST_PRIVATE_H_ */ - diff --git a/chromium/ppapi/c/private/ppb_nacl_private.h b/chromium/ppapi/c/private/ppb_nacl_private.h index 8be28293386..6441efd59be 100644 --- a/chromium/ppapi/c/private/ppb_nacl_private.h +++ b/chromium/ppapi/c/private/ppb_nacl_private.h @@ -3,7 +3,7 @@ * found in the LICENSE file. */ -/* From private/ppb_nacl_private.idl modified Tue Aug 6 11:51:26 2013. */ +/* From private/ppb_nacl_private.idl modified Thu Aug 29 17:42:12 2013. */ #ifndef PPAPI_C_PRIVATE_PPB_NACL_PRIVATE_H_ #define PPAPI_C_PRIVATE_PPB_NACL_PRIVATE_H_ @@ -63,6 +63,9 @@ struct PPB_NaCl_Private_1_0 { * will be able to use dynamic code system calls (e.g., mmap with PROT_EXEC). * The |enable_exception_handling| flag indicates whether or not the nexe * will be able to use hardware exception handling. + * The |enable_crash_throttling| flag indicates whether or not crashes of + * the nexe contribute to crash throttling statisics and whether nexe starts + * are throttled by crash throttling. */ PP_ExternalPluginResult (*LaunchSelLdr)(PP_Instance instance, const char* alleged_url, @@ -71,6 +74,7 @@ struct PPB_NaCl_Private_1_0 { PP_Bool enable_ppapi_dev, PP_Bool enable_dyncode_syscalls, PP_Bool enable_exception_handling, + PP_Bool enable_crash_throttling, void* imc_handle, struct PP_Var* error_message); /* This function starts the IPC proxy so the nexe can communicate with the @@ -118,18 +122,19 @@ struct PPB_NaCl_Private_1_0 { * returns a posix handle to that temporary file. */ PP_FileHandle (*CreateTemporaryFile)(PP_Instance instance); - /* Create a temporary file, which will be deleted by the time the last - * handle is closed (or earlier on POSIX systems), to use for the nexe - * with the cache information given by |pexe_url|, |abi_version|, |opt_level|, - * |last_modified|, and |etag|. If the nexe is already present - * in the cache, |is_hit| is set to PP_TRUE and the contents of the nexe - * will be copied into the temporary file. Otherwise |is_hit| is set to - * PP_FALSE and the temporary file will be writeable. - * Currently the implementation is a stub, which always sets is_hit to false - * and calls the implementation of CreateTemporaryFile. In a subsequent CL - * it will call into the browser which will remember the association between - * the cache key and the fd, and copy the nexe into the cache after the - * translation finishes. + /* Create a temporary file, which will be deleted by the time the + * last handle is closed (or earlier on POSIX systems), to use for + * the nexe with the cache information given by |pexe_url|, + * |abi_version|, |opt_level|, |last_modified|, |etag|, and + * |has_no_store_header|. If the nexe is already present in the + * cache, |is_hit| is set to PP_TRUE and the contents of the nexe + * will be copied into the temporary file. Otherwise |is_hit| is set + * to PP_FALSE and the temporary file will be writeable. Currently + * the implementation is a stub, which always sets is_hit to false + * and calls the implementation of CreateTemporaryFile. In a + * subsequent CL it will call into the browser which will remember + * the association between the cache key and the fd, and copy the + * nexe into the cache after the translation finishes. */ int32_t (*GetNexeFd)(PP_Instance instance, const char* pexe_url, @@ -137,6 +142,7 @@ struct PPB_NaCl_Private_1_0 { uint32_t opt_level, const char* last_modified, const char* etag, + PP_Bool has_no_store_header, PP_Bool* is_hit, PP_FileHandle* nexe_handle, struct PP_CompletionCallback callback); diff --git a/chromium/ppapi/c/private/ppb_network_list_private.h b/chromium/ppapi/c/private/ppb_network_list_private.h deleted file mode 100644 index 2cba36262b0..00000000000 --- a/chromium/ppapi/c/private/ppb_network_list_private.h +++ /dev/null @@ -1,149 +0,0 @@ -/* Copyright (c) 2012 The Chromium Authors. All rights reserved. - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -/* From private/ppb_network_list_private.idl, - * modified Thu Mar 1 16:24:33 2012. - */ - -#ifndef PPAPI_C_PRIVATE_PPB_NETWORK_LIST_PRIVATE_H_ -#define PPAPI_C_PRIVATE_PPB_NETWORK_LIST_PRIVATE_H_ - -#include "ppapi/c/pp_bool.h" -#include "ppapi/c/pp_macros.h" -#include "ppapi/c/pp_resource.h" -#include "ppapi/c/pp_stdint.h" -#include "ppapi/c/pp_var.h" -#include "ppapi/c/private/ppb_net_address_private.h" - -#define PPB_NETWORKLIST_PRIVATE_INTERFACE_0_2 "PPB_NetworkList_Private;0.2" -#define PPB_NETWORKLIST_PRIVATE_INTERFACE PPB_NETWORKLIST_PRIVATE_INTERFACE_0_2 - -/** - * @file - * This file defines the <code>PPB_NetworkList_Private</code> interface. - */ - - -/** - * @addtogroup Enums - * @{ - */ -/** - * Type of a network interface. - */ -typedef enum { - /** - * Type of the network interface is not known. - */ - PP_NETWORKLIST_UNKNOWN = 0, - /** - * Wired Ethernet network. - */ - PP_NETWORKLIST_ETHERNET = 1, - /** - * Wireless Wi-Fi network. - */ - PP_NETWORKLIST_WIFI = 2, - /** - * Cellular network (e.g. LTE). - */ - PP_NETWORKLIST_CELLULAR = 3 -} PP_NetworkListType_Private; -PP_COMPILE_ASSERT_SIZE_IN_BYTES(PP_NetworkListType_Private, 4); - -/** - * State of a network interface. - */ -typedef enum { - /** - * Network interface is down. - */ - PP_NETWORKLIST_DOWN = 0, - /** - * Network interface is up. - */ - PP_NETWORKLIST_UP = 1 -} PP_NetworkListState_Private; -PP_COMPILE_ASSERT_SIZE_IN_BYTES(PP_NetworkListState_Private, 4); -/** - * @} - */ - -/** - * @addtogroup Interfaces - * @{ - */ -/** - * The <code>PPB_NetworkList_Private</code> is used to represent a - * list of network interfaces and their configuration. The content of - * the list is immutable. The current networks configuration can be - * received using the <code>PPB_NetworkMonitor_Private</code> - * interface. - */ -struct PPB_NetworkList_Private_0_2 { - /** - * Determines if the specified <code>resource</code> is a - * <code>NetworkList</code> object. - * - * @param[in] resource A <code>PP_Resource</code> resource. - * - * @return Returns <code>PP_TRUE</code> if <code>resource</code> is - * a <code>PPB_NetworkList_Private</code>, <code>PP_FALSE</code> - * otherwise. - */ - PP_Bool (*IsNetworkList)(PP_Resource resource); - /** - * @return Returns number of available network interfaces or 0 if - * the list has never been updated. - */ - uint32_t (*GetCount)(PP_Resource resource); - /** - * @return Returns name for the network interface with the specified - * <code>index</code>. - */ - struct PP_Var (*GetName)(PP_Resource resource, uint32_t index); - /** - * @return Returns type of the network interface with the specified - * <code>index</code>. - */ - PP_NetworkListType_Private (*GetType)(PP_Resource resource, uint32_t index); - /** - * @return Returns current state of the network interface with the - * specified <code>index</code>. - */ - PP_NetworkListState_Private (*GetState)(PP_Resource resource, uint32_t index); - /** - * Gets list of IP addresses for the network interface with the - * specified <code>index</code> and stores them in - * <code>addresses</code>. If the caller didn't allocate sufficient - * space to store all addresses, then only the first - * <code>count</code> addresses are filled in. - * - * @return Returns total number of IP addresses assigned to the - * network interface or a negative error code. - */ - int32_t (*GetIpAddresses)(PP_Resource resource, - uint32_t index, - struct PP_NetAddress_Private addresses[], - uint32_t count); - /** - * @return Returns display name for the network interface with the - * specified <code>index</code>. - */ - struct PP_Var (*GetDisplayName)(PP_Resource resource, uint32_t index); - /** - * @return Returns MTU for the network interface with the specified - * <code>index</code> or 0 if MTU is unknown. - */ - uint32_t (*GetMTU)(PP_Resource resource, uint32_t index); -}; - -typedef struct PPB_NetworkList_Private_0_2 PPB_NetworkList_Private; -/** - * @} - */ - -#endif /* PPAPI_C_PRIVATE_PPB_NETWORK_LIST_PRIVATE_H_ */ - diff --git a/chromium/ppapi/c/private/ppb_network_monitor_private.h b/chromium/ppapi/c/private/ppb_network_monitor_private.h deleted file mode 100644 index 93c1ff03bd1..00000000000 --- a/chromium/ppapi/c/private/ppb_network_monitor_private.h +++ /dev/null @@ -1,97 +0,0 @@ -/* Copyright (c) 2012 The Chromium Authors. All rights reserved. - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -/* From private/ppb_network_monitor_private.idl, - * modified Thu Mar 28 10:30:11 2013. - */ - -#ifndef PPAPI_C_PRIVATE_PPB_NETWORK_MONITOR_PRIVATE_H_ -#define PPAPI_C_PRIVATE_PPB_NETWORK_MONITOR_PRIVATE_H_ - -#include "ppapi/c/pp_bool.h" -#include "ppapi/c/pp_instance.h" -#include "ppapi/c/pp_macros.h" -#include "ppapi/c/pp_resource.h" -#include "ppapi/c/pp_stdint.h" - -#define PPB_NETWORKMONITOR_PRIVATE_INTERFACE_0_2 \ - "PPB_NetworkMonitor_Private;0.2" -#define PPB_NETWORKMONITOR_PRIVATE_INTERFACE \ - PPB_NETWORKMONITOR_PRIVATE_INTERFACE_0_2 - -/** - * @file - * This file defines the <code>PPB_NetworkMonitor_Private</code> interface. - */ - - -/** - * @addtogroup Typedefs - * @{ - */ -/** - * <code>PPB_NetworkMonitor_Callback</code> is a callback function - * type that is used to receive notifications about network - * configuration changes. The <code>network_list</code> passed to this - * callback is a <code>PPB_NetworkList_Private</code> resource that - * contains current configuration of network interfaces. - */ -typedef void (*PPB_NetworkMonitor_Callback)(void* user_data, - PP_Resource network_list); -/** - * @} - */ - -/** - * @addtogroup Interfaces - * @{ - */ -/** - * The <code>PPB_NetworkMonitor_Private</code> provides access to - * notifications of network configuration changes. - */ -struct PPB_NetworkMonitor_Private_0_2 { - /** - * Starts network change monitoring. The specified - * <code>callback</code> will be called on the main thread once - * after this method is called (to supply the initial network - * configuration) and then later every time network configuration - * changes. Notifications are stopped when the returned resource is - * destroyed. If the plugin doesn't have access to the network list - * then the callback will be called once with the - * <code>network_list</code> parameter is set to 0. - * - * @param[in] callback The callback that will be called every time - * network configuration changes or NULL to stop network monitoring. - * - * @param[inout] user_data The data to be passed to the callback on - * each call. - * - * @return A <code>PP_Resource</code> containing the created - * NetworkMonitor resource. - */ - PP_Resource (*Create)(PP_Instance instance, - PPB_NetworkMonitor_Callback callback, - void* user_data); - /** - * Determines if the specified <code>resource</code> is a - * <code>NetworkMonitor</code> object. - * - * @param[in] resource A <code>PP_Resource</code> resource. - * - * @return Returns <code>PP_TRUE</code> if <code>resource</code> is - * a <code>PPB_NetworkMonitor_Private</code>, <code>PP_FALSE</code> - * otherwise. - */ - PP_Bool (*IsNetworkMonitor)(PP_Resource resource); -}; - -typedef struct PPB_NetworkMonitor_Private_0_2 PPB_NetworkMonitor_Private; -/** - * @} - */ - -#endif /* PPAPI_C_PRIVATE_PPB_NETWORK_MONITOR_PRIVATE_H_ */ - diff --git a/chromium/ppapi/c/private/ppb_output_protection_private.h b/chromium/ppapi/c/private/ppb_output_protection_private.h new file mode 100644 index 00000000000..d0438be8f32 --- /dev/null +++ b/chromium/ppapi/c/private/ppb_output_protection_private.h @@ -0,0 +1,168 @@ +/* Copyright 2013 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. + */ + +/* From private/ppb_output_protection_private.idl, + * modified Sat Aug 31 03:18:39 2013. + */ + +#ifndef PPAPI_C_PRIVATE_PPB_OUTPUT_PROTECTION_PRIVATE_H_ +#define PPAPI_C_PRIVATE_PPB_OUTPUT_PROTECTION_PRIVATE_H_ + +#include "ppapi/c/pp_bool.h" +#include "ppapi/c/pp_completion_callback.h" +#include "ppapi/c/pp_instance.h" +#include "ppapi/c/pp_macros.h" +#include "ppapi/c/pp_resource.h" +#include "ppapi/c/pp_stdint.h" + +#define PPB_OUTPUTPROTECTION_PRIVATE_INTERFACE_0_1 \ + "PPB_OutputProtection_Private;0.1" +#define PPB_OUTPUTPROTECTION_PRIVATE_INTERFACE \ + PPB_OUTPUTPROTECTION_PRIVATE_INTERFACE_0_1 + +/** + * @file + * This file defines the API for output protection. Currently, it only supports + * Chrome OS. + */ + + +/** + * @addtogroup Enums + * @{ + */ +/** + * Content protection methods applied on video output link. + */ +typedef enum { + PP_OUTPUT_PROTECTION_METHOD_PRIVATE_NONE = 0, + PP_OUTPUT_PROTECTION_METHOD_PRIVATE_HDCP = 1 << 0 +} PP_OutputProtectionMethod_Private; +PP_COMPILE_ASSERT_SIZE_IN_BYTES(PP_OutputProtectionMethod_Private, 4); + +/** + * Video output link types. + */ +typedef enum { + PP_OUTPUT_PROTECTION_LINK_TYPE_PRIVATE_NONE = 0, + PP_OUTPUT_PROTECTION_LINK_TYPE_PRIVATE_UNKNOWN = 1 << 0, + PP_OUTPUT_PROTECTION_LINK_TYPE_PRIVATE_INTERNAL = 1 << 1, + PP_OUTPUT_PROTECTION_LINK_TYPE_PRIVATE_VGA = 1 << 2, + PP_OUTPUT_PROTECTION_LINK_TYPE_PRIVATE_HDMI = 1 << 3, + PP_OUTPUT_PROTECTION_LINK_TYPE_PRIVATE_DVI = 1 << 4, + PP_OUTPUT_PROTECTION_LINK_TYPE_PRIVATE_DISPLAYPORT = 1 << 5 +} PP_OutputProtectionLinkType_Private; +PP_COMPILE_ASSERT_SIZE_IN_BYTES(PP_OutputProtectionLinkType_Private, 4); +/** + * @} + */ + +/** + * @addtogroup Interfaces + * @{ + */ +/** + * The <code>PPB_OutputProtection_Private</code> interface allows controlling + * output protection. + * + * <strong>Example:</strong> + * + * @code + * op = output_protection->Create(instance); + * output_protection->QueryStatus(op, &link_mask, &protection_mask, + * done_callback); + * @endcode + * + * In this example, the plugin wants to enforce HDCP for HDMI link. + * @code + * if (link_mask & PP_OUTPUT_PROTECTION_LINK_TYPE_PRIVATE_HDMI) { + * output_protection->EnableProtection( + * op, PP_OUTPUT_PROTECTION_METHOD_PRIVATE_HDCP, done_callback); + * } + * @endcode + * + * After EnableProtection() completes, the plugin has to query protection + * status periodically to make sure the protection is enabled and remains + * enabled. + */ +struct PPB_OutputProtection_Private_0_1 { + /** + * Create() creates a new <code>PPB_OutputProtection_Private</code> object. + * + * @pram[in] instance A <code>PP_Instance</code> identifying one instance of + * a module. + * + * @return A <code>PP_Resource</code> corresponding to a + * <code>PPB_OutputProtection_Private</code> if successful, 0 if creation + * failed. + */ + PP_Resource (*Create)(PP_Instance instance); + /** + * IsOutputProtection() determines if the provided resource is a + * <code>PPB_OutputProtection_Private</code>. + * + * @param[in] resource A <code>PP_Resource</code> corresponding to a + * <code>PPB_OutputProtection_Private</code>. + * + * @return <code>PP_TRUE</code> if the resource is a + * <code>PPB_OutputProtection_Private</code>, <code>PP_FALSE</code> if the + * resource is invalid or some type other than + * <code>PPB_OutputProtection_Private</code>. + */ + PP_Bool (*IsOutputProtection)(PP_Resource resource); + /** + * Query link status and protection status. + * Clients have to query status periodically in order to detect changes. + * + * @param[in] resource A <code>PP_Resource</code> corresponding to a + * <code>PPB_OutputProtection_Private</code>. + * @param[out] link_mask The type of connected output links, which is a + * bit-mask of the <code>PP_OutputProtectionLinkType_Private</code> values. + * @param[out] protection_mask Enabled protection methods, which is a + * bit-mask of the <code>PP_OutputProtectionMethod_Private</code> values. + * @param[in] callback A <code>PP_CompletionCallback</code> to run on + * asynchronous completion of QueryStatus(). This callback will only run if + * QueryStatus() returns <code>PP_OK_COMPLETIONPENDING</code>. + * + * @return An int32_t containing an error code from <code>pp_errors.h</code>. + */ + int32_t (*QueryStatus)(PP_Resource resource, + uint32_t* link_mask, + uint32_t* protection_mask, + struct PP_CompletionCallback callback); + /** + * Set desired protection methods. + * + * When the desired protection method(s) have been applied to all applicable + * output links, the relevant bit(s) of the protection_mask returned by + * QueryStatus() will be set. Otherwise, the relevant bit(s) of + * protection_mask will not be set; there is no separate error code or + * callback. + * + * Protections will be disabled if no longer desired by all instances. + * + * @param[in] resource A <code>PP_Resource</code> corresponding to a + * <code>PPB_OutputProtection_Private</code>. + * @param[in] desired_protection_mask The desired protection methods, which + * is a bit-mask of the <code>PP_OutputProtectionMethod_Private</code> + * values. + * @param[in] callback A <code>PP_CompletionCallback</code> to be called when + * the protection request has been made. This may be before the protection + * have actually been applied. Call QueryStatus to get protection status. + * + * @return An int32_t containing an error code from <code>pp_errors.h</code>. + */ + int32_t (*EnableProtection)(PP_Resource resource, + uint32_t desired_protection_mask, + struct PP_CompletionCallback callback); +}; + +typedef struct PPB_OutputProtection_Private_0_1 PPB_OutputProtection_Private; +/** + * @} + */ + +#endif /* PPAPI_C_PRIVATE_PPB_OUTPUT_PROTECTION_PRIVATE_H_ */ + diff --git a/chromium/ppapi/c/private/ppb_pdf.h b/chromium/ppapi/c/private/ppb_pdf.h index 2e2e73b745c..fdc5748640c 100644 --- a/chromium/ppapi/c/private/ppb_pdf.h +++ b/chromium/ppapi/c/private/ppb_pdf.h @@ -156,6 +156,10 @@ struct PPB_PDF { PP_Resource (*GetResourceImageForScale)(PP_Instance instance, PP_ResourceImage image_id, float scale); + + // Invoke password dialog for plugin. + struct PP_Var (*ModalPromptForPassword)(PP_Instance instance, + struct PP_Var message); }; #endif // PPAPI_C_PRIVATE_PPB_PDF_H_ diff --git a/chromium/ppapi/c/private/ppb_platform_verification_private.h b/chromium/ppapi/c/private/ppb_platform_verification_private.h new file mode 100644 index 00000000000..b16d074cfae --- /dev/null +++ b/chromium/ppapi/c/private/ppb_platform_verification_private.h @@ -0,0 +1,128 @@ +/* Copyright 2013 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. + */ + +/* From private/ppb_platform_verification_private.idl, + * modified Thu Sep 12 11:48:28 2013. + */ + +#ifndef PPAPI_C_PRIVATE_PPB_PLATFORM_VERIFICATION_PRIVATE_H_ +#define PPAPI_C_PRIVATE_PPB_PLATFORM_VERIFICATION_PRIVATE_H_ + +#include "ppapi/c/pp_bool.h" +#include "ppapi/c/pp_completion_callback.h" +#include "ppapi/c/pp_instance.h" +#include "ppapi/c/pp_macros.h" +#include "ppapi/c/pp_resource.h" +#include "ppapi/c/pp_stdint.h" +#include "ppapi/c/pp_var.h" + +#define PPB_PLATFORMVERIFICATION_PRIVATE_INTERFACE_0_1 \ + "PPB_PlatformVerification_Private;0.1" +#define PPB_PLATFORMVERIFICATION_PRIVATE_INTERFACE \ + PPB_PLATFORMVERIFICATION_PRIVATE_INTERFACE_0_1 + +/** + * @file + * This file defines the API for platform verification. Currently, it only + * supports Chrome OS. + */ + + +/** + * @addtogroup Interfaces + * @{ + */ +/** + * The <code>PPB_PlatformVerification_Private</code> interface allows authorized + * services to verify that the underlying platform is trusted. An example of a + * trusted platform is a Chrome OS device in verified boot mode. + */ +struct PPB_PlatformVerification_Private_0_1 { + /** + * Create() creates a <code>PPB_PlatformVerification_Private</code> object. + * + * @pram[in] instance A <code>PP_Instance</code> identifying one instance of + * a module. + * + * @return A <code>PP_Resource</code> corresponding to a + * <code>PPB_PlatformVerification_Private</code> if successful, 0 if creation + * failed. + */ + PP_Resource (*Create)(PP_Instance instance); + /** + * IsPlatformVerification() determines if the provided resource is a + * <code>PPB_PlatformVerification_Private</code>. + * + * @param[in] resource A <code>PP_Resource</code> corresponding to a + * <code>PPB_PlatformVerification_Private</code>. + * + * @return <code>PP_TRUE</code> if the resource is a + * <code>PPB_PlatformVerification_Private</code>, <code>PP_FALSE</code> if the + * resource is invalid or some type other than + * <code>PPB_PlatformVerification_Private</code>. + */ + PP_Bool (*IsPlatformVerification)(PP_Resource resource); + /** + * Check if the underlying host platform can be challenged; i.e., verified as + * a trusted platform. Useful for avoiding unnecessary work on platforms + * which will always fail; i.e. dev mode Chrome OS. + * + * @param[out] can_challenge_platform A <code>PP_Bool</code> which is set to + * <code>PP_TRUE</code> if a platform challenge might pass and + * <code>PP_FALSE</code> if it definitely won't. + * + * @param[in] callback A <code>PP_CompletionCallback</code> to be called after + * the method has been completed. This callback will only run if the return + * code is <code>PP_OK_COMPLETIONPENDING</code>. + * + * @return An int32_t containing an error code from <code>pp_errors.h</code>. + */ + int32_t (*CanChallengePlatform)(PP_Resource instance, + PP_Bool* can_challenge_platform, + struct PP_CompletionCallback callback); + /** + * Requests a platform challenge for a given service id. + * + * @param[in] service_id A <code>PP_Var</code> of type + * <code>PP_VARTYPE_STRING</code> containing the service_id for the challenge. + * + * @param[in] challenge A <code>PP_Var</code> of type + * <code>PP_VARTYPE_ARRAY_BUFFER</code> that contains the challenge data. + * + * @param[out] signed_data A <code>PP_Var</code> of type + * <code>PP_VARTYPE_ARRAY_BUFFER</code> that contains the data signed by the + * platform. + * + * @param[out] signed_data_signature A <code>PP_Var</code> of type + * <code>PP_VARTYPE_ARRAY_BUFFER</code> that contains the signature of the + * signed data block. + * + * @param[out] platform_key_certificate A <code>PP_Var</code> of type + * <code>PP_VARTYPE_STRING</code> that contains the device specific + * certificate for the requested service_id. + * + * @param[in] callback A <code>PP_CompletionCallback</code> to be called after + * the platform challenge has been completed. This callback will only run if + * the return code is <code>PP_OK_COMPLETIONPENDING</code>. + * + * @return An int32_t containing an error code from <code>pp_errors.h</code>. + */ + int32_t (*ChallengePlatform)(PP_Resource instance, + struct PP_Var service_id, + struct PP_Var challenge, + struct PP_Var* signed_data, + struct PP_Var* signed_data_signature, + struct PP_Var* platform_key_certificate, + struct PP_CompletionCallback callback); +}; + +typedef struct PPB_PlatformVerification_Private_0_1 + PPB_PlatformVerification_Private; +/** + * @} + */ + +#endif /* PPAPI_C_PRIVATE_PPB_PLATFORM_VERIFICATION_PRIVATE_H_ */ + diff --git a/chromium/ppapi/c/private/ppp_content_decryptor_private.h b/chromium/ppapi/c/private/ppp_content_decryptor_private.h index ff224c0c629..69763df251e 100644 --- a/chromium/ppapi/c/private/ppp_content_decryptor_private.h +++ b/chromium/ppapi/c/private/ppp_content_decryptor_private.h @@ -4,7 +4,7 @@ */ /* From private/ppp_content_decryptor_private.idl, - * modified Fri Oct 26 15:36:54 2012. + * modified Wed Sep 18 16:14:30 2013. */ #ifndef PPAPI_C_PRIVATE_PPP_CONTENT_DECRYPTOR_PRIVATE_H_ @@ -18,10 +18,10 @@ #include "ppapi/c/pp_var.h" #include "ppapi/c/private/pp_content_decryptor.h" -#define PPP_CONTENTDECRYPTOR_PRIVATE_INTERFACE_0_6 \ - "PPP_ContentDecryptor_Private;0.6" +#define PPP_CONTENTDECRYPTOR_PRIVATE_INTERFACE_0_7 \ + "PPP_ContentDecryptor_Private;0.7" #define PPP_CONTENTDECRYPTOR_PRIVATE_INTERFACE \ - PPP_CONTENTDECRYPTOR_PRIVATE_INTERFACE_0_6 + PPP_CONTENTDECRYPTOR_PRIVATE_INTERFACE_0_7 /** * @file @@ -42,7 +42,20 @@ * Decryption Module (CDM) for v0.1 of the proposed Encrypted Media Extensions: * http://goo.gl/rbdnR */ -struct PPP_ContentDecryptor_Private_0_6 { +struct PPP_ContentDecryptor_Private_0_7 { + /** + * Initialize for the specified key system. + * + * @param[in] key_system A <code>PP_Var</code> of type + * <code>PP_VARTYPE_STRING</code> containing the name of the key system. + * + * @param[in] can_challenge_platform A <code>PP_Bool</code> that + * indicates if the underlying host platform can be challenged; + * i.e., verified as a trusted platform. + */ + void (*Initialize)(PP_Instance instance, + struct PP_Var key_system, + PP_Bool can_challenge_platform); /** * Generates a key request. key_system specifies the key or licensing system * to use. type contains the MIME type of init_data. init_data is a data @@ -53,9 +66,6 @@ struct PPP_ContentDecryptor_Private_0_6 { * browser by the CDM via <code>KeyMessage()</code> on the * <code>PPB_ContentDecryptor_Private</code> interface. * - * @param[in] key_system A <code>PP_Var</code> of type - * <code>PP_VARTYPE_STRING</code> containing the name of the key system. - * * @param[in] type A <code>PP_Var</code> of type * <code>PP_VARTYPE_STRING</code> containing the MIME type for init_data. * @@ -64,7 +74,6 @@ struct PPP_ContentDecryptor_Private_0_6 { * initialization data. */ void (*GenerateKeyRequest)(PP_Instance instance, - struct PP_Var key_system, struct PP_Var type, struct PP_Var init_data); /** @@ -226,7 +235,7 @@ struct PPP_ContentDecryptor_Private_0_6 { const struct PP_EncryptedBlockInfo* encrypted_block_info); }; -typedef struct PPP_ContentDecryptor_Private_0_6 PPP_ContentDecryptor_Private; +typedef struct PPP_ContentDecryptor_Private_0_7 PPP_ContentDecryptor_Private; /** * @} */ diff --git a/chromium/ppapi/cpp/audio.cc b/chromium/ppapi/cpp/audio.cc index 89702be0072..04a3062cb18 100644 --- a/chromium/ppapi/cpp/audio.cc +++ b/chromium/ppapi/cpp/audio.cc @@ -15,13 +15,30 @@ template <> const char* interface_name<PPB_Audio_1_0>() { return PPB_AUDIO_INTERFACE_1_0; } +template <> const char* interface_name<PPB_Audio_1_1>() { + return PPB_AUDIO_INTERFACE_1_1; +} + } // namespace Audio::Audio(const InstanceHandle& instance, const AudioConfig& config, PPB_Audio_Callback callback, void* user_data) - : config_(config) { + : config_(config), + use_1_0_interface_(false) { + if (has_interface<PPB_Audio_1_1>()) { + PassRefFromConstructor(get_interface<PPB_Audio_1_1>()->Create( + instance.pp_instance(), config.pp_resource(), callback, user_data)); + } +} + +Audio::Audio(const InstanceHandle& instance, + const AudioConfig& config, + PPB_Audio_Callback_1_0 callback, + void* user_data) + : config_(config), + use_1_0_interface_(true) { if (has_interface<PPB_Audio_1_0>()) { PassRefFromConstructor(get_interface<PPB_Audio_1_0>()->Create( instance.pp_instance(), config.pp_resource(), callback, user_data)); @@ -29,13 +46,27 @@ Audio::Audio(const InstanceHandle& instance, } bool Audio::StartPlayback() { - return has_interface<PPB_Audio_1_0>() && - get_interface<PPB_Audio_1_0>()->StartPlayback(pp_resource()); + if (has_interface<PPB_Audio_1_1>() && !use_1_0_interface_) { + return PP_ToBool(get_interface<PPB_Audio_1_1>()->StartPlayback( + pp_resource())); + } + if (has_interface<PPB_Audio_1_0>()) { + return PP_ToBool(get_interface<PPB_Audio_1_0>()->StartPlayback( + pp_resource())); + } + return false; } bool Audio::StopPlayback() { - return has_interface<PPB_Audio_1_0>() && - get_interface<PPB_Audio_1_0>()->StopPlayback(pp_resource()); + if (has_interface<PPB_Audio_1_1>() && !use_1_0_interface_) { + return PP_ToBool(get_interface<PPB_Audio_1_1>()->StopPlayback( + pp_resource())); + } + if (has_interface<PPB_Audio_1_0>()) { + return PP_ToBool(get_interface<PPB_Audio_1_0>()->StopPlayback( + pp_resource())); + } + return false; } } // namespace pp diff --git a/chromium/ppapi/cpp/audio.h b/chromium/ppapi/cpp/audio.h index a07fcf58067..29a19f364f1 100644 --- a/chromium/ppapi/cpp/audio.h +++ b/chromium/ppapi/cpp/audio.h @@ -41,19 +41,30 @@ class Audio : public Resource { /// /// @param[in] instance The instance with which this resource will be /// associated. - // /// @param[in] config An <code>AudioConfig</code> containing the audio config /// resource. - // /// @param[in] callback A <code>PPB_Audio_Callback</code> callback function /// that the browser calls when it needs more samples to play. - // /// @param[in] user_data A pointer to user data used in the callback function. Audio(const InstanceHandle& instance, const AudioConfig& config, PPB_Audio_Callback callback, void* user_data); + /// A constructor that creates an Audio resource. + /// + /// @param[in] instance The instance with which this resource will be + /// associated. + /// @param[in] config An <code>AudioConfig</code> containing the audio config + /// resource. + /// @param[in] callback A <code>PPB_Audio_Callback_1_0</code> callback + /// function that the browser calls when it needs more samples to play. + /// @param[in] user_data A pointer to user data used in the callback function. + Audio(const InstanceHandle& instance, + const AudioConfig& config, + PPB_Audio_Callback_1_0 callback, + void* user_data); + /// Getter function for returning the internal <code>PPB_AudioConfig</code> /// struct. /// @@ -79,6 +90,7 @@ class Audio : public Resource { private: AudioConfig config_; + bool use_1_0_interface_; }; } // namespace pp diff --git a/chromium/ppapi/cpp/dev/url_util_dev.cc b/chromium/ppapi/cpp/dev/url_util_dev.cc index 0353883265f..5029a4576c2 100644 --- a/chromium/ppapi/cpp/dev/url_util_dev.cc +++ b/chromium/ppapi/cpp/dev/url_util_dev.cc @@ -82,4 +82,11 @@ Var URLUtil_Dev::GetPluginInstanceURL(const InstanceHandle& instance, components)); } +Var URLUtil_Dev::GetPluginReferrerURL(const InstanceHandle& instance, + PP_URLComponents_Dev* components) const { + return Var(PASS_REF, + interface_->GetPluginReferrerURL(instance.pp_instance(), + components)); +} + } // namespace pp diff --git a/chromium/ppapi/cpp/dev/url_util_dev.h b/chromium/ppapi/cpp/dev/url_util_dev.h index 6c0ecf56b12..9399752514a 100644 --- a/chromium/ppapi/cpp/dev/url_util_dev.h +++ b/chromium/ppapi/cpp/dev/url_util_dev.h @@ -41,6 +41,8 @@ class URLUtil_Dev { Var GetPluginInstanceURL(const InstanceHandle& instance, PP_URLComponents_Dev* components = NULL) const; + Var GetPluginReferrerURL(const InstanceHandle& instance, + PP_URLComponents_Dev* components = NULL) const; private: URLUtil_Dev() : interface_(NULL) {} diff --git a/chromium/ppapi/cpp/file_ref.h b/chromium/ppapi/cpp/file_ref.h index d229c5fd7ad..56828f7e642 100644 --- a/chromium/ppapi/cpp/file_ref.h +++ b/chromium/ppapi/cpp/file_ref.h @@ -48,7 +48,7 @@ class FileRef : public Resource { /// /// @param[in] file_system A <code>FileSystem</code> corresponding to a file /// system type. - /// @param[in] path A path to the file. + /// @param[in] path A path to the file. Must begin with a '/' character. FileRef(const FileSystem& file_system, const char* path); /// The copy constructor for <code>FileRef</code>. diff --git a/chromium/ppapi/cpp/network_list.cc b/chromium/ppapi/cpp/network_list.cc new file mode 100644 index 00000000000..12c3bf4c96c --- /dev/null +++ b/chromium/ppapi/cpp/network_list.cc @@ -0,0 +1,94 @@ +// Copyright (c) 2012 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "ppapi/cpp/network_list.h" + +#include "ppapi/c/pp_errors.h" +#include "ppapi/cpp/array_output.h" +#include "ppapi/cpp/logging.h" +#include "ppapi/cpp/module_impl.h" +#include "ppapi/cpp/net_address.h" +#include "ppapi/cpp/var.h" + +namespace pp { + +namespace { + +template <> const char* interface_name<PPB_NetworkList_1_0>() { + return PPB_NETWORKLIST_INTERFACE_1_0; +} + +} // namespace + +NetworkList::NetworkList() { +} + +NetworkList::NetworkList(PassRef, PP_Resource resource) + : Resource(PASS_REF, resource) { +} + +// static +bool NetworkList::IsAvailable() { + return has_interface<PPB_NetworkList_1_0>(); +} + +uint32_t NetworkList::GetCount() const { + if (!has_interface<PPB_NetworkList_1_0>()) + return 0; + return get_interface<PPB_NetworkList_1_0>()->GetCount(pp_resource()); +} + +std::string NetworkList::GetName(uint32_t index) const { + if (!has_interface<PPB_NetworkList_1_0>()) + return std::string(); + Var result(PASS_REF, + get_interface<PPB_NetworkList_1_0>()->GetName( + pp_resource(), index)); + return result.is_string() ? result.AsString() : std::string(); +} + +PP_NetworkList_Type NetworkList::GetType(uint32_t index) const { + if (!has_interface<PPB_NetworkList_1_0>()) + return PP_NETWORKLIST_TYPE_ETHERNET; + return get_interface<PPB_NetworkList_1_0>()->GetType( + pp_resource(), index); +} + +PP_NetworkList_State NetworkList::GetState(uint32_t index) const { + if (!has_interface<PPB_NetworkList_1_0>()) + return PP_NETWORKLIST_STATE_DOWN; + return get_interface<PPB_NetworkList_1_0>()->GetState( + pp_resource(), index); +} + +int32_t NetworkList::GetIpAddresses( + uint32_t index, + std::vector<NetAddress>* addresses) const { + if (!has_interface<PPB_NetworkList_1_0>()) + return PP_ERROR_NOINTERFACE; + if (!addresses) + return PP_ERROR_BADARGUMENT; + + ResourceArrayOutputAdapter<NetAddress> adapter(addresses); + return get_interface<PPB_NetworkList_1_0>()->GetIpAddresses( + pp_resource(), index, adapter.pp_array_output()); +} + +std::string NetworkList::GetDisplayName(uint32_t index) const { + if (!has_interface<PPB_NetworkList_1_0>()) + return std::string(); + Var result(PASS_REF, + get_interface<PPB_NetworkList_1_0>()->GetDisplayName( + pp_resource(), index)); + return result.is_string() ? result.AsString() : std::string(); +} + +uint32_t NetworkList::GetMTU(uint32_t index) const { + if (!has_interface<PPB_NetworkList_1_0>()) + return 0; + return get_interface<PPB_NetworkList_1_0>()->GetMTU( + pp_resource(), index); +} + +} // namespace pp diff --git a/chromium/ppapi/cpp/private/network_list_private.h b/chromium/ppapi/cpp/network_list.h index 31cd9b598b8..d479129442e 100644 --- a/chromium/ppapi/cpp/private/network_list_private.h +++ b/chromium/ppapi/cpp/network_list.h @@ -2,22 +2,24 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#ifndef PPAPI_CPP_PRIVATE_NETWORK_LIST_PRIVATE_H_ -#define PPAPI_CPP_PRIVATE_NETWORK_LIST_PRIVATE_H_ +#ifndef PPAPI_CPP_NETWORK_LIST_H_ +#define PPAPI_CPP_NETWORK_LIST_H_ #include <string> #include <vector> -#include "ppapi/c/private/ppb_network_list_private.h" +#include "ppapi/c/ppb_network_list.h" #include "ppapi/cpp/pass_ref.h" #include "ppapi/cpp/resource.h" namespace pp { -class NetworkListPrivate : public Resource { +class NetAddress; + +class NetworkList : public Resource { public: - NetworkListPrivate(); - NetworkListPrivate(PassRef, PP_Resource resource); + NetworkList(); + NetworkList(PassRef, PP_Resource resource); /// Returns true if the required interface is available. static bool IsAvailable(); @@ -32,17 +34,17 @@ class NetworkListPrivate : public Resource { /// @return Returns the type of the network interface with the /// specified <code>index</code>. - PP_NetworkListType_Private GetType(uint32_t index) const; + PP_NetworkList_Type GetType(uint32_t index) const; /// @return Returns the current state of the network interface with /// the specified <code>index</code>. - PP_NetworkListState_Private GetState(uint32_t index) const; + PP_NetworkList_State GetState(uint32_t index) const; /// Gets the list of IP addresses for the network interface with the /// specified <code>index</code> and stores them in /// <code>addresses</code>. - void GetIpAddresses(uint32_t index, - std::vector<PP_NetAddress_Private>* addresses) const; + int32_t GetIpAddresses(uint32_t index, + std::vector<NetAddress>* addresses) const; /// @return Returns the display name for the network interface with /// the specified <code>index</code>. @@ -55,4 +57,4 @@ class NetworkListPrivate : public Resource { } // namespace pp -#endif // PPAPI_CPP_PRIVATE_NETWORK_LIST_PRIVATE_H_ +#endif // PPAPI_CPP_NETWORK_LIST_H_ diff --git a/chromium/ppapi/cpp/network_monitor.cc b/chromium/ppapi/cpp/network_monitor.cc new file mode 100644 index 00000000000..b721e965dca --- /dev/null +++ b/chromium/ppapi/cpp/network_monitor.cc @@ -0,0 +1,44 @@ +// Copyright (c) 2012 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "ppapi/cpp/network_monitor.h" + +#include "ppapi/c/ppb_network_monitor.h" +#include "ppapi/cpp/completion_callback.h" +#include "ppapi/cpp/instance.h" +#include "ppapi/cpp/module_impl.h" +#include "ppapi/cpp/network_list.h" + +namespace pp { + +namespace { + +template <> const char* interface_name<PPB_NetworkMonitor_1_0>() { + return PPB_NETWORKMONITOR_INTERFACE_1_0; +} + +} // namespace + +NetworkMonitor::NetworkMonitor(const InstanceHandle& instance) { + if (has_interface<PPB_NetworkMonitor_1_0>()) { + PassRefFromConstructor(get_interface<PPB_NetworkMonitor_1_0>()->Create( + instance.pp_instance())); + } +} + +int32_t NetworkMonitor::UpdateNetworkList( + const CompletionCallbackWithOutput<NetworkList>& callback) { + if (has_interface<PPB_NetworkMonitor_1_0>()) { + return get_interface<PPB_NetworkMonitor_1_0>()->UpdateNetworkList( + pp_resource(), callback.output(), callback.pp_completion_callback()); + } + return callback.MayForce(PP_ERROR_NOINTERFACE); +} + +// static +bool NetworkMonitor::IsAvailable() { + return has_interface<PPB_NetworkMonitor_1_0>(); +} + +} // namespace pp diff --git a/chromium/ppapi/cpp/network_monitor.h b/chromium/ppapi/cpp/network_monitor.h new file mode 100644 index 00000000000..bce731d90d2 --- /dev/null +++ b/chromium/ppapi/cpp/network_monitor.h @@ -0,0 +1,31 @@ +// Copyright (c) 2012 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef PPAPI_CPP_NETWORK_MONITOR_H_ +#define PPAPI_CPP_NETWORK_MONITOR_H_ + +#include "ppapi/cpp/instance_handle.h" +#include "ppapi/cpp/resource.h" + +namespace pp { + +class Instance; +class NetworkList; + +template <typename T> class CompletionCallbackWithOutput; + +class NetworkMonitor : public Resource { + public: + explicit NetworkMonitor(const InstanceHandle& instance); + + int32_t UpdateNetworkList( + const CompletionCallbackWithOutput<NetworkList>& callback); + + // Returns true if the required interface is available. + static bool IsAvailable(); +}; + +} // namespace pp + +#endif // PPAPI_CPP_NETWORK_MONITOR_H_ diff --git a/chromium/ppapi/cpp/output_traits.h b/chromium/ppapi/cpp/output_traits.h index 37a8a656e12..31cdbbe1122 100644 --- a/chromium/ppapi/cpp/output_traits.h +++ b/chromium/ppapi/cpp/output_traits.h @@ -161,6 +161,29 @@ struct CallbackOutputTraits<Var> { } }; +// A specialization of CallbackOutputTraits for bool output parameters. +// It passes a PP_Bool* to the browser and converts to a bool when passing +// to the plugin. +template<> +struct CallbackOutputTraits<bool> { + // To call the browser, we just pass a PP_Bool* as an output param. + typedef PP_Bool* APIArgType; + typedef PP_Bool StorageType; + + static inline APIArgType StorageToAPIArg(StorageType& t) { + return &t; + } + + // Converts the PP_Bool to a bool object. + static inline bool StorageToPluginArg(StorageType& t) { + return PP_ToBool(t); + } + + static inline void Initialize(StorageType* t) { + *t = PP_FALSE; + } +}; + // Array output parameters ----------------------------------------------------- // Output traits for vectors of all "plain old data" (POD) types. It is diff --git a/chromium/ppapi/cpp/private/content_decryptor_private.cc b/chromium/ppapi/cpp/private/content_decryptor_private.cc index 48690946128..23417c3e155 100644 --- a/chromium/ppapi/cpp/private/content_decryptor_private.cc +++ b/chromium/ppapi/cpp/private/content_decryptor_private.cc @@ -23,10 +23,9 @@ namespace { static const char kPPPContentDecryptorInterface[] = PPP_CONTENTDECRYPTOR_PRIVATE_INTERFACE; -void GenerateKeyRequest(PP_Instance instance, - PP_Var key_system_arg, - PP_Var type_arg, - PP_Var init_data_arg) { +void Initialize(PP_Instance instance, + PP_Var key_system_arg, + PP_Bool can_challenge_platform) { void* object = Instance::GetPerInstanceObject(instance, kPPPContentDecryptorInterface); if (!object) @@ -36,6 +35,19 @@ void GenerateKeyRequest(PP_Instance instance, if (!key_system_var.is_string()) return; + static_cast<ContentDecryptor_Private*>(object)->Initialize( + key_system_var.AsString(), + PP_ToBool(can_challenge_platform)); +} + +void GenerateKeyRequest(PP_Instance instance, + PP_Var type_arg, + PP_Var init_data_arg) { + void* object = + Instance::GetPerInstanceObject(instance, kPPPContentDecryptorInterface); + if (!object) + return; + pp::Var type_var(pp::PASS_REF, type_arg); if (!type_var.is_string()) return; @@ -46,7 +58,6 @@ void GenerateKeyRequest(PP_Instance instance, pp::VarArrayBuffer init_data_array_buffer(init_data_var); static_cast<ContentDecryptor_Private*>(object)->GenerateKeyRequest( - key_system_var.AsString(), type_var.AsString(), init_data_array_buffer); } @@ -184,6 +195,7 @@ void DecryptAndDecode(PP_Instance instance, } const PPP_ContentDecryptor_Private ppp_content_decryptor = { + &Initialize, &GenerateKeyRequest, &AddKey, &CancelKeyRequest, @@ -214,22 +226,6 @@ ContentDecryptor_Private::~ContentDecryptor_Private() { this); } -void ContentDecryptor_Private::NeedKey(const std::string& key_system, - const std::string& session_id, - pp::VarArrayBuffer init_data) { - // session_id can be empty here. - if (has_interface<PPB_ContentDecryptor_Private>()) { - pp::Var key_system_var(key_system); - pp::Var session_id_var(session_id); - - get_interface<PPB_ContentDecryptor_Private>()->NeedKey( - associated_instance_.pp_instance(), - key_system_var.pp_var(), - session_id_var.pp_var(), - init_data.pp_var()); - } -} - void ContentDecryptor_Private::KeyAdded(const std::string& key_system, const std::string& session_id) { if (has_interface<PPB_ContentDecryptor_Private>()) { diff --git a/chromium/ppapi/cpp/private/content_decryptor_private.h b/chromium/ppapi/cpp/private/content_decryptor_private.h index 477c6de5c25..a43a74cfb83 100644 --- a/chromium/ppapi/cpp/private/content_decryptor_private.h +++ b/chromium/ppapi/cpp/private/content_decryptor_private.h @@ -31,8 +31,9 @@ class ContentDecryptor_Private { // TODO(tomfinegan): This could be optimized to pass pp::Var instead of // strings. The change would allow the CDM wrapper to reuse vars when // replying to the browser. - virtual void GenerateKeyRequest(const std::string& key_system, - const std::string& type, + virtual void Initialize(const std::string& key_system, + bool can_challenge_platform) = 0; + virtual void GenerateKeyRequest(const std::string& type, pp::VarArrayBuffer init_data) = 0; virtual void AddKey(const std::string& session_id, pp::VarArrayBuffer key, @@ -58,9 +59,6 @@ class ContentDecryptor_Private { // PPB_ContentDecryptor_Private methods for passing data from the decryptor // to the browser. - void NeedKey(const std::string& key_system, - const std::string& session_id, - pp::VarArrayBuffer init_data); void KeyAdded(const std::string& key_system, const std::string& session_id); void KeyMessage(const std::string& key_system, diff --git a/chromium/ppapi/cpp/private/network_list_private.cc b/chromium/ppapi/cpp/private/network_list_private.cc deleted file mode 100644 index 1297aa3a09c..00000000000 --- a/chromium/ppapi/cpp/private/network_list_private.cc +++ /dev/null @@ -1,110 +0,0 @@ -// Copyright (c) 2012 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#include "ppapi/cpp/private/network_list_private.h" - -#include "ppapi/cpp/module_impl.h" -#include "ppapi/cpp/var.h" - -namespace pp { - -namespace { - -template <> const char* interface_name<PPB_NetworkList_Private>() { - return PPB_NETWORKLIST_PRIVATE_INTERFACE; -} - -} // namespace - -NetworkListPrivate::NetworkListPrivate() { -} - -NetworkListPrivate::NetworkListPrivate(PassRef, PP_Resource resource) - : Resource(PASS_REF, resource) { -} - -// static -bool NetworkListPrivate::IsAvailable() { - return has_interface<PPB_NetworkList_Private>(); -} - -uint32_t NetworkListPrivate::GetCount() const { - if (!has_interface<PPB_NetworkList_Private>()) - return 0; - return get_interface<PPB_NetworkList_Private>()->GetCount(pp_resource()); -} - -std::string NetworkListPrivate::GetName(uint32_t index) const { - if (!has_interface<PPB_NetworkList_Private>()) - return std::string(); - Var result(PASS_REF, - get_interface<PPB_NetworkList_Private>()->GetName( - pp_resource(), index)); - return result.is_string() ? result.AsString() : std::string(); -} - -PP_NetworkListType_Private NetworkListPrivate::GetType(uint32_t index) const { - if (!has_interface<PPB_NetworkList_Private>()) - return PP_NETWORKLIST_ETHERNET; - return get_interface<PPB_NetworkList_Private>()->GetType( - pp_resource(), index); -} - -PP_NetworkListState_Private NetworkListPrivate::GetState(uint32_t index) const { - if (!has_interface<PPB_NetworkList_Private>()) - return PP_NETWORKLIST_DOWN; - return get_interface<PPB_NetworkList_Private>()->GetState( - pp_resource(), index); -} - -void NetworkListPrivate::GetIpAddresses( - uint32_t index, - std::vector<PP_NetAddress_Private>* addresses) const { - if (!has_interface<PPB_NetworkList_Private>()) - return; - - // Most network interfaces don't have more than 3 network - // interfaces. - addresses->resize(3); - - int32_t result = get_interface<PPB_NetworkList_Private>()->GetIpAddresses( - pp_resource(), index, &addresses->front(), addresses->size()); - - if (result < 0) { - addresses->resize(0); - return; - } - - if (result <= static_cast<int32_t>(addresses->size())) { - addresses->resize(result); - return; - } - - addresses->resize(result); - result = get_interface<PPB_NetworkList_Private>()->GetIpAddresses( - pp_resource(), index, &addresses->front(), addresses->size()); - if (result < 0) { - addresses->resize(0); - } else if (result < static_cast<int32_t>(addresses->size())) { - addresses->resize(result); - } -} - -std::string NetworkListPrivate::GetDisplayName(uint32_t index) const { - if (!has_interface<PPB_NetworkList_Private>()) - return std::string(); - Var result(PASS_REF, - get_interface<PPB_NetworkList_Private>()->GetDisplayName( - pp_resource(), index)); - return result.is_string() ? result.AsString() : std::string(); -} - -uint32_t NetworkListPrivate::GetMTU(uint32_t index) const { - if (!has_interface<PPB_NetworkList_Private>()) - return 0; - return get_interface<PPB_NetworkList_Private>()->GetMTU( - pp_resource(), index); -} - -} // namespace pp diff --git a/chromium/ppapi/cpp/private/network_monitor_private.cc b/chromium/ppapi/cpp/private/network_monitor_private.cc deleted file mode 100644 index 2f931ea4288..00000000000 --- a/chromium/ppapi/cpp/private/network_monitor_private.cc +++ /dev/null @@ -1,35 +0,0 @@ -// Copyright (c) 2012 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#include "ppapi/cpp/private/network_monitor_private.h" - -#include "ppapi/cpp/instance.h" -#include "ppapi/cpp/module_impl.h" - -namespace pp { - -namespace { - -template <> const char* interface_name<PPB_NetworkMonitor_Private>() { - return PPB_NETWORKMONITOR_PRIVATE_INTERFACE; -} - -} // namespace - -NetworkMonitorPrivate::NetworkMonitorPrivate( - const InstanceHandle& instance, - PPB_NetworkMonitor_Callback callback, - void* user_data) { - if (has_interface<PPB_NetworkMonitor_Private>()) { - PassRefFromConstructor(get_interface<PPB_NetworkMonitor_Private>()->Create( - instance.pp_instance(), callback, user_data)); - } -} - -// static -bool NetworkMonitorPrivate::IsAvailable() { - return has_interface<PPB_NetworkMonitor_Private>(); -} - -} // namespace pp diff --git a/chromium/ppapi/cpp/private/network_monitor_private.h b/chromium/ppapi/cpp/private/network_monitor_private.h deleted file mode 100644 index 693bbcdc7fb..00000000000 --- a/chromium/ppapi/cpp/private/network_monitor_private.h +++ /dev/null @@ -1,28 +0,0 @@ -// Copyright (c) 2012 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#ifndef PPAPI_CPP_PRIVATE_NETWORK_MONITOR_PRIVATE_H_ -#define PPAPI_CPP_PRIVATE_NETWORK_MONITOR_PRIVATE_H_ - -#include "ppapi/c/private/ppb_network_monitor_private.h" -#include "ppapi/cpp/resource.h" -#include "ppapi/cpp/instance_handle.h" - -namespace pp { - -class Instance; - -class NetworkMonitorPrivate : public Resource { - public: - NetworkMonitorPrivate(const InstanceHandle& instance, - PPB_NetworkMonitor_Callback callback, - void* user_data); - - // Returns true if the required interface is available. - static bool IsAvailable(); -}; - -} // namespace pp - -#endif // PPAPI_CPP_PRIVATE_NETWORK_MONITOR_PRIVATE_H_ diff --git a/chromium/ppapi/cpp/private/pdf.cc b/chromium/ppapi/cpp/private/pdf.cc index 753613c18a3..9d6bd898251 100644 --- a/chromium/ppapi/cpp/private/pdf.cc +++ b/chromium/ppapi/cpp/private/pdf.cc @@ -184,4 +184,14 @@ ImageData PDF::GetResourceImageForScale(const InstanceHandle& instance, return ImageData(); } +Var PDF::ModalPromptForPassword(const InstanceHandle& instance, + Var message) { + if (has_interface<PPB_PDF>()) { + return Var(PASS_REF, + get_interface<PPB_PDF>()->ModalPromptForPassword( + instance.pp_instance(), + message.pp_var())); + } + return Var(); +} } // namespace pp diff --git a/chromium/ppapi/cpp/private/pdf.h b/chromium/ppapi/cpp/private/pdf.h index 893f9e3f279..1e89dd0c7ed 100644 --- a/chromium/ppapi/cpp/private/pdf.h +++ b/chromium/ppapi/cpp/private/pdf.h @@ -62,6 +62,8 @@ class PDF { static ImageData GetResourceImageForScale(const InstanceHandle& instance, PP_ResourceImage image_id, float scale); + static Var ModalPromptForPassword(const InstanceHandle& instance, + Var message); }; } // namespace pp diff --git a/chromium/ppapi/cpp/private/platform_verification.cc b/chromium/ppapi/cpp/private/platform_verification.cc new file mode 100644 index 00000000000..f9085700696 --- /dev/null +++ b/chromium/ppapi/cpp/private/platform_verification.cc @@ -0,0 +1,66 @@ +// Copyright 2013 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/cpp/private/platform_verification.h" + +#include "ppapi/c/pp_bool.h" +#include "ppapi/c/pp_errors.h" +#include "ppapi/c/private/ppb_platform_verification_private.h" +#include "ppapi/cpp/instance_handle.h" +#include "ppapi/cpp/module_impl.h" +#include "ppapi/cpp/var.h" + +namespace pp { + +namespace { + +template <> const char* interface_name<PPB_PlatformVerification_Private_0_1>() { + return PPB_PLATFORMVERIFICATION_PRIVATE_INTERFACE_0_1; +} + +inline bool HasInterface() { + return has_interface<PPB_PlatformVerification_Private_0_1>(); +} + +inline const PPB_PlatformVerification_Private_0_1* GetInterface() { + return get_interface<PPB_PlatformVerification_Private_0_1>(); +} + +} // namespace + +PlatformVerification::PlatformVerification(const InstanceHandle& instance) { + if (HasInterface()) + PassRefFromConstructor(GetInterface()->Create(instance.pp_instance())); +} + +PlatformVerification::~PlatformVerification() {} + +int32_t PlatformVerification::CanChallengePlatform( + const CompletionCallbackWithOutput<bool>& callback) { + if (!HasInterface()) + return callback.MayForce(PP_ERROR_NOINTERFACE); + + return GetInterface()->CanChallengePlatform( + pp_resource(), callback.output(), callback.pp_completion_callback()); +} + +int32_t PlatformVerification::ChallengePlatform( + const Var& service_id, + const Var& challenge, + Var* signed_data, + Var* signed_data_signature, + Var* platform_key_certificate, + const CompletionCallback& callback) { + if (!HasInterface()) + return callback.MayForce(PP_ERROR_NOINTERFACE); + + return GetInterface()->ChallengePlatform( + pp_resource(), service_id.pp_var(), challenge.pp_var(), + const_cast<PP_Var*>(&signed_data->pp_var()), + const_cast<PP_Var*>(&signed_data_signature->pp_var()), + const_cast<PP_Var*>(&platform_key_certificate->pp_var()), + callback.pp_completion_callback()); +} + +} // namespace pp diff --git a/chromium/ppapi/cpp/private/platform_verification.h b/chromium/ppapi/cpp/private/platform_verification.h new file mode 100644 index 00000000000..7f0f8a197ff --- /dev/null +++ b/chromium/ppapi/cpp/private/platform_verification.h @@ -0,0 +1,33 @@ +// Copyright 2013 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_CPP_PRIVATE_PLATFORM_VERIFICATION_H_ +#define PPAPI_CPP_PRIVATE_PLATFORM_VERIFICATION_H_ + +#include "ppapi/cpp/completion_callback.h" +#include "ppapi/cpp/resource.h" + +namespace pp { + +class InstanceHandle; +class Var; + +class PlatformVerification : public Resource { + public: + explicit PlatformVerification(const InstanceHandle& instance); + virtual ~PlatformVerification(); + + int32_t CanChallengePlatform( + const CompletionCallbackWithOutput<bool>& callback); + int32_t ChallengePlatform(const Var& service_id, + const Var& challenge, + Var* signed_data, + Var* signed_data_signature, + Var* platform_key_certificate, + const CompletionCallback& callback); +}; + +} // namespace pp + +#endif // PPAPI_CPP_PRIVATE_PLATFORM_VERIFICATION_H_ diff --git a/chromium/ppapi/cpp/tcp_socket.cc b/chromium/ppapi/cpp/tcp_socket.cc index f0002fa5545..ab08ff3626c 100644 --- a/chromium/ppapi/cpp/tcp_socket.cc +++ b/chromium/ppapi/cpp/tcp_socket.cc @@ -17,13 +17,20 @@ template <> const char* interface_name<PPB_TCPSocket_1_0>() { return PPB_TCPSOCKET_INTERFACE_1_0; } +template <> const char* interface_name<PPB_TCPSocket_1_1>() { + return PPB_TCPSOCKET_INTERFACE_1_1; +} + } // namespace TCPSocket::TCPSocket() { } TCPSocket::TCPSocket(const InstanceHandle& instance) { - if (has_interface<PPB_TCPSocket_1_0>()) { + if (has_interface<PPB_TCPSocket_1_1>()) { + PassRefFromConstructor(get_interface<PPB_TCPSocket_1_1>()->Create( + instance.pp_instance())); + } else if (has_interface<PPB_TCPSocket_1_0>()) { PassRefFromConstructor(get_interface<PPB_TCPSocket_1_0>()->Create( instance.pp_instance())); } @@ -46,11 +53,25 @@ TCPSocket& TCPSocket::operator=(const TCPSocket& other) { // static bool TCPSocket::IsAvailable() { - return has_interface<PPB_TCPSocket_1_0>(); + return has_interface<PPB_TCPSocket_1_1>() || + has_interface<PPB_TCPSocket_1_0>(); +} + +int32_t TCPSocket::Bind(const NetAddress& addr, + const CompletionCallback& callback) { + if (has_interface<PPB_TCPSocket_1_1>()) { + return get_interface<PPB_TCPSocket_1_1>()->Bind( + pp_resource(), addr.pp_resource(), callback.pp_completion_callback()); + } + return callback.MayForce(PP_ERROR_NOINTERFACE); } int32_t TCPSocket::Connect(const NetAddress& addr, const CompletionCallback& callback) { + if (has_interface<PPB_TCPSocket_1_1>()) { + return get_interface<PPB_TCPSocket_1_1>()->Connect( + pp_resource(), addr.pp_resource(), callback.pp_completion_callback()); + } if (has_interface<PPB_TCPSocket_1_0>()) { return get_interface<PPB_TCPSocket_1_0>()->Connect( pp_resource(), addr.pp_resource(), callback.pp_completion_callback()); @@ -59,6 +80,11 @@ int32_t TCPSocket::Connect(const NetAddress& addr, } NetAddress TCPSocket::GetLocalAddress() const { + if (has_interface<PPB_TCPSocket_1_1>()) { + return NetAddress( + PASS_REF, + get_interface<PPB_TCPSocket_1_1>()->GetLocalAddress(pp_resource())); + } if (has_interface<PPB_TCPSocket_1_0>()) { return NetAddress( PASS_REF, @@ -68,6 +94,11 @@ NetAddress TCPSocket::GetLocalAddress() const { } NetAddress TCPSocket::GetRemoteAddress() const { + if (has_interface<PPB_TCPSocket_1_1>()) { + return NetAddress( + PASS_REF, + get_interface<PPB_TCPSocket_1_1>()->GetRemoteAddress(pp_resource())); + } if (has_interface<PPB_TCPSocket_1_0>()) { return NetAddress( PASS_REF, @@ -79,6 +110,11 @@ NetAddress TCPSocket::GetRemoteAddress() const { int32_t TCPSocket::Read(char* buffer, int32_t bytes_to_read, const CompletionCallback& callback) { + if (has_interface<PPB_TCPSocket_1_1>()) { + return get_interface<PPB_TCPSocket_1_1>()->Read( + pp_resource(), buffer, bytes_to_read, + callback.pp_completion_callback()); + } if (has_interface<PPB_TCPSocket_1_0>()) { return get_interface<PPB_TCPSocket_1_0>()->Read( pp_resource(), buffer, bytes_to_read, @@ -90,6 +126,11 @@ int32_t TCPSocket::Read(char* buffer, int32_t TCPSocket::Write(const char* buffer, int32_t bytes_to_write, const CompletionCallback& callback) { + if (has_interface<PPB_TCPSocket_1_1>()) { + return get_interface<PPB_TCPSocket_1_1>()->Write( + pp_resource(), buffer, bytes_to_write, + callback.pp_completion_callback()); + } if (has_interface<PPB_TCPSocket_1_0>()) { return get_interface<PPB_TCPSocket_1_0>()->Write( pp_resource(), buffer, bytes_to_write, @@ -98,14 +139,39 @@ int32_t TCPSocket::Write(const char* buffer, return callback.MayForce(PP_ERROR_NOINTERFACE); } +int32_t TCPSocket::Listen(int32_t backlog, + const CompletionCallback& callback) { + if (has_interface<PPB_TCPSocket_1_1>()) { + return get_interface<PPB_TCPSocket_1_1>()->Listen( + pp_resource(), backlog, callback.pp_completion_callback()); + } + return callback.MayForce(PP_ERROR_NOINTERFACE); +} + +int32_t TCPSocket::Accept( + const CompletionCallbackWithOutput<TCPSocket>& callback) { + if (has_interface<PPB_TCPSocket_1_1>()) { + return get_interface<PPB_TCPSocket_1_1>()->Accept( + pp_resource(), callback.output(), callback.pp_completion_callback()); + } + return callback.MayForce(PP_ERROR_NOINTERFACE); +} + void TCPSocket::Close() { - if (has_interface<PPB_TCPSocket_1_0>()) + if (has_interface<PPB_TCPSocket_1_1>()) { + get_interface<PPB_TCPSocket_1_1>()->Close(pp_resource()); + } else if (has_interface<PPB_TCPSocket_1_0>()) { get_interface<PPB_TCPSocket_1_0>()->Close(pp_resource()); + } } int32_t TCPSocket::SetOption(PP_TCPSocket_Option name, const Var& value, const CompletionCallback& callback) { + if (has_interface<PPB_TCPSocket_1_1>()) { + return get_interface<PPB_TCPSocket_1_1>()->SetOption( + pp_resource(), name, value.pp_var(), callback.pp_completion_callback()); + } if (has_interface<PPB_TCPSocket_1_0>()) { return get_interface<PPB_TCPSocket_1_0>()->SetOption( pp_resource(), name, value.pp_var(), callback.pp_completion_callback()); diff --git a/chromium/ppapi/cpp/tcp_socket.h b/chromium/ppapi/cpp/tcp_socket.h index 5a5e0f4149e..578e08fac22 100644 --- a/chromium/ppapi/cpp/tcp_socket.h +++ b/chromium/ppapi/cpp/tcp_socket.h @@ -15,10 +15,13 @@ namespace pp { class CompletionCallback; class InstanceHandle; +template <typename T> class CompletionCallbackWithOutput; + /// The <code>TCPSocket</code> class provides TCP socket operations. /// /// Permissions: Apps permission <code>socket</code> with subrule -/// <code>tcp-connect</code> is required for <code>Connect()</code>. +/// <code>tcp-connect</code> is required for <code>Connect()</code>; subrule +/// <code>tcp-listen</code> is required for <code>Listen()</code>. /// For more details about network communication permissions, please see: /// http://developer.chrome.com/apps/app_network.html class TCPSocket : public Resource { @@ -60,7 +63,20 @@ class TCPSocket : public Resource { /// @return true if the interface is available, false otherwise. static bool IsAvailable(); - /// Connects the socket to the given address. + /// Binds the socket to the given address. The socket must not be bound. + /// + /// @param[in] addr A <code>NetAddress</code> object. + /// @param[in] callback A <code>CompletionCallback</code> to be called upon + /// completion. + /// + /// @return An int32_t containing an error code from <code>pp_errors.h</code>, + /// including (but not limited to): + /// - <code>PP_ERROR_ADDRESS_IN_USE</code>: the address is already in use. + /// - <code>PP_ERROR_ADDRESS_INVALID</code>: the address is invalid. + int32_t Bind(const NetAddress& addr, const CompletionCallback& callback); + + /// Connects the socket to the given address. The socket must not be + /// listening. Binding the socket beforehand is optional. /// /// @param[in] addr A <code>NetAddress</code> object. /// @param[in] callback A <code>CompletionCallback</code> to be called upon @@ -77,10 +93,14 @@ class TCPSocket : public Resource { /// - <code>PP_ERROR_CONNECTION_FAILED</code>: the connection attempt failed. /// - <code>PP_ERROR_CONNECTION_TIMEDOUT</code>: the connection attempt timed /// out. - int32_t Connect(const NetAddress& addr, - const CompletionCallback& callback); + /// + /// Since version 1.1, if the socket is listening/connected or has a pending + /// listen/connect request, <code>Connect()</code> will fail without starting + /// a connection attempt. Otherwise, any failure during the connection attempt + /// will cause the socket to be closed. + int32_t Connect(const NetAddress& addr, const CompletionCallback& callback); - /// Gets the local address of the socket, if it is connected. + /// Gets the local address of the socket, if it is bound. /// /// @return A <code>NetAddress</code> object. The object will be null /// (i.e., is_null() returns true) on failure. @@ -135,11 +155,38 @@ class TCPSocket : public Resource { int32_t bytes_to_write, const CompletionCallback& callback); - /// Cancels all pending reads and writes and disconnects the socket. Any - /// pending callbacks will still run, reporting <code>PP_ERROR_ABORTED</code> - /// if pending IO was interrupted. After a call to this method, no output - /// buffer pointers passed into previous <code>Read()</code> calls will be - /// accessed. It is not valid to call <code>Connect()</code> again. + /// Starts listening. The socket must be bound and not connected. + /// + /// @param[in] backlog A hint to determine the maximum length to which the + /// queue of pending connections may grow. + /// @param[in] callback A <code>CompletionCallback</code> to be called upon + /// completion. + /// + /// @return An int32_t containing an error code from <code>pp_errors.h</code>, + /// including (but not limited to): + /// - <code>PP_ERROR_NOACCESS</code>: the caller doesn't have required + /// permissions. + /// - <code>PP_ERROR_ADDRESS_IN_USE</code>: Another socket is already + /// listening on the same port. + int32_t Listen(int32_t backlog, + const CompletionCallback& callback); + + /// Accepts a connection. The socket must be listening. + /// + /// @param[in] callback A <code>CompletionCallbackWithOutput</code> to be + /// called upon completion. + /// + /// @return An int32_t containing an error code from <code>pp_errors.h</code>, + /// including (but not limited to): + /// - <code>PP_ERROR_CONNECTION_ABORTED</code>: A connection has been aborted. + int32_t Accept(const CompletionCallbackWithOutput<TCPSocket>& callback); + + /// Cancels all pending operations and closes the socket. Any pending + /// callbacks will still run, reporting <code>PP_ERROR_ABORTED</code> if + /// pending IO was interrupted. After a call to this method, no output buffer + /// pointers passed into previous <code>Read()</code> or <code>Accept()</code> + /// calls will be accessed. It is not valid to call <code>Connect()</code> or + /// <code>Listen()</code> again. /// /// The socket is implicitly closed if it is destroyed, so you are not /// required to call this method. @@ -155,7 +202,6 @@ class TCPSocket : public Resource { /// completion. /// /// @return An int32_t containing an error code from <code>pp_errors.h</code>. - //// int32_t SetOption(PP_TCPSocket_Option name, const Var& value, const CompletionCallback& callback); diff --git a/chromium/ppapi/examples/ime/ime.cc b/chromium/ppapi/examples/ime/ime.cc index e7307868476..0f3e41edcf2 100644 --- a/chromium/ppapi/examples/ime/ime.cc +++ b/chromium/ppapi/examples/ime/ime.cc @@ -21,7 +21,7 @@ namespace { -// Extracted from: ui/base/keycodes/keyboard_codes.h +// Extracted from: ui/events/keycodes/keyboard_codes.h enum { VKEY_BACK = 0x08, VKEY_SHIFT = 0x10, @@ -128,7 +128,8 @@ class MyTextField { area_(x, y, width, height), font_size_(height - 2), caret_pos_(std::string::npos), - anchor_pos_(std::string::npos) { + anchor_pos_(std::string::npos), + target_segment_(0) { pp::FontDescription_Dev desc; desc.set_family(PP_FONTFAMILY_SANSSERIF); desc.set_size(font_size_); diff --git a/chromium/ppapi/examples/video_decode/video_decode.cc b/chromium/ppapi/examples/video_decode/video_decode.cc index e6bcff82f19..d1f7181dedf 100644 --- a/chromium/ppapi/examples/video_decode/video_decode.cc +++ b/chromium/ppapi/examples/video_decode/video_decode.cc @@ -221,6 +221,7 @@ VideoDecodeDemoInstance::VideoDecodeDemoInstance(PP_Instance instance, pp::Module* module) : pp::Instance(instance), pp::Graphics3DClient(this), pp::VideoDecoderClient_Dev(this), + is_painting_(false), num_frames_rendered_(0), first_frame_delivered_ticks_(-1), swap_ticks_(0), diff --git a/chromium/ppapi/generators/idl_c_proto.py b/chromium/ppapi/generators/idl_c_proto.py index 2989a09afd4..0e0797ac42c 100755 --- a/chromium/ppapi/generators/idl_c_proto.py +++ b/chromium/ppapi/generators/idl_c_proto.py @@ -606,8 +606,14 @@ class CGen(object): for line in data.split('\n'): # Add indentation line = tab + line - if len(line) <= 80: + space_break = line.rfind(' ', 0, 80) + if len(line) <= 80 or 'http' in line: + # Ignore normal line and URLs permitted by the style guide. lines.append(line.rstrip()) + elif not '(' in line and space_break >= 0: + # Break long typedefs on nearest space. + lines.append(line[0:space_break]) + lines.append(' ' + line[space_break + 1:]) else: left = line.rfind('(') + 1 args = line[left:].split(',') diff --git a/chromium/ppapi/host/message_filter_host.cc b/chromium/ppapi/host/message_filter_host.cc index 78ebd231ff4..1ef6244caa4 100644 --- a/chromium/ppapi/host/message_filter_host.cc +++ b/chromium/ppapi/host/message_filter_host.cc @@ -23,4 +23,4 @@ MessageFilterHost::~MessageFilterHost() { } } // namespace host -} // namespace ppapi
\ No newline at end of file +} // namespace ppapi diff --git a/chromium/ppapi/native_client/src/trusted/plugin/json_manifest.cc b/chromium/ppapi/native_client/src/trusted/plugin/json_manifest.cc index 12d3c10d19c..0928c05f2ce 100644 --- a/chromium/ppapi/native_client/src/trusted/plugin/json_manifest.cc +++ b/chromium/ppapi/native_client/src/trusted/plugin/json_manifest.cc @@ -173,6 +173,15 @@ bool IsValidUrlSpec(const Json::Value& url_spec, urlSpecPlusOptional = kPnaclUrlSpecPlusOptional; urlSpecPlusOptionalLength = NACL_ARRAY_SIZE(kPnaclUrlSpecPlusOptional); } else { + // URL specifications must not contain "pnacl-translate" keys. + // This prohibits NaCl clients from invoking PNaCl. + if (url_spec.isMember(kPnaclTranslateKey)) { + nacl::stringstream error_stream; + error_stream << "PNaCl-like NMF with application/x-nacl mimetype instead " + << "of x-pnacl mimetype (has " << kPnaclTranslateKey << ")."; + *error_string = error_stream.str(); + return false; + } urlSpecPlusOptional = kManifestUrlSpecRequired; urlSpecPlusOptionalLength = NACL_ARRAY_SIZE(kManifestUrlSpecRequired); } @@ -184,16 +193,6 @@ bool IsValidUrlSpec(const Json::Value& url_spec, error_string)) { return false; } - // URL specifications must not contain "pnacl-translate" keys. - // This prohibits NaCl clients from invoking PNaCl. - Json::Value translate = url_spec[kPnaclTranslateKey]; - if (!translate.empty()) { - nacl::stringstream error_stream; - error_stream << parent_key << " property '" << container_key << - "' has '" << kPnaclTranslateKey << "' inside URL spec."; - *error_string = error_stream.str(); - return false; - } // Verify the correct types of the fields if they exist. Json::Value url = url_spec[kUrlKey]; if (!url.isString()) { diff --git a/chromium/ppapi/native_client/src/trusted/plugin/local_temp_file.cc b/chromium/ppapi/native_client/src/trusted/plugin/local_temp_file.cc deleted file mode 100644 index 15917e71104..00000000000 --- a/chromium/ppapi/native_client/src/trusted/plugin/local_temp_file.cc +++ /dev/null @@ -1,243 +0,0 @@ -// Copyright (c) 2012 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#include "ppapi/native_client/src/trusted/plugin/local_temp_file.h" - -#include "native_client/src/include/portability_io.h" -#include "native_client/src/shared/platform/nacl_check.h" - -#include "ppapi/c/ppb_file_io.h" -#include "ppapi/cpp/file_io.h" -#include "ppapi/cpp/file_ref.h" -#include "ppapi/cpp/file_system.h" - -#include "ppapi/native_client/src/trusted/plugin/plugin.h" -#include "ppapi/native_client/src/trusted/plugin/utility.h" - -////////////////////////////////////////////////////////////////////// -// Local temporary file access. -////////////////////////////////////////////////////////////////////// -namespace plugin { - -namespace { -nacl::string Random32CharHexString(struct NaClDescRng* rng) { - struct NaClDesc* desc = reinterpret_cast<struct NaClDesc*>(rng); - const struct NaClDescVtbl* vtbl = - reinterpret_cast<const struct NaClDescVtbl*>(desc->base.vtbl); - - nacl::string hex_string; - const int32_t kTempFileNameWords = 4; - for (int32_t i = 0; i < kTempFileNameWords; ++i) { - int32_t num; - CHECK(sizeof num == vtbl->Read(desc, - reinterpret_cast<char*>(&num), - sizeof num)); - char frag[16]; - SNPRINTF(frag, sizeof frag, "%08x", num); - hex_string += nacl::string(frag); - } - return hex_string; -} - -// Some constants for LocalTempFile::GetFD readability. -const bool kReadOnly = false; -const bool kWriteable = true; -} // namespace - -uint32_t LocalTempFile::next_identifier = 0; - -LocalTempFile::LocalTempFile(Plugin* plugin, - pp::FileSystem* file_system, - const nacl::string &base_dir) - : plugin_(plugin), - file_system_(file_system), - base_dir_(base_dir) { - PLUGIN_PRINTF(("LocalTempFile::LocalTempFile (plugin=%p, " - "file_system=%p)\n", - static_cast<void*>(plugin), static_cast<void*>(file_system))); - Initialize(); -} - -LocalTempFile::LocalTempFile(Plugin* plugin, - pp::FileSystem* file_system, - const nacl::string &base_dir, - const nacl::string &filename) - : plugin_(plugin), - file_system_(file_system), - base_dir_(base_dir), - filename_(base_dir + "/" + filename) { - PLUGIN_PRINTF(("LocalTempFile::LocalTempFile (plugin=%p, " - "file_system=%p, filename=%s)\n", - static_cast<void*>(plugin), static_cast<void*>(file_system), - filename.c_str())); - file_ref_.reset(new pp::FileRef(*file_system_, filename_.c_str())); - Initialize(); -} - -void LocalTempFile::Initialize() { - callback_factory_.Initialize(this); - rng_desc_ = (struct NaClDescRng *) malloc(sizeof *rng_desc_); - CHECK(rng_desc_ != NULL); - CHECK(NaClDescRngCtor(rng_desc_)); - file_io_trusted_ = static_cast<const PPB_FileIOTrusted*>( - pp::Module::Get()->GetBrowserInterface(PPB_FILEIOTRUSTED_INTERFACE)); - ++next_identifier; - SNPRINTF(reinterpret_cast<char *>(identifier_), sizeof identifier_, - "%" NACL_PRIu32, next_identifier); -} - -LocalTempFile::~LocalTempFile() { - PLUGIN_PRINTF(("LocalTempFile::~LocalTempFile\n")); - NaClDescUnref(reinterpret_cast<NaClDesc*>(rng_desc_)); -} - -void LocalTempFile::OpenWrite(const pp::CompletionCallback& cb) { - done_callback_ = cb; - // If we don't already have a filename, generate one. - if (filename_ == "") { - // Get a random temp file name. - filename_ = base_dir_ + "/" + Random32CharHexString(rng_desc_); - // Remember the ref used to open for writing and reading. - file_ref_.reset(new pp::FileRef(*file_system_, filename_.c_str())); - } - PLUGIN_PRINTF(("LocalTempFile::OpenWrite: %s\n", filename_.c_str())); - // Open the writeable file. - write_io_.reset(new pp::FileIO(plugin_)); - pp::CompletionCallback open_write_cb = - callback_factory_.NewCallback(&LocalTempFile::WriteFileDidOpen); - write_io_->Open(*file_ref_, - PP_FILEOPENFLAG_WRITE | - PP_FILEOPENFLAG_CREATE | - PP_FILEOPENFLAG_EXCLUSIVE, - open_write_cb); -} - -int32_t LocalTempFile::GetFD(int32_t pp_error, - const pp::Resource& resource, - bool is_writable) { - PLUGIN_PRINTF(("LocalTempFile::GetFD (pp_error=%" NACL_PRId32 - ", is_writable=%d)\n", pp_error, is_writable)); - if (pp_error != PP_OK) { - PLUGIN_PRINTF(("LocalTempFile::GetFD pp_error != PP_OK\n")); - return -1; - } - int32_t file_desc = - file_io_trusted_->GetOSFileDescriptor(resource.pp_resource()); -#if NACL_WINDOWS - // Convert the Windows HANDLE from Pepper to a POSIX file descriptor. - int32_t open_flags = ((is_writable ? _O_RDWR : _O_RDONLY) | _O_BINARY); - int32_t posix_desc = _open_osfhandle(file_desc, open_flags); - if (posix_desc == -1) { - // Close the Windows HANDLE if it can't be converted. - CloseHandle(reinterpret_cast<HANDLE>(file_desc)); - PLUGIN_PRINTF(("LocalTempFile::GetFD _open_osfhandle failed.\n")); - return NACL_NO_FILE_DESC; - } - file_desc = posix_desc; -#endif - int32_t file_desc_ok_to_close = DUP(file_desc); - if (file_desc_ok_to_close == NACL_NO_FILE_DESC) { - PLUGIN_PRINTF(("LocalTempFile::GetFD dup failed.\n")); - return -1; - } - return file_desc_ok_to_close; -} - -void LocalTempFile::WriteFileDidOpen(int32_t pp_error) { - PLUGIN_PRINTF(("LocalTempFile::WriteFileDidOpen (pp_error=%" - NACL_PRId32")\n", pp_error)); - if (pp_error == PP_ERROR_FILEEXISTS) { - // Filenames clashed, retry. - filename_ = ""; - OpenWrite(done_callback_); - } - // Run the client's completion callback. - pp::Core* core = pp::Module::Get()->core(); - if (pp_error != PP_OK) { - core->CallOnMainThread(0, done_callback_, pp_error); - return; - } - // Remember the object temporary file descriptor. - int32_t fd = GetFD(pp_error, *write_io_, kWriteable); - if (fd < 0) { - core->CallOnMainThread(0, done_callback_, pp_error); - return; - } - // The descriptor for a writeable file needs to have quota management. - write_wrapper_.reset( - plugin_->wrapper_factory()->MakeFileDescQuota(fd, O_RDWR, identifier_)); - core->CallOnMainThread(0, done_callback_, PP_OK); -} - -void LocalTempFile::OpenRead(const pp::CompletionCallback& cb) { - PLUGIN_PRINTF(("LocalTempFile::OpenRead: %s\n", filename_.c_str())); - done_callback_ = cb; - // Open the read only file. - read_io_.reset(new pp::FileIO(plugin_)); - pp::CompletionCallback open_read_cb = - callback_factory_.NewCallback(&LocalTempFile::ReadFileDidOpen); - read_io_->Open(*file_ref_, PP_FILEOPENFLAG_READ, open_read_cb); -} - -void LocalTempFile::ReadFileDidOpen(int32_t pp_error) { - PLUGIN_PRINTF(("LocalTempFile::ReadFileDidOpen (pp_error=%" - NACL_PRId32")\n", pp_error)); - // Run the client's completion callback. - pp::Core* core = pp::Module::Get()->core(); - if (pp_error != PP_OK) { - core->CallOnMainThread(0, done_callback_, pp_error); - return; - } - // Remember the object temporary file descriptor. - int32_t fd = GetFD(pp_error, *read_io_, kReadOnly); - if (fd < 0) { - core->CallOnMainThread(0, done_callback_, PP_ERROR_FAILED); - return; - } - read_wrapper_.reset(plugin_->wrapper_factory()->MakeFileDesc(fd, O_RDONLY)); - core->CallOnMainThread(0, done_callback_, PP_OK); -} - -void LocalTempFile::Close(const pp::CompletionCallback& cb) { - PLUGIN_PRINTF(("LocalTempFile::Close: %s\n", filename_.c_str())); - // Close the open DescWrappers and FileIOs. - if (write_io_.get() != NULL) { - write_io_->Close(); - } - write_wrapper_.reset(NULL); - write_io_.reset(NULL); - if (read_io_.get() != NULL) { - read_io_->Close(); - } - read_wrapper_.reset(NULL); - read_io_.reset(NULL); - // Run the client's completion callback. - pp::Core* core = pp::Module::Get()->core(); - core->CallOnMainThread(0, cb, PP_OK); -} - -void LocalTempFile::Delete(const pp::CompletionCallback& cb) { - PLUGIN_PRINTF(("LocalTempFile::Delete: %s\n", filename_.c_str())); - file_ref_->Delete(cb); -} - -void LocalTempFile::Rename(const nacl::string& new_name, - const pp::CompletionCallback& cb) { - // Rename the temporary file. - filename_ = base_dir_ + "/" + new_name; - PLUGIN_PRINTF(("LocalTempFile::Rename %s to %s\n", - file_ref_->GetName().AsString().c_str(), - filename_.c_str())); - // Remember the old ref until the rename is complete. - old_ref_.reset(file_ref_.release()); - file_ref_.reset(new pp::FileRef(*file_system_, filename_.c_str())); - old_ref_->Rename(*file_ref_, cb); -} - -void LocalTempFile::FinishRename() { - // Now we can release the old ref. - old_ref_.reset(NULL); -} - -} // namespace plugin diff --git a/chromium/ppapi/native_client/src/trusted/plugin/local_temp_file.h b/chromium/ppapi/native_client/src/trusted/plugin/local_temp_file.h deleted file mode 100644 index 51d2095f1c9..00000000000 --- a/chromium/ppapi/native_client/src/trusted/plugin/local_temp_file.h +++ /dev/null @@ -1,133 +0,0 @@ -// Copyright (c) 2012 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#ifndef NATIVE_CLIENT_SRC_TRUSTED_PLUGIN_LOCAL_TEMP_FILE_H_ -#define NATIVE_CLIENT_SRC_TRUSTED_PLUGIN_LOCAL_TEMP_FILE_H_ - -#include "native_client/src/include/nacl_macros.h" -#include "native_client/src/include/nacl_string.h" -#include "native_client/src/trusted/desc/nacl_desc_rng.h" -#include "native_client/src/trusted/desc/nacl_desc_wrapper.h" - -#include "ppapi/c/trusted/ppb_file_io_trusted.h" -#include "ppapi/utility/completion_callback_factory.h" - -namespace pp { -class CompletionCallback; -class FileIO; -class FileRef; -class FileSystem; -} - -namespace plugin { - -class Plugin; - -// Translation creates two temporary files. The first temporary file holds -// the object file created by llc. The second holds the nexe produced by -// the linker. Both of these temporary files are used to both write and -// read according to the following matrix: -// -// PnaclCoordinator::obj_file_: -// written by: llc (passed in explicitly through SRPC) -// read by: ld (returned via lookup service from SRPC) -// PnaclCoordinator::nexe_file_: -// written by: ld (passed in explicitly through SRPC) -// read by: sel_ldr (passed in explicitly to command channel) -// - -// LocalTempFile represents a file used as a temporary between stages in -// translation. It is created in the local temporary file system of the page -// being processed. The name of the temporary file is a random 32-character -// hex string. Because both reading and writing are necessary, two I/O objects -// for the file are opened. -class LocalTempFile { - public: - // Create a LocalTempFile with a random name. - LocalTempFile(Plugin* plugin, - pp::FileSystem* file_system, - const nacl::string& base_dir); - // Create a LocalTempFile with a specific filename. - LocalTempFile(Plugin* plugin, - pp::FileSystem* file_system, - const nacl::string& base_dir, - const nacl::string& filename); - ~LocalTempFile(); - // Opens a writeable file IO object and descriptor referring to the file. - void OpenWrite(const pp::CompletionCallback& cb); - // Opens a read only file IO object and descriptor referring to the file. - void OpenRead(const pp::CompletionCallback& cb); - // Closes the open descriptors. - void Close(const pp::CompletionCallback& cb); - // Deletes the temporary file. - void Delete(const pp::CompletionCallback& cb); - // Renames the temporary file. - void Rename(const nacl::string& new_name, - const pp::CompletionCallback& cb); - void FinishRename(); - - // Accessors. - // The nacl::DescWrapper* for the writeable version of the file. - nacl::DescWrapper* write_wrapper() { return write_wrapper_.get(); } - nacl::DescWrapper* release_write_wrapper() { - return write_wrapper_.release(); - } - // The nacl::DescWrapper* for the read-only version of the file. - nacl::DescWrapper* read_wrapper() { return read_wrapper_.get(); } - nacl::DescWrapper* release_read_wrapper() { - return read_wrapper_.release(); - } - // For quota management. - const nacl::string identifier() const { - return nacl::string(reinterpret_cast<const char*>(identifier_)); - } - pp::FileIO* write_file_io() const { return write_io_.get(); } - - private: - NACL_DISALLOW_COPY_AND_ASSIGN(LocalTempFile); - - void Initialize(); - - // Gets the POSIX file descriptor for a resource. - int32_t GetFD(int32_t pp_error, - const pp::Resource& resource, - bool is_writable); - // Called when the writable file IO was opened. - void WriteFileDidOpen(int32_t pp_error); - // Called when the readable file IO was opened. - void ReadFileDidOpen(int32_t pp_error); - // Completes the close operation after quota update. - void CloseContinuation(int32_t pp_error); - - Plugin* plugin_; - pp::FileSystem* file_system_; - const PPB_FileIOTrusted* file_io_trusted_; - pp::CompletionCallbackFactory<LocalTempFile> callback_factory_; - nacl::string base_dir_; - nacl::string filename_; - nacl::scoped_ptr<pp::FileRef> file_ref_; - // Temporarily holds the previous file ref during a rename operation. - nacl::scoped_ptr<pp::FileRef> old_ref_; - // The PPAPI and wrapper state for the writeable file. - nacl::scoped_ptr<pp::FileIO> write_io_; - nacl::scoped_ptr<nacl::DescWrapper> write_wrapper_; - // The PPAPI and wrapper state for the read-only file. - nacl::scoped_ptr<pp::FileIO> read_io_; - nacl::scoped_ptr<nacl::DescWrapper> read_wrapper_; - // The callback invoked when both file I/O objects are created. - pp::CompletionCallback done_callback_; - // Random number generator used to create filenames. - struct NaClDescRng *rng_desc_; - // An identifier string used for quota request processing. The quota - // interface needs a string that is unique per sel_ldr instance only, so - // the identifiers can be reused between runs of the translator, start-ups of - // the browser, etc. - uint8_t identifier_[16]; - // A counter to dole out unique identifiers. - static uint32_t next_identifier; -}; - -} // namespace plugin - -#endif // NATIVE_CLIENT_SRC_TRUSTED_PLUGIN_LOCAL_TEMP_FILE_H_ diff --git a/chromium/ppapi/native_client/src/trusted/plugin/module_ppapi.cc b/chromium/ppapi/native_client/src/trusted/plugin/module_ppapi.cc index 4204ed4637e..b73a1a3ac3b 100644 --- a/chromium/ppapi/native_client/src/trusted/plugin/module_ppapi.cc +++ b/chromium/ppapi/native_client/src/trusted/plugin/module_ppapi.cc @@ -5,10 +5,10 @@ */ #include "native_client/src/shared/imc/nacl_imc_c.h" +#include "native_client/src/shared/platform/nacl_secure_random.h" #include "native_client/src/shared/platform/nacl_time.h" #include "native_client/src/trusted/desc/nrd_all_modules.h" - #include "ppapi/native_client/src/trusted/plugin/module_ppapi.h" #include "ppapi/native_client/src/trusted/plugin/nacl_entry_points.h" #include "ppapi/native_client/src/trusted/plugin/plugin.h" @@ -76,28 +76,6 @@ pp::Instance* ModulePpapi::CreateInstance(PP_Instance pp_instance) { return plugin; } -const uint64_t kMaxCrashesPerInterval = 3; -const uint64_t kCrashesIntervalInSeconds = 120; - -void ModulePpapi::RegisterPluginCrash() { - PLUGIN_PRINTF(("ModulePpapi::RegisterPluginCrash ()\n")); - if (crash_times_.size() == kMaxCrashesPerInterval) { - crash_times_.pop_front(); - } - int64_t time = NaClGetTimeOfDayMicroseconds(); - crash_times_.push_back(time); -} - -bool ModulePpapi::IsPluginUnstable() { - PLUGIN_PRINTF(("ModulePpapi::IsPluginUnstable ()\n")); - if (crash_times_.size() != kMaxCrashesPerInterval) { - return false; - } - int64_t now = NaClGetTimeOfDayMicroseconds(); - int64_t delta = now - crash_times_.front(); - return delta / (1000.0 * 1000.0) <= kCrashesIntervalInSeconds; -} - } // namespace plugin diff --git a/chromium/ppapi/native_client/src/trusted/plugin/module_ppapi.h b/chromium/ppapi/native_client/src/trusted/plugin/module_ppapi.h index b2e75645e7b..ee7bd1980ee 100644 --- a/chromium/ppapi/native_client/src/trusted/plugin/module_ppapi.h +++ b/chromium/ppapi/native_client/src/trusted/plugin/module_ppapi.h @@ -4,8 +4,6 @@ * found in the LICENSE file. */ -#include <deque> - #include "ppapi/c/private/ppb_nacl_private.h" #include "ppapi/cpp/module.h" @@ -21,18 +19,9 @@ class ModulePpapi : public pp::Module { virtual pp::Instance* CreateInstance(PP_Instance pp_instance); - // NaCl crash throttling. If RegisterPluginCrash is called too many times - // within a time period, IsPluginUnstable reports true. As long as - // IsPluginUnstable returns true, NaCl modules will fail to load. - void RegisterPluginCrash(); - bool IsPluginUnstable(); - private: bool init_was_successful_; const PPB_NaCl_Private* private_interface_; - - // Crash throttling support. - std::deque<int64_t> crash_times_; }; } // namespace plugin diff --git a/chromium/ppapi/native_client/src/trusted/plugin/nacl_entry_points.h b/chromium/ppapi/native_client/src/trusted/plugin/nacl_entry_points.h index 4fd620d097d..0d182087d66 100644 --- a/chromium/ppapi/native_client/src/trusted/plugin/nacl_entry_points.h +++ b/chromium/ppapi/native_client/src/trusted/plugin/nacl_entry_points.h @@ -24,6 +24,7 @@ typedef PP_ExternalPluginResult (*LaunchNaClProcessFunc)( PP_Bool enable_ppapi_dev, PP_Bool enable_dyncode_syscalls, PP_Bool enable_exception_handling, + PP_Bool enable_crash_throttling, NaClHandle* result_socket, struct PP_Var* error_message); diff --git a/chromium/ppapi/native_client/src/trusted/plugin/plugin.cc b/chromium/ppapi/native_client/src/trusted/plugin/plugin.cc index fe27aa29143..2aa90bedb4e 100644 --- a/chromium/ppapi/native_client/src/trusted/plugin/plugin.cc +++ b/chromium/ppapi/native_client/src/trusted/plugin/plugin.cc @@ -55,7 +55,6 @@ #include "ppapi/native_client/src/trusted/plugin/file_utils.h" #include "ppapi/native_client/src/trusted/plugin/json_manifest.h" -#include "ppapi/native_client/src/trusted/plugin/module_ppapi.h" #include "ppapi/native_client/src/trusted/plugin/nacl_entry_points.h" #include "ppapi/native_client/src/trusted/plugin/nacl_subprocess.h" #include "ppapi/native_client/src/trusted/plugin/nexe_arch.h" @@ -447,6 +446,7 @@ bool Plugin::LoadNaClModule(nacl::DescWrapper* wrapper, ErrorInfo* error_info, bool enable_dyncode_syscalls, bool enable_exception_handling, + bool enable_crash_throttling, const pp::CompletionCallback& init_done_cb, const pp::CompletionCallback& crash_cb) { // Before forking a new sel_ldr process, ensure that we do not leak @@ -460,7 +460,8 @@ bool Plugin::LoadNaClModule(nacl::DescWrapper* wrapper, true /* uses_ppapi */, enable_dev_interfaces_, enable_dyncode_syscalls, - enable_exception_handling); + enable_exception_handling, + enable_crash_throttling); if (!LoadNaClModuleCommon(wrapper, &main_subprocess_, manifest_.get(), true /* should_report_uma */, params, init_done_cb, crash_cb)) { @@ -532,7 +533,8 @@ NaClSubprocess* Plugin::LoadHelperNaClModule(nacl::DescWrapper* wrapper, false /* uses_ppapi */, enable_dev_interfaces_, false /* enable_dyncode_syscalls */, - false /* enable_exception_handling */); + false /* enable_exception_handling */, + true /* enable_crash_throttling */); if (!LoadNaClModuleCommon(wrapper, nacl_subprocess.get(), manifest, false /* should_report_uma */, params, @@ -907,6 +909,7 @@ void Plugin::NexeFileDidOpen(int32_t pp_error) { wrapper.get(), &error_info, true, /* enable_dyncode_syscalls */ true, /* enable_exception_handling */ + false, /* enable_crash_throttling */ callback_factory_.NewCallback(&Plugin::NexeFileDidOpenContinuation), callback_factory_.NewCallback(&Plugin::NexeDidCrash)); @@ -1010,10 +1013,6 @@ void Plugin::NexeDidCrash(int32_t pp_error) { // invocation will just be a no-op, since all the crash log will // have been received and we'll just get an EOF indication. CopyCrashLogToJsConsole(); - - // Remember the nexe crash time, which helps determine the need to throttle. - ModulePpapi* module_ppapi = static_cast<ModulePpapi*>(pp::Module::Get()); - module_ppapi->RegisterPluginCrash(); } void Plugin::BitcodeDidTranslate(int32_t pp_error) { @@ -1033,6 +1032,7 @@ void Plugin::BitcodeDidTranslate(int32_t pp_error) { wrapper.get(), &error_info, false, /* enable_dyncode_syscalls */ false, /* enable_exception_handling */ + true, /* enable_crash_throttling */ callback_factory_.NewCallback(&Plugin::BitcodeDidTranslateContinuation), callback_factory_.NewCallback(&Plugin::NexeDidCrash)); @@ -1208,31 +1208,16 @@ void Plugin::ProcessNaClManifest(const nacl::string& manifest_json) { // Inform JavaScript that we found a nexe URL to load. EnqueueProgressEvent(kProgressEventProgress); if (pnacl_options.translate()) { - if (this->nacl_interface()->IsPnaclEnabled()) { - // Check whether PNaCl has been crashing "frequently". If so, report - // a load error. - ModulePpapi* module_ppapi = - static_cast<ModulePpapi*>(pp::Module::Get()); - if (module_ppapi->IsPluginUnstable()) { - error_info.SetReport(ERROR_PNACL_CRASH_THROTTLED, - "PNaCl has been temporarily disabled because too" - " many crashes have been observed."); - } else { - pp::CompletionCallback translate_callback = - callback_factory_.NewCallback(&Plugin::BitcodeDidTranslate); - // Will always call the callback on success or failure. - pnacl_coordinator_.reset( - PnaclCoordinator::BitcodeToNative(this, - program_url, - pnacl_options, - translate_callback)); - return; - } - } else { - error_info.SetReport(ERROR_PNACL_NOT_ENABLED, - "PNaCl has not been enabled (e.g., by setting " - "the --enable-pnacl flag)."); - } + CHECK(nacl_interface()->IsPnaclEnabled()); + pp::CompletionCallback translate_callback = + callback_factory_.NewCallback(&Plugin::BitcodeDidTranslate); + // Will always call the callback on success or failure. + pnacl_coordinator_.reset( + PnaclCoordinator::BitcodeToNative(this, + program_url, + pnacl_options, + translate_callback)); + return; } else { // Try the fast path first. This will only block if the file is installed. if (OpenURLFast(program_url, &nexe_downloader_)) { diff --git a/chromium/ppapi/native_client/src/trusted/plugin/plugin.gypi b/chromium/ppapi/native_client/src/trusted/plugin/plugin.gypi index 1357a370de4..7f3bff41402 100644 --- a/chromium/ppapi/native_client/src/trusted/plugin/plugin.gypi +++ b/chromium/ppapi/native_client/src/trusted/plugin/plugin.gypi @@ -9,7 +9,6 @@ 'file_downloader.cc', 'file_utils.cc', 'json_manifest.cc', - 'local_temp_file.cc', 'module_ppapi.cc', 'nacl_http_response_headers.cc', 'nacl_subprocess.cc', diff --git a/chromium/ppapi/native_client/src/trusted/plugin/plugin.h b/chromium/ppapi/native_client/src/trusted/plugin/plugin.h index 1e9e78003f5..416ab5bf71a 100644 --- a/chromium/ppapi/native_client/src/trusted/plugin/plugin.h +++ b/chromium/ppapi/native_client/src/trusted/plugin/plugin.h @@ -106,6 +106,7 @@ class Plugin : public pp::InstancePrivate { bool LoadNaClModule(nacl::DescWrapper* wrapper, ErrorInfo* error_info, bool enable_dyncode_syscalls, bool enable_exception_handling, + bool enable_crash_throttling, const pp::CompletionCallback& init_done_cb, const pp::CompletionCallback& crash_cb); diff --git a/chromium/ppapi/native_client/src/trusted/plugin/plugin_error.h b/chromium/ppapi/native_client/src/trusted/plugin/plugin_error.h index cba1701c6cd..4ec0b51a9e0 100644 --- a/chromium/ppapi/native_client/src/trusted/plugin/plugin_error.h +++ b/chromium/ppapi/native_client/src/trusted/plugin/plugin_error.h @@ -93,8 +93,8 @@ enum PluginErrorCode { ERROR_PNACL_LLC_INTERNAL = 65, ERROR_PNACL_LD_INTERNAL = 66, ERROR_PNACL_CREATE_TEMP = 67, - // Remove this next code when pnacl is no longer behind a flag (when we - // remove the --enable-pnacl flag). + // This entry is no longer used, but should not be removed, because UMA + // numbers need to be kept consistent. ERROR_PNACL_NOT_ENABLED = 68, ERROR_MANIFEST_NOACCESS_URL = 69, ERROR_NEXE_NOACCESS_URL = 70, diff --git a/chromium/ppapi/native_client/src/trusted/plugin/pnacl_coordinator.cc b/chromium/ppapi/native_client/src/trusted/plugin/pnacl_coordinator.cc index 4362ec40313..26268bf7eba 100644 --- a/chromium/ppapi/native_client/src/trusted/plugin/pnacl_coordinator.cc +++ b/chromium/ppapi/native_client/src/trusted/plugin/pnacl_coordinator.cc @@ -14,11 +14,8 @@ #include "ppapi/c/pp_bool.h" #include "ppapi/c/pp_errors.h" -#include "ppapi/c/ppb_file_io.h" #include "ppapi/c/private/ppb_uma_private.h" -#include "ppapi/cpp/file_io.h" -#include "ppapi/native_client/src/trusted/plugin/local_temp_file.h" #include "ppapi/native_client/src/trusted/plugin/manifest.h" #include "ppapi/native_client/src/trusted/plugin/nacl_http_response_headers.h" #include "ppapi/native_client/src/trusted/plugin/plugin.h" @@ -27,11 +24,6 @@ #include "ppapi/native_client/src/trusted/plugin/service_runtime.h" #include "ppapi/native_client/src/trusted/plugin/temporary_file.h" -namespace { -const char kPnaclTempDir[] = "/.pnacl"; -const uint32_t kCopyBufSize = 512 << 10; -} - namespace plugin { ////////////////////////////////////////////////////////////////////// @@ -259,13 +251,11 @@ PnaclCoordinator::PnaclCoordinator( : translate_finish_error_(PP_OK), plugin_(plugin), translate_notify_callback_(translate_notify_callback), - file_system_(new pp::FileSystem(plugin, PP_FILESYSTEMTYPE_LOCALTEMPORARY)), + translation_finished_reported_(false), manifest_(new PnaclManifest()), pexe_url_(pexe_url), pnacl_options_(pnacl_options), - use_new_cache_(true), is_cache_hit_(PP_FALSE), - nexe_handle_(PP_kInvalidFileHandle), error_already_reported_(false), off_the_record_(false), pnacl_init_time_(0), @@ -275,10 +265,6 @@ PnaclCoordinator::PnaclCoordinator( PLUGIN_PRINTF(("PnaclCoordinator::PnaclCoordinator (this=%p, plugin=%p)\n", static_cast<void*>(this), static_cast<void*>(plugin))); callback_factory_.Initialize(this); - if (getenv("PNACL_USE_OLD_CACHE")) { - PLUGIN_PRINTF(("PnaclCoordinator using old translation cache\n")); - use_new_cache_ = false; - } } PnaclCoordinator::~PnaclCoordinator() { @@ -293,6 +279,16 @@ PnaclCoordinator::~PnaclCoordinator() { if (translate_thread_.get() != NULL) { translate_thread_->AbortSubprocesses(); } + if (!translation_finished_reported_) { + plugin_->nacl_interface()->ReportTranslationFinished( + plugin_->pp_instance(), + PP_FALSE); + } +} + +nacl::DescWrapper* PnaclCoordinator::ReleaseTranslatedFD() { + DCHECK(temp_nexe_file_ != NULL); + return temp_nexe_file_->release_read_wrapper(); } void PnaclCoordinator::ReportNonPpapiError(enum PluginErrorCode err_code, @@ -325,6 +321,10 @@ void PnaclCoordinator::ExitWithError() { callback_factory_.CancelAll(); if (!error_already_reported_) { error_already_reported_ = true; + translation_finished_reported_ = true; + plugin_->nacl_interface()->ReportTranslationFinished( + plugin_->pp_instance(), + PP_FALSE); translate_notify_callback_.Run(PP_ERROR_FAILED); } else { PLUGIN_PRINTF(("PnaclCoordinator::ExitWithError an earlier error was " @@ -339,11 +339,6 @@ void PnaclCoordinator::TranslateFinished(int32_t pp_error) { // Bail out if there was an earlier error (e.g., pexe load failure), // or if there is an error from the translation thread. if (translate_finish_error_ != PP_OK || pp_error != PP_OK) { - if (use_new_cache_) { - plugin_->nacl_interface()->ReportTranslationFinished( - plugin_->pp_instance(), - PP_FALSE); - } ExitWithError(); return; } @@ -388,242 +383,6 @@ void PnaclCoordinator::TranslateFinished(int32_t pp_error) { HistogramRatio("NaCl.Perf.Size.PexeNexeSizePct", pexe_size_, nexe_size); } - // The nexe is written to the temp_nexe_file_. We must Reset() the file - // pointer to be able to read it again from the beginning. - temp_nexe_file_->Reset(); - - if (use_new_cache_) { - // Report to the browser that translation finished. The browser will take - // care of caching. - plugin_->nacl_interface()->ReportTranslationFinished( - plugin_->pp_instance(), PP_TRUE); - - // These can maybe move up with the rest of the UMA stats when we remove - // the old cache code - int64_t total_time = NaClGetTimeOfDayMicroseconds() - pnacl_init_time_; - HistogramTime("NaCl.Perf.PNaClLoadTime.TotalUncachedTime", - total_time / NACL_MICROS_PER_MILLI); - HistogramKBPerSec("NaCl.Perf.PNaClLoadTime.TotalUncachedKBPerSec", - pexe_size_ / 1024.0, - total_time / 1000000.0); - NexeReadDidOpen(PP_OK); - return; - } - if (pnacl_options_.HasCacheKey() && cached_nexe_file_ != NULL) { - // We are using a cache, but had a cache miss, which is why we did the - // translation. Reset cached_nexe_file_ to have a random name, - // for scratch purposes, before renaming to the final cache_identity. - cached_nexe_file_.reset(new LocalTempFile(plugin_, file_system_.get(), - nacl::string(kPnaclTempDir))); - pp::CompletionCallback cb = callback_factory_.NewCallback( - &PnaclCoordinator::CachedNexeOpenedForWrite); - cached_nexe_file_->OpenWrite(cb); - } else { - // For now, tolerate bitcode that is missing a cache identity, and - // tolerate the lack of caching in incognito mode. - PLUGIN_PRINTF(("PnaclCoordinator -- not caching.\n")); - NexeReadDidOpen(PP_OK); - } -} - -void PnaclCoordinator::CachedNexeOpenedForWrite(int32_t pp_error) { - if (pp_error != PP_OK) { - if (pp_error == PP_ERROR_NOACCESS) { - ReportPpapiError( - ERROR_PNACL_CACHE_FILEOPEN_NOACCESS, - pp_error, - "PNaCl translation cache failed to open file for write " - "(no access)."); - return; - } - if (pp_error == PP_ERROR_NOQUOTA) { - ReportPpapiError( - ERROR_PNACL_CACHE_FILEOPEN_NOQUOTA, - pp_error, - "PNaCl translation cache failed to open file for write " - "(no quota)."); - return; - } - if (pp_error == PP_ERROR_NOSPACE) { - ReportPpapiError( - ERROR_PNACL_CACHE_FILEOPEN_NOSPACE, - pp_error, - "PNaCl translation cache failed to open file for write " - "(no space)."); - return; - } - if (pp_error == PP_ERROR_NOTAFILE) { - ReportPpapiError(ERROR_PNACL_CACHE_FILEOPEN_NOTAFILE, - pp_error, - "PNaCl translation cache failed to open file for write." - " File already exists as a directory."); - return; - } - ReportPpapiError(ERROR_PNACL_CACHE_FILEOPEN_OTHER, - pp_error, - "PNaCl translation cache failed to open file for write."); - return; - } - - // Copy the contents from temp_nexe_file_ -> cached_nexe_file_, - // then rename the cached_nexe_file_ file to the cache id. - int64_t cur_offset = 0; - nacl::DescWrapper* read_wrapper = temp_nexe_file_->read_wrapper(); - char buf[kCopyBufSize]; - int32_t num_read = - nacl::assert_cast<int32_t>(read_wrapper->Read(buf, sizeof buf)); - // Hit EOF or something. - if (num_read == 0) { - NexeWasCopiedToCache(PP_OK); - return; - } - if (num_read < 0) { - PLUGIN_PRINTF(("PnaclCoordinator::CachedNexeOpenedForWrite read failed " - "(error=%" NACL_PRId32 ")\n", num_read)); - NexeWasCopiedToCache(PP_ERROR_FAILED); - return; - } - pp::CompletionCallback cb = callback_factory_.NewCallback( - &PnaclCoordinator::DidCopyNexeToCachePartial, num_read, cur_offset); - cached_nexe_file_->write_file_io()->Write(cur_offset, buf, num_read, cb); -} - -void PnaclCoordinator::DidCopyNexeToCachePartial(int32_t pp_error, - int32_t num_read_prev, - int64_t cur_offset) { - PLUGIN_PRINTF(("PnaclCoordinator::DidCopyNexeToCachePartial " - "(pp_error=%" NACL_PRId32 ", num_read_prev=%" NACL_PRId32 - ", cur_offset=%" NACL_PRId64 ").\n", - pp_error, num_read_prev, cur_offset)); - // Assume we are done. - if (pp_error == PP_OK) { - NexeWasCopiedToCache(PP_OK); - return; - } - if (pp_error < PP_OK) { - PLUGIN_PRINTF(("PnaclCoordinator::DidCopyNexeToCachePartial failed (err=%" - NACL_PRId32 ")\n", pp_error)); - NexeWasCopiedToCache(pp_error); - return; - } - - // Check if we wrote as much as we read. - nacl::DescWrapper* read_wrapper = temp_nexe_file_->read_wrapper(); - if (pp_error != num_read_prev) { - PLUGIN_PRINTF(("PnaclCoordinator::DidCopyNexeToCachePartial partial " - "write (bytes_written=%" NACL_PRId32 " vs " - "read=%" NACL_PRId32 ")\n", pp_error, num_read_prev)); - CHECK(pp_error < num_read_prev); - // Seek back to re-read the bytes that were not written. - nacl_off64_t seek_result = - read_wrapper->Seek(pp_error - num_read_prev, SEEK_CUR); - if (seek_result < 0) { - PLUGIN_PRINTF(("PnaclCoordinator::DidCopyNexeToCachePartial seek failed " - "(err=%" NACL_PRId64 ")\n", seek_result)); - NexeWasCopiedToCache(PP_ERROR_FAILED); - return; - } - } - - int64_t next_offset = cur_offset + pp_error; - char buf[kCopyBufSize]; - int32_t num_read = - nacl::assert_cast<int32_t>(read_wrapper->Read(buf, sizeof buf)); - PLUGIN_PRINTF(("PnaclCoordinator::DidCopyNexeToCachePartial read (bytes=%" - NACL_PRId32 ")\n", num_read)); - // Hit EOF or something. - if (num_read == 0) { - NexeWasCopiedToCache(PP_OK); - return; - } - if (num_read < 0) { - PLUGIN_PRINTF(("PnaclCoordinator::DidCopyNexeToCachePartial read failed " - "(error=%" NACL_PRId32 ")\n", num_read)); - NexeWasCopiedToCache(PP_ERROR_FAILED); - return; - } - pp::CompletionCallback cb = callback_factory_.NewCallback( - &PnaclCoordinator::DidCopyNexeToCachePartial, num_read, next_offset); - PLUGIN_PRINTF(("PnaclCoordinator::CopyNexeToCache Writing (" - "bytes=%" NACL_PRId32 ", buf=%p, file_io=%p)\n", num_read, buf, - cached_nexe_file_->write_file_io())); - cached_nexe_file_->write_file_io()->Write(next_offset, buf, num_read, cb); -} - -void PnaclCoordinator::NexeWasCopiedToCache(int32_t pp_error) { - if (pp_error != PP_OK) { - // Try to delete the partially written not-yet-committed cache file before - // returning. We pass the current pp_error along so that it can be reported - // before returning. - pp::CompletionCallback cb = callback_factory_.NewCallback( - &PnaclCoordinator::CorruptCacheFileWasDeleted, pp_error); - cached_nexe_file_->Delete(cb); - return; - } - // Rename the cached_nexe_file_ file to the cache id, to finalize. - pp::CompletionCallback cb = - callback_factory_.NewCallback(&PnaclCoordinator::NexeFileWasRenamed); - cached_nexe_file_->Rename(pnacl_options_.GetCacheKey(), cb); -} - -void PnaclCoordinator::CorruptCacheFileWasDeleted(int32_t delete_pp_error, - int32_t orig_pp_error) { - if (delete_pp_error != PP_OK) { - // The cache file was certainly already opened by the time we tried - // to write to it, so it should certainly be deletable. - PLUGIN_PRINTF(("PnaclCoordinator::CorruptCacheFileWasDeleted " - "delete failed with pp_error=%" NACL_PRId32 "\n", - delete_pp_error)); - // fall through and report the original error. - } - // Report the original error that caused us to consider the - // cache file corrupted. - if (orig_pp_error == PP_ERROR_NOQUOTA) { - ReportPpapiError(ERROR_PNACL_CACHE_FINALIZE_COPY_NOQUOTA, - orig_pp_error, - "Failed to copy translated nexe to cache (no quota)."); - return; - } - if (orig_pp_error == PP_ERROR_NOSPACE) { - ReportPpapiError(ERROR_PNACL_CACHE_FINALIZE_COPY_NOSPACE, - orig_pp_error, - "Failed to copy translated nexe to cache (no space)."); - return; - } - ReportPpapiError(ERROR_PNACL_CACHE_FINALIZE_COPY_OTHER, - orig_pp_error, - "Failed to copy translated nexe to cache."); - return; -} - -void PnaclCoordinator::NexeFileWasRenamed(int32_t pp_error) { - PLUGIN_PRINTF(("PnaclCoordinator::NexeFileWasRenamed (pp_error=%" - NACL_PRId32 ")\n", pp_error)); - if (pp_error != PP_OK) { - if (pp_error == PP_ERROR_NOACCESS) { - ReportPpapiError(ERROR_PNACL_CACHE_FINALIZE_RENAME_NOACCESS, - pp_error, - "Failed to finalize cached translation (no access)."); - return; - } else if (pp_error != PP_ERROR_FILEEXISTS) { - ReportPpapiError(ERROR_PNACL_CACHE_FINALIZE_RENAME_OTHER, - pp_error, - "Failed to finalize cached translation."); - return; - } else { // pp_error == PP_ERROR_FILEEXISTS. - // NOTE: if the file already existed, it looks like the rename will - // happily succeed. However, we should add a test for this. - // Could be a hash collision, or it could also be two tabs racing to - // translate the same pexe. We may want UMA stats to know if this happens. - // For now, assume that it is a race and try to continue. - // If there is truly a corrupted file, then sel_ldr should prevent the - // file from loading due to the file size not matching the ELF header. - PLUGIN_PRINTF(("PnaclCoordinator::NexeFileWasRenamed file existed\n")); - } - } - - cached_nexe_file_->FinishRename(); - int64_t total_time = NaClGetTimeOfDayMicroseconds() - pnacl_init_time_; HistogramTime("NaCl.Perf.PNaClLoadTime.TotalUncachedTime", total_time / NACL_MICROS_PER_MILLI); @@ -631,10 +390,17 @@ void PnaclCoordinator::NexeFileWasRenamed(int32_t pp_error) { pexe_size_ / 1024.0, total_time / 1000000.0); - // Open the cache file for reading. - pp::CompletionCallback cb = - callback_factory_.NewCallback(&PnaclCoordinator::NexeReadDidOpen); - cached_nexe_file_->OpenRead(cb); + // The nexe is written to the temp_nexe_file_. We must Reset() the file + // pointer to be able to read it again from the beginning. + temp_nexe_file_->Reset(); + + // Report to the browser that translation finished. The browser will take + // care of storing the nexe in the cache. + translation_finished_reported_ = true; + plugin_->nacl_interface()->ReportTranslationFinished( + plugin_->pp_instance(), PP_TRUE); + + NexeReadDidOpen(PP_OK); } void PnaclCoordinator::NexeReadDidOpen(int32_t pp_error) { @@ -659,12 +425,6 @@ void PnaclCoordinator::NexeReadDidOpen(int32_t pp_error) { return; } - // Transfer ownership of cache/temp file's wrapper to the coordinator. - if (cached_nexe_file_ != NULL) { - translated_fd_.reset(cached_nexe_file_->release_read_wrapper()); - } else { - translated_fd_.reset(temp_nexe_file_->release_read_wrapper()); - } translate_notify_callback_.Run(pp_error); } @@ -672,8 +432,9 @@ void PnaclCoordinator::DidCheckPnaclInstalled(int32_t pp_error) { if (pp_error != PP_OK) { ReportNonPpapiError( ERROR_PNACL_RESOURCE_FETCH, - nacl::string("The Portable Native Client component is not installed" - " or has been disabled.")); + nacl::string("The Portable Native Client (pnacl) component is not " + "installed. Please consult chrome://components for more " + "information.")); return; } @@ -709,97 +470,6 @@ void PnaclCoordinator::ResourcesDidLoad(int32_t pp_error) { return; } - if (!off_the_record_) { - if (use_new_cache_) { - OpenBitcodeStream(); - } else { - // Open the local temporary FS to see if we get a hit in the cache. - pp::CompletionCallback cb = - callback_factory_.NewCallback(&PnaclCoordinator::FileSystemDidOpen); - int32_t open_error = file_system_->Open(0, cb); - if (open_error != PP_OK_COMPLETIONPENDING) { - // At this point, no async request has kicked off to check for - // permissions, space, etc., so the only error that can be detected - // now is that an open() is already in progress (or a really terrible - // error). - if (pp_error == PP_ERROR_INPROGRESS) { - ReportPpapiError( - ERROR_PNACL_CACHE_OPEN_INPROGRESS, - pp_error, - "File system for PNaCl translation cache failed to open " - "(in progress)."); - return; - } - ReportPpapiError( - ERROR_PNACL_CACHE_OPEN_OTHER, - pp_error, - "File system for PNaCl translation cache failed to open."); - } - } - } else { - // We don't have a cache, so do the non-cached codepath. - OpenBitcodeStream(); - } -} - -void PnaclCoordinator::FileSystemDidOpen(int32_t pp_error) { - PLUGIN_PRINTF(("PnaclCoordinator::FileSystemDidOpen (pp_error=%" - NACL_PRId32 ")\n", pp_error)); - if (pp_error != PP_OK) { - if (pp_error == PP_ERROR_NOACCESS) { - ReportPpapiError( - ERROR_PNACL_CACHE_OPEN_NOACCESS, - pp_error, - "File system for PNaCl translation cache failed to open " - "(no access)."); - return; - } - if (pp_error == PP_ERROR_NOQUOTA) { - ReportPpapiError( - ERROR_PNACL_CACHE_OPEN_NOQUOTA, - pp_error, - "File system for PNaCl translation cache failed to open " - "(no quota)."); - return; - } - if (pp_error == PP_ERROR_NOSPACE) { - ReportPpapiError( - ERROR_PNACL_CACHE_OPEN_NOSPACE, - pp_error, - "File system for PNaCl translation cache failed to open " - "(no space)."); - return; - } - ReportPpapiError(ERROR_PNACL_CACHE_OPEN_OTHER, - pp_error, - "File system for PNaCl translation cache failed to open."); - } - dir_ref_.reset(new pp::FileRef(*file_system_, kPnaclTempDir)); - // Attempt to create the directory. - pp::CompletionCallback cb = - callback_factory_.NewCallback(&PnaclCoordinator::DirectoryWasCreated); - dir_ref_->MakeDirectory(cb); -} - -void PnaclCoordinator::DirectoryWasCreated(int32_t pp_error) { - PLUGIN_PRINTF(("PnaclCoordinator::DirectoryWasCreated (pp_error=%" - NACL_PRId32 ")\n", pp_error)); - if (pp_error != PP_ERROR_FILEEXISTS && pp_error != PP_OK) { - // Directory did not exist and could not be created. - if (pp_error == PP_ERROR_NOACCESS) { - ReportPpapiError( - ERROR_PNACL_CACHE_DIRECTORY_CREATE, - pp_error, - "PNaCl translation cache directory creation/check failed " - "(no access)."); - return; - } - ReportPpapiError( - ERROR_PNACL_CACHE_DIRECTORY_CREATE, - pp_error, - "PNaCl translation cache directory creation/check failed."); - return; - } OpenBitcodeStream(); } @@ -819,14 +489,6 @@ void PnaclCoordinator::OpenBitcodeStream() { "PnaclCoordinator: could not allocate translation thread."); return; } - if (!use_new_cache_) { - // We also want to open the object file now so the - // translator can start writing to it during streaming translation. - obj_file_.reset(new TempFile(plugin_)); - pp::CompletionCallback obj_cb = - callback_factory_.NewCallback(&PnaclCoordinator::ObjectFileDidOpen); - obj_file_->Open(obj_cb, true); - } pp::CompletionCallback cb = callback_factory_.NewCallback(&PnaclCoordinator::BitcodeStreamDidOpen); @@ -841,66 +503,37 @@ void PnaclCoordinator::OpenBitcodeStream() { void PnaclCoordinator::BitcodeStreamDidOpen(int32_t pp_error) { if (pp_error != PP_OK) { BitcodeStreamDidFinish(pp_error); - // In the new cache case, we have not spun up the translation process yet, - // so we need to call TranslateFinished here. - if (use_new_cache_) - TranslateFinished(pp_error); + // We have not spun up the translation process yet, so we need to call + // TranslateFinished here. + TranslateFinished(pp_error); return; } - if (!off_the_record_ || use_new_cache_) { - // Get the cache key and try to open an existing entry. - nacl::string headers = streaming_downloader_->GetResponseHeaders(); - NaClHttpResponseHeaders parser; - parser.Parse(headers); - nacl::string cache_validators = parser.GetCacheValidators(); - if (parser.CacheControlNoStore() || cache_validators.empty()) { - // We can't cache in this case. - pnacl_options_.set_cache_validators(""); - CachedFileDidOpen(PP_ERROR_FAILED); - return; - } else { - nacl::string url = streaming_downloader_->url(); - // For now, combine the cache_validators + the URL as the key. - // When we change the cache backend to be not-origin-specific - // we should send the URL separately, and check in the browser's - // RenderViewHost / SiteInstance's IsSameWebsite() to prevent - // people from forging the URL for a different origin. - pnacl_options_.set_cache_validators(cache_validators + url); - } - if (use_new_cache_) { - pp::CompletionCallback cb = - callback_factory_.NewCallback(&PnaclCoordinator::NexeFdDidOpen); - int32_t nexe_fd_err = - plugin_->nacl_interface()->GetNexeFd( - plugin_->pp_instance(), - streaming_downloader_->url().c_str(), - // TODO(dschuff): Get this value from the pnacl json file after it - // rolls in from NaCl. - 1, - pnacl_options_.opt_level(), - parser.GetHeader("last-modified").c_str(), - parser.GetHeader("etag").c_str(), - &is_cache_hit_, - &nexe_handle_, - cb.pp_completion_callback()); - if (nexe_fd_err < PP_OK_COMPLETIONPENDING) { - ReportPpapiError(ERROR_PNACL_CREATE_TEMP, nexe_fd_err, - nacl::string("Call to GetNexeFd failed")); - return; - } - } else { - cached_nexe_file_.reset(new LocalTempFile( - plugin_, file_system_.get(), - nacl::string(kPnaclTempDir), - pnacl_options_.GetCacheKey())); - pp::CompletionCallback cb = - callback_factory_.NewCallback(&PnaclCoordinator::CachedFileDidOpen); - cached_nexe_file_->OpenRead(cb); - } - } else { - // No cache case. - CachedFileDidOpen(PP_ERROR_FAILED); + // Get the cache key and try to open an existing entry. + nacl::string headers = streaming_downloader_->GetResponseHeaders(); + NaClHttpResponseHeaders parser; + parser.Parse(headers); + + temp_nexe_file_.reset(new TempFile(plugin_)); + pp::CompletionCallback cb = + callback_factory_.NewCallback(&PnaclCoordinator::NexeFdDidOpen); + int32_t nexe_fd_err = + plugin_->nacl_interface()->GetNexeFd( + plugin_->pp_instance(), + streaming_downloader_->url().c_str(), + // TODO(dschuff): Get this value from the pnacl json file after it + // rolls in from NaCl. + 1, + pnacl_options_.opt_level(), + parser.GetHeader("last-modified").c_str(), + parser.GetHeader("etag").c_str(), + PP_FromBool(parser.CacheControlNoStore()), + &is_cache_hit_, + temp_nexe_file_->existing_handle(), + cb.pp_completion_callback()); + if (nexe_fd_err < PP_OK_COMPLETIONPENDING) { + ReportPpapiError(ERROR_PNACL_CREATE_TEMP, nexe_fd_err, + nacl::string("Call to GetNexeFd failed")); } } @@ -908,14 +541,14 @@ void PnaclCoordinator::NexeFdDidOpen(int32_t pp_error) { PLUGIN_PRINTF(("PnaclCoordinator::NexeFdDidOpen (pp_error=%" NACL_PRId32 ", hit=%d, handle=%d)\n", pp_error, is_cache_hit_ == PP_TRUE, - nexe_handle_)); + *temp_nexe_file_->existing_handle())); if (pp_error < PP_OK) { ReportPpapiError(ERROR_PNACL_CREATE_TEMP, pp_error, nacl::string("GetNexeFd failed")); return; } - temp_nexe_file_.reset(new TempFile(plugin_)); - if (!temp_nexe_file_->SetExistingFd(nexe_handle_)) { + + if (*temp_nexe_file_->existing_handle() == PP_kInvalidFileHandle) { ReportNonPpapiError( ERROR_PNACL_CREATE_TEMP, nacl::string( @@ -949,25 +582,6 @@ void PnaclCoordinator::NexeFdDidOpen(int32_t pp_error) { } } -void PnaclCoordinator::CachedFileDidOpen(int32_t pp_error) { - PLUGIN_PRINTF(("PnaclCoordinator::CachedFileDidOpen (pp_error=%" - NACL_PRId32 ")\n", pp_error)); - if (pp_error == PP_OK) { - // Cache hit -- no need to stream the rest of the file. - streaming_downloader_.reset(NULL); - HistogramEnumerateTranslationCache(true); - NexeReadDidOpen(PP_OK); - return; - } - // Otherwise, the cache file is missing so we must translate. - HistogramEnumerateTranslationCache(false); - - // Continue streaming. - pp::CompletionCallback cb = - callback_factory_.NewCallback(&PnaclCoordinator::BitcodeStreamDidFinish); - streaming_downloader_->FinishStreaming(cb); -} - void PnaclCoordinator::BitcodeStreamDidFinish(int32_t pp_error) { PLUGIN_PRINTF(("PnaclCoordinator::BitcodeStreamDidFinish (pp_error=%" NACL_PRId32 ")\n", pp_error)); @@ -988,11 +602,6 @@ void PnaclCoordinator::BitcodeStreamDidFinish(int32_t pp_error) { ss << "PnaclCoordinator: pexe load failed (pp_error=" << pp_error << ")."; error_info_.SetReport(ERROR_PNACL_PEXE_FETCH_OTHER, ss.str()); } - if (use_new_cache_) { - plugin_->nacl_interface()->ReportTranslationFinished( - plugin_->pp_instance(), - PP_FALSE); - } translate_thread_->AbortSubprocesses(); } else { // Compare download completion pct (100% now), to compile completion pct. @@ -1067,19 +676,10 @@ void PnaclCoordinator::ObjectFileDidOpen(int32_t pp_error) { ReportPpapiError(ERROR_PNACL_CREATE_TEMP, pp_error, "Failed to open scratch object file."); - if (use_new_cache_) { - plugin_->nacl_interface()->ReportTranslationFinished( - plugin_->pp_instance(), - PP_FALSE); - } return; } // Open the nexe file for connecting ld and sel_ldr. // Start translation when done with this last step of setup! - if (!use_new_cache_) - // In the new cache case, the TempFile has already been created. - temp_nexe_file_.reset(new TempFile(plugin_)); - pp::CompletionCallback cb = callback_factory_.NewCallback(&PnaclCoordinator::RunTranslate); temp_nexe_file_->Open(cb, true); diff --git a/chromium/ppapi/native_client/src/trusted/plugin/pnacl_coordinator.h b/chromium/ppapi/native_client/src/trusted/plugin/pnacl_coordinator.h index 42f12077797..97828646a5d 100644 --- a/chromium/ppapi/native_client/src/trusted/plugin/pnacl_coordinator.h +++ b/chromium/ppapi/native_client/src/trusted/plugin/pnacl_coordinator.h @@ -15,16 +15,10 @@ #include "native_client/src/shared/srpc/nacl_srpc.h" #include "native_client/src/trusted/desc/nacl_desc_wrapper.h" -#include "ppapi/c/pp_file_info.h" -#include "ppapi/c/trusted/ppb_file_io_trusted.h" #include "ppapi/cpp/completion_callback.h" -#include "ppapi/cpp/file_io.h" -#include "ppapi/cpp/file_ref.h" -#include "ppapi/cpp/file_system.h" #include "ppapi/native_client/src/trusted/plugin/callback_source.h" #include "ppapi/native_client/src/trusted/plugin/file_downloader.h" -#include "ppapi/native_client/src/trusted/plugin/local_temp_file.h" #include "ppapi/native_client/src/trusted/plugin/nacl_subprocess.h" #include "ppapi/native_client/src/trusted/plugin/plugin_error.h" #include "ppapi/native_client/src/trusted/plugin/pnacl_options.h" @@ -94,7 +88,7 @@ class PnaclCoordinator: public CallbackSource<FileStreamData> { // Call this to take ownership of the FD of the translated nexe after // BitcodeToNative has completed (and the finish_callback called). - nacl::DescWrapper* ReleaseTranslatedFD() { return translated_fd_.release(); } + nacl::DescWrapper* ReleaseTranslatedFD(); // Run |translate_notify_callback_| with an error condition that is not // PPAPI specific. Also set ErrorInfo report. @@ -156,10 +150,6 @@ class PnaclCoordinator: public CallbackSource<FileStreamData> { // Callbacks for temporary file related stages. // They are invoked from ResourcesDidLoad and proceed in declaration order. - // Invoked when the temporary file system is successfully opened in PPAPI. - void FileSystemDidOpen(int32_t pp_error); - // Invoked after we are sure the PNaCl temporary directory exists. - void DirectoryWasCreated(int32_t pp_error); // Invoke to issue a GET request for bitcode. void OpenBitcodeStream(); // Invoked when we've started an URL fetch for the pexe to check for @@ -168,8 +158,6 @@ class PnaclCoordinator: public CallbackSource<FileStreamData> { // Invoked when we've gotten a temp FD for the nexe, either with the nexe // data, or a writeable fd to save to. void NexeFdDidOpen(int32_t pp_error); - // Invoked after we have checked the PNaCl cache for a translated version. - void CachedFileDidOpen(int32_t pp_error); // Invoked when a pexe data chunk arrives (when using streaming translation) void BitcodeStreamGotData(int32_t pp_error, FileStreamData data); // Invoked when a pexe data chunk is compiled. @@ -186,21 +174,6 @@ class PnaclCoordinator: public CallbackSource<FileStreamData> { // Invoked when translation is finished. void TranslateFinished(int32_t pp_error); - // If the cache is enabled, open a cache file for write, then copy - // the nexe data from temp_nexe_file_ to> cached_nexe_file_. - // Once the copy is done, we commit it to the cache by renaming the - // cache file to the final name. - void CachedNexeOpenedForWrite(int32_t pp_error); - void DidCopyNexeToCachePartial(int32_t pp_error, int32_t num_read_prev, - int64_t cur_offset); - void NexeWasCopiedToCache(int32_t pp_error); - // If the copy of the nexe to the not-yet-committed-to-cache file - // failed after partial writes, we attempt to delete the partially written - // file. This callback is invoked when the delete is completed. - void CorruptCacheFileWasDeleted(int32_t delete_pp_error, - int32_t orig_pp_error); - // Invoked when the nexe_file_ temporary has been renamed to the nexe name. - void NexeFileWasRenamed(int32_t pp_error); // Invoked when the read descriptor for nexe_file_ is created. void NexeReadDidOpen(int32_t pp_error); @@ -212,24 +185,22 @@ class PnaclCoordinator: public CallbackSource<FileStreamData> { Plugin* plugin_; pp::CompletionCallback translate_notify_callback_; + // Set to true when the translation (if applicable) is finished and the nexe + // file is loaded, (or when there was an error), and the browser has been + // notified via ReportTranslationFinished. If it is not set before + // plugin/coordinator destruction, the destructor will call + // ReportTranslationFinished. + bool translation_finished_reported_; // Threadsafety is required to support file lookups. pp::CompletionCallbackFactory<PnaclCoordinator, pp::ThreadSafeThreadTraits> callback_factory_; - // Nexe from the final native Link. - nacl::scoped_ptr<nacl::DescWrapper> translated_fd_; - - // Translation creates local temporary files. - nacl::scoped_ptr<pp::FileSystem> file_system_; // The manifest used by resource loading and ld + llc's reverse service // to look up objects and libraries. nacl::scoped_ptr<const Manifest> manifest_; // An auxiliary class that manages downloaded resources (llc and ld nexes). nacl::scoped_ptr<PnaclResources> resources_; - // State used for querying the temporary directory. - nacl::scoped_ptr<pp::FileRef> dir_ref_; - // The URL for the pexe file. nacl::string pexe_url_; // Options for translation. @@ -239,19 +210,9 @@ class PnaclCoordinator: public CallbackSource<FileStreamData> { nacl::scoped_ptr<TempFile> obj_file_; // Translated nexe file, produced by the linker. nacl::scoped_ptr<TempFile> temp_nexe_file_; - // Cached nexe file, consumed by sel_ldr. This will be NULL if we do - // not have a writeable cache file. That is currently the case when - // off_the_record_ is true. - nacl::scoped_ptr<LocalTempFile> cached_nexe_file_; - // True if the new cache flow is enabled. Currently set by an environment - // variable on construction. TODO(dschuff): remove old cache stuff. - bool use_new_cache_; // Passed to the browser, which sets it to true if there is a translation // cache hit. PP_Bool is_cache_hit_; - // Passed to the browser, which sets it to the handle for the nexe file - // (either the translated nexe from the cache, or a temp file to write to). - PP_FileHandle nexe_handle_; // Downloader for streaming translation nacl::scoped_ptr<FileDownloader> streaming_downloader_; diff --git a/chromium/ppapi/native_client/src/trusted/plugin/pnacl_options.cc b/chromium/ppapi/native_client/src/trusted/plugin/pnacl_options.cc index 0e684bb58e1..6985883175e 100644 --- a/chromium/ppapi/native_client/src/trusted/plugin/pnacl_options.cc +++ b/chromium/ppapi/native_client/src/trusted/plugin/pnacl_options.cc @@ -9,21 +9,6 @@ #include "native_client/src/include/nacl_string.h" -namespace { - -nacl::string ReplaceBadFSChars(nacl::string str, - const nacl::string& bad_chars, - const nacl::string& replacement) { - size_t replace_pos = str.find_first_of(bad_chars); - while (replace_pos != nacl::string::npos) { - str = str.replace(replace_pos, 1, replacement); - replace_pos = str.find_first_of(bad_chars); - } - return str; -} - -} // namespace - namespace plugin { PnaclOptions::PnaclOptions() : translate_(false), opt_level_(2) { } @@ -31,25 +16,6 @@ PnaclOptions::PnaclOptions() : translate_(false), opt_level_(2) { } PnaclOptions::~PnaclOptions() { } -nacl::string PnaclOptions::GetCacheKey() const { - // TODO(jvoung): We need to read the PNaCl translator's manifest - // to grab the NaCl / PNaCl ABI version too. - nacl::stringstream ss; - // Cast opt_level_ as int so that it doesn't think it's a char. - ss << "-O:" << static_cast<int>(opt_level_) - << ";cache_validators:" << cache_validators_; - // HTML5 FileSystem-based cache does not allow some characters which - // may appear in URLs, ETags, or Last-Modified times. Once we move to - // our own cache-backend, it will be more tolerant of various cache - // key values. - // See: http://dev.w3.org/2009/dap/file-system/file-dir-sys.html#naming-restrictions - nacl::string key = ss.str(); - key = ReplaceBadFSChars(key, "/", "_FWDSLASH_"); - key = ReplaceBadFSChars(key, "\\", "_BCKSLASH_"); - key = ReplaceBadFSChars(key, "\0", "_NULL_"); - return key; -} - void PnaclOptions::set_opt_level(int32_t l) { if (l <= 0) { opt_level_ = 0; diff --git a/chromium/ppapi/native_client/src/trusted/plugin/pnacl_options.h b/chromium/ppapi/native_client/src/trusted/plugin/pnacl_options.h index f998b2c46ce..df2a9aa171f 100644 --- a/chromium/ppapi/native_client/src/trusted/plugin/pnacl_options.h +++ b/chromium/ppapi/native_client/src/trusted/plugin/pnacl_options.h @@ -19,16 +19,6 @@ class PnaclOptions { PnaclOptions(); ~PnaclOptions(); - // Return |true| if PNaCl is allowed to cache. - // PNaCl is allowed to cache if the server sends cache validators - // like Last-Modified time or ETags in the HTTP response, and - // it does not send "Cache-Control: no-store". - bool HasCacheKey() const { return (!cache_validators_.empty()); } - - // Return the cache key (which takes into account the bitcode hash, - // as well as the commandline options). - nacl::string GetCacheKey() const; - // Return a character array of \x00 delimited commandline options. std::vector<char> GetOptCommandline() const; @@ -38,17 +28,12 @@ class PnaclOptions { int32_t opt_level() const { return opt_level_; } void set_opt_level(int32_t l); - void set_cache_validators(const nacl::string& c) { - cache_validators_ = c; - } - private: // NOTE: There are users of this class that use the copy constructor. // Currently the default copy constructor is good enough, but // double-check that it is the case when more fields are added. bool translate_; int32_t opt_level_; - nacl::string cache_validators_; }; } // namespace plugin; diff --git a/chromium/ppapi/native_client/src/trusted/plugin/pnacl_resources.cc b/chromium/ppapi/native_client/src/trusted/plugin/pnacl_resources.cc index 6ba90c83f1d..d712bc4922e 100644 --- a/chromium/ppapi/native_client/src/trusted/plugin/pnacl_resources.cc +++ b/chromium/ppapi/native_client/src/trusted/plugin/pnacl_resources.cc @@ -121,8 +121,9 @@ void PnaclResources::ReadResourceInfo( // File-open failed. Assume this means that the file is // not actually installed. ReadResourceInfoError( - nacl::string("The Portable Native Client component is not installed" - " or has been disabled.")); + nacl::string("The Portable Native Client (pnacl) component is not " + "installed. Please consult chrome://components for more " + "information.")); return; } @@ -222,8 +223,9 @@ void PnaclResources::StartLoad( // ReadResourceInfo() should happen first, and error out. coordinator_->ReportNonPpapiError( ERROR_PNACL_RESOURCE_FETCH, - nacl::string("The Portable Native Client component is not installed " - "or has been disabled. Cannot open file: ") + filename); + nacl::string("The Portable Native Client (pnacl) component is not " + "installed. Please consult chrome://components for more " + "information.")); result = PP_ERROR_FILENOTFOUND; break; } else { diff --git a/chromium/ppapi/native_client/src/trusted/plugin/pnacl_translate_thread.cc b/chromium/ppapi/native_client/src/trusted/plugin/pnacl_translate_thread.cc index b27bad16590..d51efe45f6b 100644 --- a/chromium/ppapi/native_client/src/trusted/plugin/pnacl_translate_thread.cc +++ b/chromium/ppapi/native_client/src/trusted/plugin/pnacl_translate_thread.cc @@ -200,15 +200,25 @@ void PnaclTranslateThread::DoTranslate() { ¶ms, &data[0], data.size())) { - TranslateFailed(ERROR_PNACL_LLC_INTERNAL, - "Compile stream chunk failed."); - return; + if (llc_subprocess_->srpc_client()->GetLastError() != + NACL_SRPC_RESULT_APP_ERROR) { + // If the error was reported by the translator, then we fall through + // and call StreamEnd, which returns a string describing the error, + // which we can then send to the Javascript console. Otherwise just + // fail here, since the translator has probably crashed or asserted. + TranslateFailed(ERROR_PNACL_LLC_INTERNAL, + "Compile stream chunk failed. " + "The PNaCl translator has probably crashed."); + return; + } + break; + } else { + PLUGIN_PRINTF(("StreamChunk Successful\n")); + core->CallOnMainThread( + 0, + coordinator_->GetCompileProgressCallback(data.size()), + PP_OK); } - PLUGIN_PRINTF(("StreamChunk Successful\n")); - core->CallOnMainThread( - 0, - coordinator_->GetCompileProgressCallback(data.size()), - PP_OK); } else { NaClXMutexUnlock(&cond_mu_); } diff --git a/chromium/ppapi/native_client/src/trusted/plugin/sel_ldr_launcher_chrome.cc b/chromium/ppapi/native_client/src/trusted/plugin/sel_ldr_launcher_chrome.cc index 2714eac8668..486696bce53 100644 --- a/chromium/ppapi/native_client/src/trusted/plugin/sel_ldr_launcher_chrome.cc +++ b/chromium/ppapi/native_client/src/trusted/plugin/sel_ldr_launcher_chrome.cc @@ -24,6 +24,7 @@ bool SelLdrLauncherChrome::Start(PP_Instance instance, bool enable_ppapi_dev, bool enable_dyncode_syscalls, bool enable_exception_handling, + bool enable_crash_throttling, nacl::string* error_message) { *error_message = ""; if (!launch_nacl_process) @@ -37,6 +38,7 @@ bool SelLdrLauncherChrome::Start(PP_Instance instance, PP_FromBool(enable_ppapi_dev), PP_FromBool(enable_dyncode_syscalls), PP_FromBool(enable_exception_handling), + PP_FromBool(enable_crash_throttling), &channel_, &var_error_message) != PP_EXTERNAL_PLUGIN_OK) { pp::Var var_error_message_cpp(pp::PASS_REF, var_error_message); diff --git a/chromium/ppapi/native_client/src/trusted/plugin/sel_ldr_launcher_chrome.h b/chromium/ppapi/native_client/src/trusted/plugin/sel_ldr_launcher_chrome.h index a64c66b46b9..69c171601c0 100644 --- a/chromium/ppapi/native_client/src/trusted/plugin/sel_ldr_launcher_chrome.h +++ b/chromium/ppapi/native_client/src/trusted/plugin/sel_ldr_launcher_chrome.h @@ -20,6 +20,7 @@ class SelLdrLauncherChrome : public nacl::SelLdrLauncherBase { bool enable_ppapi_dev, bool enable_dyncode_syscalls, bool enable_exception_handling, + bool enable_crash_throttling, nacl::string* error_message); }; diff --git a/chromium/ppapi/native_client/src/trusted/plugin/service_runtime.cc b/chromium/ppapi/native_client/src/trusted/plugin/service_runtime.cc index 2b43b2e6e84..27957862325 100644 --- a/chromium/ppapi/native_client/src/trusted/plugin/service_runtime.cc +++ b/chromium/ppapi/native_client/src/trusted/plugin/service_runtime.cc @@ -44,10 +44,8 @@ #include "native_client/src/trusted/validator/nacl_file_info.h" #include "ppapi/c/pp_errors.h" -#include "ppapi/c/trusted/ppb_file_io_trusted.h" #include "ppapi/cpp/core.h" #include "ppapi/cpp/completion_callback.h" -#include "ppapi/cpp/file_io.h" #include "ppapi/native_client/src/trusted/plugin/manifest.h" #include "ppapi/native_client/src/trusted/plugin/plugin.h" @@ -61,8 +59,10 @@ namespace { // For doing crude quota enforcement on writes to temp files. -// We do not allow a temp file bigger than 512 MB for now. -const uint64_t kMaxTempQuota = 0x20000000; +// We do not allow a temp file bigger than 128 MB for now. +// There is currently a limit of 32M for nexe text size, so 128M +// should be plenty for static data +const int64_t kMaxTempQuota = 0x8000000; } // namespace @@ -337,29 +337,19 @@ void PluginReverseInterface::OpenManifestEntry_MainThreadContinuation( NaClLog(4, "OpenManifestEntry_MainThreadContinuation: " "pulling down and translating.\n"); - if (plugin_->nacl_interface()->IsPnaclEnabled()) { - pp::CompletionCallback translate_callback = - WeakRefNewCallback( - anchor_, - this, - &PluginReverseInterface::BitcodeTranslate_MainThreadContinuation, - open_cont); - // Will always call the callback on success or failure. - pnacl_coordinator_.reset( - PnaclCoordinator::BitcodeToNative(plugin_, - mapped_url, - pnacl_options, - translate_callback)); - } else { - nacl::MutexLocker take(&mu_); - *p->op_complete_ptr = true; // done... - p->file_info->desc = -1; // but failed. - p->error_info->SetReport(ERROR_PNACL_NOT_ENABLED, - "ServiceRuntime: GetPnaclFd failed -- pnacl not " - "enabled with --enable-pnacl."); - NaClXCondVarBroadcast(&cv_); - return; - } + CHECK(plugin_->nacl_interface()->IsPnaclEnabled()); + pp::CompletionCallback translate_callback = + WeakRefNewCallback( + anchor_, + this, + &PluginReverseInterface::BitcodeTranslate_MainThreadContinuation, + open_cont); + // Will always call the callback on success or failure. + pnacl_coordinator_.reset( + PnaclCoordinator::BitcodeToNative(plugin_, + mapped_url, + pnacl_options, + translate_callback)); } // p is deleted automatically } @@ -485,142 +475,36 @@ void PluginReverseInterface::ReportExitStatus(int exit_status) { service_runtime_->set_exit_status(exit_status); } -void PluginReverseInterface::QuotaRequest_MainThreadContinuation( - QuotaRequest* request, - int32_t err) { - if (err != PP_OK) { - return; - } - - switch (request->data.type) { - case plugin::PepperQuotaType: { - const PPB_FileIOTrusted* file_io_trusted = - static_cast<const PPB_FileIOTrusted*>( - pp::Module::Get()->GetBrowserInterface( - PPB_FILEIOTRUSTED_INTERFACE)); - // Copy the request object because this one will be deleted on return. - // copy ctor! - QuotaRequest* cont_for_response = new QuotaRequest(*request); - pp::CompletionCallback quota_cc = WeakRefNewCallback( - anchor_, - this, - &PluginReverseInterface::QuotaRequest_MainThreadResponse, - cont_for_response); - file_io_trusted->WillWrite(request->data.resource, - request->offset, - // TODO(sehr): remove need for cast. - // Unify WillWrite interface vs Quota request. - nacl::assert_cast<int32_t>( - request->bytes_requested), - quota_cc.pp_completion_callback()); - break; - } - case plugin::TempQuotaType: { - uint64_t len = request->offset + request->bytes_requested; - nacl::MutexLocker take(&mu_); - // Do some crude quota enforcement. - if (len > kMaxTempQuota) { - *request->bytes_granted = 0; - } else { - *request->bytes_granted = request->bytes_requested; - } - *request->op_complete_ptr = true; - NaClXCondVarBroadcast(&cv_); - break; - } - } - // request automatically deleted -} - -void PluginReverseInterface::QuotaRequest_MainThreadResponse( - QuotaRequest* request, - int32_t err) { - NaClLog(4, - "PluginReverseInterface::QuotaRequest_MainThreadResponse:" - " (resource=%" NACL_PRIx32 ", offset=%" NACL_PRId64 ", requested=%" - NACL_PRId64 ", err=%" NACL_PRId32 ")\n", - request->data.resource, - request->offset, request->bytes_requested, err); - nacl::MutexLocker take(&mu_); - if (err >= PP_OK) { - *request->bytes_granted = err; - } else { - *request->bytes_granted = 0; - } - *request->op_complete_ptr = true; - NaClXCondVarBroadcast(&cv_); - // request automatically deleted -} - int64_t PluginReverseInterface::RequestQuotaForWrite( nacl::string file_id, int64_t offset, int64_t bytes_to_write) { NaClLog(4, "PluginReverseInterface::RequestQuotaForWrite:" " (file_id='%s', offset=%" NACL_PRId64 ", bytes_to_write=%" NACL_PRId64 ")\n", file_id.c_str(), offset, bytes_to_write); - QuotaData quota_data; - { - nacl::MutexLocker take(&mu_); - uint64_t file_key = STRTOULL(file_id.c_str(), NULL, 10); - if (quota_map_.find(file_key) == quota_map_.end()) { - // Look up failed to find the requested quota managed resource. - NaClLog(4, "PluginReverseInterface::RequestQuotaForWrite: failed...\n"); - return 0; - } - quota_data = quota_map_[file_key]; + uint64_t file_key = STRTOULL(file_id.c_str(), NULL, 10); + nacl::MutexLocker take(&mu_); + if (quota_files_.count(file_key) == 0) { + // Look up failed to find the requested quota managed resource. + NaClLog(4, "PluginReverseInterface::RequestQuotaForWrite: failed...\n"); + return 0; } - // Variables set by requesting quota. - int64_t quota_granted = 0; - bool op_complete = false; - QuotaRequest* continuation = - new QuotaRequest(quota_data, offset, bytes_to_write, "a_granted, - &op_complete); - // The reverse service is running on a background thread and the PPAPI quota - // methods must be invoked only from the main thread. - plugin::WeakRefCallOnMainThread( - anchor_, - 0, /* delay in ms */ - this, - &plugin::PluginReverseInterface::QuotaRequest_MainThreadContinuation, - continuation); - // Wait for the main thread to request quota and signal completion. - // It is also possible that the main thread will signal shut down. - bool shutting_down; - do { - nacl::MutexLocker take(&mu_); - for (;;) { - shutting_down = shutting_down_; - if (op_complete || shutting_down) { - break; - } - NaClXCondVarWait(&cv_, &mu_); - } - } while (0); - if (shutting_down) return 0; - return quota_granted; -} -void PluginReverseInterface::AddQuotaManagedFile(const nacl::string& file_id, - const pp::FileIO& file_io) { - PP_Resource resource = file_io.pp_resource(); - NaClLog(4, - "PluginReverseInterface::AddQuotaManagedFile: " - "(file_id='%s', file_io_ref=%" NACL_PRIx32 ")\n", - file_id.c_str(), resource); - nacl::MutexLocker take(&mu_); - uint64_t file_key = STRTOULL(file_id.c_str(), NULL, 10); - QuotaData data(plugin::PepperQuotaType, resource); - quota_map_[file_key] = data; + // Because we now only support this interface for tempfiles which are not + // pepper objects, we can just do some crude quota enforcement here rather + // than calling out to pepper from the main thread. + if (offset + bytes_to_write >= kMaxTempQuota) + return 0; + + return bytes_to_write; } void PluginReverseInterface::AddTempQuotaManagedFile( const nacl::string& file_id) { NaClLog(4, "PluginReverseInterface::AddTempQuotaManagedFile: " "(file_id='%s')\n", file_id.c_str()); - nacl::MutexLocker take(&mu_); uint64_t file_key = STRTOULL(file_id.c_str(), NULL, 10); - QuotaData data(plugin::TempQuotaType, 0); - quota_map_[file_key] = data; + nacl::MutexLocker take(&mu_); + quota_files_.insert(file_key); } ServiceRuntime::ServiceRuntime(Plugin* plugin, @@ -736,6 +620,7 @@ bool ServiceRuntime::StartSelLdr(const SelLdrStartParams& params) { params.enable_dev_interfaces, params.enable_dyncode_syscalls, params.enable_exception_handling, + params.enable_crash_throttling, &error_message); if (!started) { NaClLog(LOG_ERROR, "ServiceRuntime::Start (start failed)\n"); diff --git a/chromium/ppapi/native_client/src/trusted/plugin/service_runtime.h b/chromium/ppapi/native_client/src/trusted/plugin/service_runtime.h index ee97710047c..4241737602b 100644 --- a/chromium/ppapi/native_client/src/trusted/plugin/service_runtime.h +++ b/chromium/ppapi/native_client/src/trusted/plugin/service_runtime.h @@ -11,7 +11,7 @@ #ifndef NATIVE_CLIENT_SRC_TRUSTED_PLUGIN_SERVICE_RUNTIME_H_ #define NATIVE_CLIENT_SRC_TRUSTED_PLUGIN_SERVICE_RUNTIME_H_ -#include <map> +#include <set> #include "native_client/src/include/nacl_macros.h" #include "native_client/src/include/nacl_scoped_ptr.h" @@ -56,14 +56,16 @@ struct SelLdrStartParams { bool uses_ppapi, bool enable_dev_interfaces, bool enable_dyncode_syscalls, - bool enable_exception_handling) + bool enable_exception_handling, + bool enable_crash_throttling) : url(url), error_info(error_info), uses_irt(uses_irt), uses_ppapi(uses_ppapi), enable_dev_interfaces(enable_dev_interfaces), enable_dyncode_syscalls(enable_dyncode_syscalls), - enable_exception_handling(enable_exception_handling) { + enable_exception_handling(enable_exception_handling), + enable_crash_throttling(enable_crash_throttling) { } nacl::string url; ErrorInfo* error_info; @@ -72,6 +74,7 @@ struct SelLdrStartParams { bool enable_dev_interfaces; bool enable_dyncode_syscalls; bool enable_exception_handling; + bool enable_crash_throttling; }; // Callback resources are essentially our continuation state. @@ -120,35 +123,20 @@ struct CloseManifestEntryResource { bool* op_result_ptr; }; -enum QuotaDataType { - PepperQuotaType, - TempQuotaType -}; - -struct QuotaData { - QuotaData(QuotaDataType type_, PP_Resource resource_) - : type(type_), resource(resource_) {} - QuotaData() - : type(PepperQuotaType), resource(0) {} - - QuotaDataType type; - PP_Resource resource; -}; - struct QuotaRequest { public: - QuotaRequest(QuotaData quota_data, + QuotaRequest(PP_Resource pp_resource, int64_t start_offset, int64_t quota_bytes_requested, int64_t* quota_bytes_granted, bool* op_complete) - : data(quota_data), + : resource(pp_resource), offset(start_offset), bytes_requested(quota_bytes_requested), bytes_granted(quota_bytes_granted), op_complete_ptr(op_complete) { } - QuotaData data; + PP_Resource resource; int64_t offset; int64_t bytes_requested; int64_t* bytes_granted; @@ -222,14 +210,6 @@ class PluginReverseInterface: public nacl::ReverseInterface { CloseManifestEntryResource* cls, int32_t err); - virtual void QuotaRequest_MainThreadContinuation( - QuotaRequest* request, - int32_t err); - - virtual void QuotaRequest_MainThreadResponse( - QuotaRequest* request, - int32_t err); - private: nacl::WeakRefAnchor* anchor_; // holds a ref Plugin* plugin_; // value may be copied, but should be used only in @@ -238,7 +218,7 @@ class PluginReverseInterface: public nacl::ReverseInterface { ServiceRuntime* service_runtime_; NaClMutex mu_; NaClCondVar cv_; - std::map<int64_t, QuotaData> quota_map_; + std::set<int64_t> quota_files_; bool shutting_down_; nacl::scoped_ptr<PnaclCoordinator> pnacl_coordinator_; diff --git a/chromium/ppapi/native_client/src/trusted/plugin/temporary_file.cc b/chromium/ppapi/native_client/src/trusted/plugin/temporary_file.cc index 46167a14976..2bb65bf510d 100644 --- a/chromium/ppapi/native_client/src/trusted/plugin/temporary_file.cc +++ b/chromium/ppapi/native_client/src/trusted/plugin/temporary_file.cc @@ -37,14 +37,6 @@ TempFile::~TempFile() { PLUGIN_PRINTF(("TempFile::~TempFile\n")); } -bool TempFile::SetExistingFd(PP_FileHandle handle) { - // Check if we got a bad handle or if Open has already been called. - if (handle == PP_kInvalidFileHandle || read_wrapper_.get() != NULL) - return false; - existing_handle_ = handle; - return true; -} - void TempFile::Open(const pp::CompletionCallback& cb, bool writeable) { PLUGIN_PRINTF(("TempFile::Open\n")); PP_FileHandle file_handle; diff --git a/chromium/ppapi/native_client/src/trusted/plugin/temporary_file.h b/chromium/ppapi/native_client/src/trusted/plugin/temporary_file.h index 966945c8afd..09a42502b6b 100644 --- a/chromium/ppapi/native_client/src/trusted/plugin/temporary_file.h +++ b/chromium/ppapi/native_client/src/trusted/plugin/temporary_file.h @@ -41,9 +41,6 @@ class TempFile { explicit TempFile(Plugin* plugin); ~TempFile(); - // Set an existing Fd instead of getting one from the nacl interface on open. - // Must be called before Open. - bool SetExistingFd(PP_FileHandle handle); // Opens a temporary file object and descriptor wrapper referring to the file. // If |writeable| is true, the descriptor will be opened for writing, and // write_wrapper will return a valid pointer, otherwise it will return NULL. @@ -59,6 +56,8 @@ class TempFile { return read_wrapper_.release(); } + PP_FileHandle* existing_handle() { return &existing_handle_; } + // For quota management. const nacl::string identifier() const { return nacl::string(reinterpret_cast<const char*>(identifier_)); diff --git a/chromium/ppapi/native_client/src/untrusted/pnacl_irt_shim/pnacl_shim.c b/chromium/ppapi/native_client/src/untrusted/pnacl_irt_shim/pnacl_shim.c index 8bb17f721db..747d753e6ed 100644 --- a/chromium/ppapi/native_client/src/untrusted/pnacl_irt_shim/pnacl_shim.c +++ b/chromium/ppapi/native_client/src/untrusted/pnacl_irt_shim/pnacl_shim.c @@ -64,6 +64,8 @@ #include "ppapi/c/ppb_mouse_cursor.h" #include "ppapi/c/ppb_mouse_lock.h" #include "ppapi/c/ppb_net_address.h" +#include "ppapi/c/ppb_network_list.h" +#include "ppapi/c/ppb_network_monitor.h" #include "ppapi/c/ppb_network_proxy.h" #include "ppapi/c/ppb_tcp_socket.h" #include "ppapi/c/ppb_text_input_controller.h" @@ -95,13 +97,12 @@ #include "ppapi/c/private/ppb_flash_menu.h" #include "ppapi/c/private/ppb_flash_message_loop.h" #include "ppapi/c/private/ppb_flash_print.h" -#include "ppapi/c/private/ppb_gpu_blacklist_private.h" #include "ppapi/c/private/ppb_host_resolver_private.h" #include "ppapi/c/private/ppb_instance_private.h" #include "ppapi/c/private/ppb_nacl_private.h" #include "ppapi/c/private/ppb_net_address_private.h" -#include "ppapi/c/private/ppb_network_list_private.h" -#include "ppapi/c/private/ppb_network_monitor_private.h" +#include "ppapi/c/private/ppb_output_protection_private.h" +#include "ppapi/c/private/ppb_platform_verification_private.h" #include "ppapi/c/private/ppb_talk_private.h" #include "ppapi/c/private/ppb_tcp_server_socket_private.h" #include "ppapi/c/private/ppb_tcp_socket_private.h" @@ -155,8 +156,11 @@ static struct __PnaclWrapperInfo Pnacl_WrapperInfo_PPB_MessageLoop_1_0; static struct __PnaclWrapperInfo Pnacl_WrapperInfo_PPB_Messaging_1_0; static struct __PnaclWrapperInfo Pnacl_WrapperInfo_PPB_MouseLock_1_0; static struct __PnaclWrapperInfo Pnacl_WrapperInfo_PPB_NetAddress_1_0; +static struct __PnaclWrapperInfo Pnacl_WrapperInfo_PPB_NetworkList_1_0; +static struct __PnaclWrapperInfo Pnacl_WrapperInfo_PPB_NetworkMonitor_1_0; static struct __PnaclWrapperInfo Pnacl_WrapperInfo_PPB_NetworkProxy_1_0; static struct __PnaclWrapperInfo Pnacl_WrapperInfo_PPB_TCPSocket_1_0; +static struct __PnaclWrapperInfo Pnacl_WrapperInfo_PPB_TCPSocket_1_1; static struct __PnaclWrapperInfo Pnacl_WrapperInfo_PPB_TextInputController_1_0; static struct __PnaclWrapperInfo Pnacl_WrapperInfo_PPB_UDPSocket_1_0; static struct __PnaclWrapperInfo Pnacl_WrapperInfo_PPB_URLLoader_1_0; @@ -178,17 +182,19 @@ static struct __PnaclWrapperInfo Pnacl_WrapperInfo_PPB_FileChooser_Dev_0_6; static struct __PnaclWrapperInfo Pnacl_WrapperInfo_PPB_Font_Dev_0_6; static struct __PnaclWrapperInfo Pnacl_WrapperInfo_PPB_IMEInputEvent_Dev_0_1; static struct __PnaclWrapperInfo Pnacl_WrapperInfo_PPB_IMEInputEvent_Dev_0_2; +static struct __PnaclWrapperInfo Pnacl_WrapperInfo_PPB_KeyboardInputEvent_Dev_0_2; static struct __PnaclWrapperInfo Pnacl_WrapperInfo_PPB_Printing_Dev_0_7; static struct __PnaclWrapperInfo Pnacl_WrapperInfo_PPB_Testing_Dev_0_9; static struct __PnaclWrapperInfo Pnacl_WrapperInfo_PPB_Testing_Dev_0_91; static struct __PnaclWrapperInfo Pnacl_WrapperInfo_PPB_Testing_Dev_0_92; static struct __PnaclWrapperInfo Pnacl_WrapperInfo_PPB_TrueTypeFont_Dev_0_1; static struct __PnaclWrapperInfo Pnacl_WrapperInfo_PPB_URLUtil_Dev_0_6; +static struct __PnaclWrapperInfo Pnacl_WrapperInfo_PPB_URLUtil_Dev_0_7; static struct __PnaclWrapperInfo Pnacl_WrapperInfo_PPB_VideoCapture_Dev_0_2; static struct __PnaclWrapperInfo Pnacl_WrapperInfo_PPB_VideoCapture_Dev_0_3; static struct __PnaclWrapperInfo Pnacl_WrapperInfo_PPB_VideoDecoder_Dev_0_16; static struct __PnaclWrapperInfo Pnacl_WrapperInfo_PPP_Selection_Dev_0_3; -static struct __PnaclWrapperInfo Pnacl_WrapperInfo_PPB_ContentDecryptor_Private_0_6; +static struct __PnaclWrapperInfo Pnacl_WrapperInfo_PPB_ContentDecryptor_Private_0_7; static struct __PnaclWrapperInfo Pnacl_WrapperInfo_PPB_Ext_CrxFileSystem_Private_0_1; static struct __PnaclWrapperInfo Pnacl_WrapperInfo_PPB_FileIO_Private_0_1; static struct __PnaclWrapperInfo Pnacl_WrapperInfo_PPB_FileRefPrivate_0_1; @@ -207,7 +213,8 @@ static struct __PnaclWrapperInfo Pnacl_WrapperInfo_PPB_NaCl_Private_1_0; static struct __PnaclWrapperInfo Pnacl_WrapperInfo_PPB_NetAddress_Private_0_1; static struct __PnaclWrapperInfo Pnacl_WrapperInfo_PPB_NetAddress_Private_1_0; static struct __PnaclWrapperInfo Pnacl_WrapperInfo_PPB_NetAddress_Private_1_1; -static struct __PnaclWrapperInfo Pnacl_WrapperInfo_PPB_NetworkList_Private_0_2; +static struct __PnaclWrapperInfo Pnacl_WrapperInfo_PPB_OutputProtection_Private_0_1; +static struct __PnaclWrapperInfo Pnacl_WrapperInfo_PPB_PlatformVerification_Private_0_1; static struct __PnaclWrapperInfo Pnacl_WrapperInfo_PPB_Talk_Private_1_0; static struct __PnaclWrapperInfo Pnacl_WrapperInfo_PPB_Talk_Private_2_0; static struct __PnaclWrapperInfo Pnacl_WrapperInfo_PPB_TCPServerSocket_Private_0_1; @@ -222,7 +229,7 @@ static struct __PnaclWrapperInfo Pnacl_WrapperInfo_PPB_UMA_Private_0_1; static struct __PnaclWrapperInfo Pnacl_WrapperInfo_PPB_VideoDestination_Private_0_1; static struct __PnaclWrapperInfo Pnacl_WrapperInfo_PPB_VideoSource_Private_0_1; static struct __PnaclWrapperInfo Pnacl_WrapperInfo_PPB_X509Certificate_Private_0_1; -static struct __PnaclWrapperInfo Pnacl_WrapperInfo_PPP_ContentDecryptor_Private_0_6; +static struct __PnaclWrapperInfo Pnacl_WrapperInfo_PPP_ContentDecryptor_Private_0_7; static struct __PnaclWrapperInfo Pnacl_WrapperInfo_PPP_Instance_Private_0_1; static struct __PnaclWrapperInfo Pnacl_WrapperInfo_PPB_Ext_Alarms_Dev_0_1; static struct __PnaclWrapperInfo Pnacl_WrapperInfo_PPB_Ext_Events_Dev_0_1; @@ -232,6 +239,8 @@ static struct __PnaclWrapperInfo Pnacl_WrapperInfo_PPB_Ext_Socket_Dev_0_2; /* Not generating wrapper methods for PPB_Audio_1_0 */ +/* Not generating wrapper methods for PPB_Audio_1_1 */ + /* Not generating wrapper methods for PPB_AudioConfig_1_0 */ /* Not generating wrapper methods for PPB_AudioConfig_1_1 */ @@ -1007,6 +1016,69 @@ static PP_Bool Pnacl_M29_PPB_NetAddress_DescribeAsIPv6Address(PP_Resource addr, /* End wrapper methods for PPB_NetAddress_1_0 */ +/* Begin wrapper methods for PPB_NetworkList_1_0 */ + +static PP_Bool Pnacl_M31_PPB_NetworkList_IsNetworkList(PP_Resource resource) { + const struct PPB_NetworkList_1_0 *iface = Pnacl_WrapperInfo_PPB_NetworkList_1_0.real_iface; + return iface->IsNetworkList(resource); +} + +static uint32_t Pnacl_M31_PPB_NetworkList_GetCount(PP_Resource resource) { + const struct PPB_NetworkList_1_0 *iface = Pnacl_WrapperInfo_PPB_NetworkList_1_0.real_iface; + return iface->GetCount(resource); +} + +static void Pnacl_M31_PPB_NetworkList_GetName(struct PP_Var* _struct_result, PP_Resource resource, uint32_t index) { + const struct PPB_NetworkList_1_0 *iface = Pnacl_WrapperInfo_PPB_NetworkList_1_0.real_iface; + *_struct_result = iface->GetName(resource, index); +} + +static PP_NetworkList_Type Pnacl_M31_PPB_NetworkList_GetType(PP_Resource resource, uint32_t index) { + const struct PPB_NetworkList_1_0 *iface = Pnacl_WrapperInfo_PPB_NetworkList_1_0.real_iface; + return iface->GetType(resource, index); +} + +static PP_NetworkList_State Pnacl_M31_PPB_NetworkList_GetState(PP_Resource resource, uint32_t index) { + const struct PPB_NetworkList_1_0 *iface = Pnacl_WrapperInfo_PPB_NetworkList_1_0.real_iface; + return iface->GetState(resource, index); +} + +static int32_t Pnacl_M31_PPB_NetworkList_GetIpAddresses(PP_Resource resource, uint32_t index, struct PP_ArrayOutput* output) { + const struct PPB_NetworkList_1_0 *iface = Pnacl_WrapperInfo_PPB_NetworkList_1_0.real_iface; + return iface->GetIpAddresses(resource, index, *output); +} + +static void Pnacl_M31_PPB_NetworkList_GetDisplayName(struct PP_Var* _struct_result, PP_Resource resource, uint32_t index) { + const struct PPB_NetworkList_1_0 *iface = Pnacl_WrapperInfo_PPB_NetworkList_1_0.real_iface; + *_struct_result = iface->GetDisplayName(resource, index); +} + +static uint32_t Pnacl_M31_PPB_NetworkList_GetMTU(PP_Resource resource, uint32_t index) { + const struct PPB_NetworkList_1_0 *iface = Pnacl_WrapperInfo_PPB_NetworkList_1_0.real_iface; + return iface->GetMTU(resource, index); +} + +/* End wrapper methods for PPB_NetworkList_1_0 */ + +/* Begin wrapper methods for PPB_NetworkMonitor_1_0 */ + +static PP_Resource Pnacl_M31_PPB_NetworkMonitor_Create(PP_Instance instance) { + const struct PPB_NetworkMonitor_1_0 *iface = Pnacl_WrapperInfo_PPB_NetworkMonitor_1_0.real_iface; + return iface->Create(instance); +} + +static int32_t Pnacl_M31_PPB_NetworkMonitor_UpdateNetworkList(PP_Resource network_monitor, PP_Resource* network_list, struct PP_CompletionCallback* callback) { + const struct PPB_NetworkMonitor_1_0 *iface = Pnacl_WrapperInfo_PPB_NetworkMonitor_1_0.real_iface; + return iface->UpdateNetworkList(network_monitor, network_list, *callback); +} + +static PP_Bool Pnacl_M31_PPB_NetworkMonitor_IsNetworkMonitor(PP_Resource resource) { + const struct PPB_NetworkMonitor_1_0 *iface = Pnacl_WrapperInfo_PPB_NetworkMonitor_1_0.real_iface; + return iface->IsNetworkMonitor(resource); +} + +/* End wrapper methods for PPB_NetworkMonitor_1_0 */ + /* Begin wrapper methods for PPB_NetworkProxy_1_0 */ static int32_t Pnacl_M29_PPB_NetworkProxy_GetProxyForURL(PP_Instance instance, struct PP_Var* url, struct PP_Var* proxy_string, struct PP_CompletionCallback* callback) { @@ -1065,6 +1137,70 @@ static int32_t Pnacl_M29_PPB_TCPSocket_SetOption(PP_Resource tcp_socket, PP_TCPS /* End wrapper methods for PPB_TCPSocket_1_0 */ +/* Begin wrapper methods for PPB_TCPSocket_1_1 */ + +static PP_Resource Pnacl_M31_PPB_TCPSocket_Create(PP_Instance instance) { + const struct PPB_TCPSocket_1_1 *iface = Pnacl_WrapperInfo_PPB_TCPSocket_1_1.real_iface; + return iface->Create(instance); +} + +static PP_Bool Pnacl_M31_PPB_TCPSocket_IsTCPSocket(PP_Resource resource) { + const struct PPB_TCPSocket_1_1 *iface = Pnacl_WrapperInfo_PPB_TCPSocket_1_1.real_iface; + return iface->IsTCPSocket(resource); +} + +static int32_t Pnacl_M31_PPB_TCPSocket_Bind(PP_Resource tcp_socket, PP_Resource addr, struct PP_CompletionCallback* callback) { + const struct PPB_TCPSocket_1_1 *iface = Pnacl_WrapperInfo_PPB_TCPSocket_1_1.real_iface; + return iface->Bind(tcp_socket, addr, *callback); +} + +static int32_t Pnacl_M31_PPB_TCPSocket_Connect(PP_Resource tcp_socket, PP_Resource addr, struct PP_CompletionCallback* callback) { + const struct PPB_TCPSocket_1_1 *iface = Pnacl_WrapperInfo_PPB_TCPSocket_1_1.real_iface; + return iface->Connect(tcp_socket, addr, *callback); +} + +static PP_Resource Pnacl_M31_PPB_TCPSocket_GetLocalAddress(PP_Resource tcp_socket) { + const struct PPB_TCPSocket_1_1 *iface = Pnacl_WrapperInfo_PPB_TCPSocket_1_1.real_iface; + return iface->GetLocalAddress(tcp_socket); +} + +static PP_Resource Pnacl_M31_PPB_TCPSocket_GetRemoteAddress(PP_Resource tcp_socket) { + const struct PPB_TCPSocket_1_1 *iface = Pnacl_WrapperInfo_PPB_TCPSocket_1_1.real_iface; + return iface->GetRemoteAddress(tcp_socket); +} + +static int32_t Pnacl_M31_PPB_TCPSocket_Read(PP_Resource tcp_socket, char* buffer, int32_t bytes_to_read, struct PP_CompletionCallback* callback) { + const struct PPB_TCPSocket_1_1 *iface = Pnacl_WrapperInfo_PPB_TCPSocket_1_1.real_iface; + return iface->Read(tcp_socket, buffer, bytes_to_read, *callback); +} + +static int32_t Pnacl_M31_PPB_TCPSocket_Write(PP_Resource tcp_socket, const char* buffer, int32_t bytes_to_write, struct PP_CompletionCallback* callback) { + const struct PPB_TCPSocket_1_1 *iface = Pnacl_WrapperInfo_PPB_TCPSocket_1_1.real_iface; + return iface->Write(tcp_socket, buffer, bytes_to_write, *callback); +} + +static int32_t Pnacl_M31_PPB_TCPSocket_Listen(PP_Resource tcp_socket, int32_t backlog, struct PP_CompletionCallback* callback) { + const struct PPB_TCPSocket_1_1 *iface = Pnacl_WrapperInfo_PPB_TCPSocket_1_1.real_iface; + return iface->Listen(tcp_socket, backlog, *callback); +} + +static int32_t Pnacl_M31_PPB_TCPSocket_Accept(PP_Resource tcp_socket, PP_Resource* accepted_tcp_socket, struct PP_CompletionCallback* callback) { + const struct PPB_TCPSocket_1_1 *iface = Pnacl_WrapperInfo_PPB_TCPSocket_1_1.real_iface; + return iface->Accept(tcp_socket, accepted_tcp_socket, *callback); +} + +static void Pnacl_M31_PPB_TCPSocket_Close(PP_Resource tcp_socket) { + const struct PPB_TCPSocket_1_1 *iface = Pnacl_WrapperInfo_PPB_TCPSocket_1_1.real_iface; + iface->Close(tcp_socket); +} + +static int32_t Pnacl_M31_PPB_TCPSocket_SetOption(PP_Resource tcp_socket, PP_TCPSocket_Option name, struct PP_Var* value, struct PP_CompletionCallback* callback) { + const struct PPB_TCPSocket_1_1 *iface = Pnacl_WrapperInfo_PPB_TCPSocket_1_1.real_iface; + return iface->SetOption(tcp_socket, name, *value, *callback); +} + +/* End wrapper methods for PPB_TCPSocket_1_1 */ + /* Begin wrapper methods for PPB_TextInputController_1_0 */ static void Pnacl_M30_PPB_TextInputController_SetTextInputType(PP_Instance instance, PP_TextInput_Type type) { @@ -1816,7 +1952,24 @@ static void Pnacl_M21_PPB_IMEInputEvent_Dev_GetSelection(PP_Resource ime_event, /* End wrapper methods for PPB_IMEInputEvent_Dev_0_2 */ -/* Not generating wrapper methods for PPB_KeyboardInputEvent_Dev_0_1 */ +/* Begin wrapper methods for PPB_KeyboardInputEvent_Dev_0_2 */ + +static PP_Bool Pnacl_M31_PPB_KeyboardInputEvent_Dev_SetUsbKeyCode(PP_Resource key_event, uint32_t usb_key_code) { + const struct PPB_KeyboardInputEvent_Dev_0_2 *iface = Pnacl_WrapperInfo_PPB_KeyboardInputEvent_Dev_0_2.real_iface; + return iface->SetUsbKeyCode(key_event, usb_key_code); +} + +static uint32_t Pnacl_M31_PPB_KeyboardInputEvent_Dev_GetUsbKeyCode(PP_Resource key_event) { + const struct PPB_KeyboardInputEvent_Dev_0_2 *iface = Pnacl_WrapperInfo_PPB_KeyboardInputEvent_Dev_0_2.real_iface; + return iface->GetUsbKeyCode(key_event); +} + +static void Pnacl_M31_PPB_KeyboardInputEvent_Dev_GetCode(struct PP_Var* _struct_result, PP_Resource key_event) { + const struct PPB_KeyboardInputEvent_Dev_0_2 *iface = Pnacl_WrapperInfo_PPB_KeyboardInputEvent_Dev_0_2.real_iface; + *_struct_result = iface->GetCode(key_event); +} + +/* End wrapper methods for PPB_KeyboardInputEvent_Dev_0_2 */ /* Not generating wrapper methods for PPB_Memory_Dev_0_1 */ @@ -2065,6 +2218,55 @@ static void Pnacl_M17_PPB_URLUtil_Dev_GetPluginInstanceURL(struct PP_Var* _struc /* End wrapper methods for PPB_URLUtil_Dev_0_6 */ +/* Begin wrapper methods for PPB_URLUtil_Dev_0_7 */ + +static void Pnacl_M31_PPB_URLUtil_Dev_Canonicalize(struct PP_Var* _struct_result, struct PP_Var* url, struct PP_URLComponents_Dev* components) { + const struct PPB_URLUtil_Dev_0_7 *iface = Pnacl_WrapperInfo_PPB_URLUtil_Dev_0_7.real_iface; + *_struct_result = iface->Canonicalize(*url, components); +} + +static void Pnacl_M31_PPB_URLUtil_Dev_ResolveRelativeToURL(struct PP_Var* _struct_result, struct PP_Var* base_url, struct PP_Var* relative_string, struct PP_URLComponents_Dev* components) { + const struct PPB_URLUtil_Dev_0_7 *iface = Pnacl_WrapperInfo_PPB_URLUtil_Dev_0_7.real_iface; + *_struct_result = iface->ResolveRelativeToURL(*base_url, *relative_string, components); +} + +static void Pnacl_M31_PPB_URLUtil_Dev_ResolveRelativeToDocument(struct PP_Var* _struct_result, PP_Instance instance, struct PP_Var* relative_string, struct PP_URLComponents_Dev* components) { + const struct PPB_URLUtil_Dev_0_7 *iface = Pnacl_WrapperInfo_PPB_URLUtil_Dev_0_7.real_iface; + *_struct_result = iface->ResolveRelativeToDocument(instance, *relative_string, components); +} + +static PP_Bool Pnacl_M31_PPB_URLUtil_Dev_IsSameSecurityOrigin(struct PP_Var* url_a, struct PP_Var* url_b) { + const struct PPB_URLUtil_Dev_0_7 *iface = Pnacl_WrapperInfo_PPB_URLUtil_Dev_0_7.real_iface; + return iface->IsSameSecurityOrigin(*url_a, *url_b); +} + +static PP_Bool Pnacl_M31_PPB_URLUtil_Dev_DocumentCanRequest(PP_Instance instance, struct PP_Var* url) { + const struct PPB_URLUtil_Dev_0_7 *iface = Pnacl_WrapperInfo_PPB_URLUtil_Dev_0_7.real_iface; + return iface->DocumentCanRequest(instance, *url); +} + +static PP_Bool Pnacl_M31_PPB_URLUtil_Dev_DocumentCanAccessDocument(PP_Instance active, PP_Instance target) { + const struct PPB_URLUtil_Dev_0_7 *iface = Pnacl_WrapperInfo_PPB_URLUtil_Dev_0_7.real_iface; + return iface->DocumentCanAccessDocument(active, target); +} + +static void Pnacl_M31_PPB_URLUtil_Dev_GetDocumentURL(struct PP_Var* _struct_result, PP_Instance instance, struct PP_URLComponents_Dev* components) { + const struct PPB_URLUtil_Dev_0_7 *iface = Pnacl_WrapperInfo_PPB_URLUtil_Dev_0_7.real_iface; + *_struct_result = iface->GetDocumentURL(instance, components); +} + +static void Pnacl_M31_PPB_URLUtil_Dev_GetPluginInstanceURL(struct PP_Var* _struct_result, PP_Instance instance, struct PP_URLComponents_Dev* components) { + const struct PPB_URLUtil_Dev_0_7 *iface = Pnacl_WrapperInfo_PPB_URLUtil_Dev_0_7.real_iface; + *_struct_result = iface->GetPluginInstanceURL(instance, components); +} + +static void Pnacl_M31_PPB_URLUtil_Dev_GetPluginReferrerURL(struct PP_Var* _struct_result, PP_Instance instance, struct PP_URLComponents_Dev* components) { + const struct PPB_URLUtil_Dev_0_7 *iface = Pnacl_WrapperInfo_PPB_URLUtil_Dev_0_7.real_iface; + *_struct_result = iface->GetPluginReferrerURL(instance, components); +} + +/* End wrapper methods for PPB_URLUtil_Dev_0_7 */ + /* Begin wrapper methods for PPB_VideoCapture_Dev_0_2 */ static PP_Resource Pnacl_M19_PPB_VideoCapture_Dev_Create(PP_Instance instance) { @@ -2245,59 +2447,54 @@ static struct PP_Var Pnacl_M13_PPP_Selection_Dev_GetSelectedText(PP_Instance ins /* Not generating wrapper methods for PPP_Zoom_Dev_0_3 */ -/* Begin wrapper methods for PPB_ContentDecryptor_Private_0_6 */ +/* Begin wrapper methods for PPB_ContentDecryptor_Private_0_7 */ -static void Pnacl_M24_PPB_ContentDecryptor_Private_NeedKey(PP_Instance instance, struct PP_Var* key_system, struct PP_Var* session_id, struct PP_Var* init_data) { - const struct PPB_ContentDecryptor_Private_0_6 *iface = Pnacl_WrapperInfo_PPB_ContentDecryptor_Private_0_6.real_iface; - iface->NeedKey(instance, *key_system, *session_id, *init_data); -} - -static void Pnacl_M24_PPB_ContentDecryptor_Private_KeyAdded(PP_Instance instance, struct PP_Var* key_system, struct PP_Var* session_id) { - const struct PPB_ContentDecryptor_Private_0_6 *iface = Pnacl_WrapperInfo_PPB_ContentDecryptor_Private_0_6.real_iface; +static void Pnacl_M31_PPB_ContentDecryptor_Private_KeyAdded(PP_Instance instance, struct PP_Var* key_system, struct PP_Var* session_id) { + const struct PPB_ContentDecryptor_Private_0_7 *iface = Pnacl_WrapperInfo_PPB_ContentDecryptor_Private_0_7.real_iface; iface->KeyAdded(instance, *key_system, *session_id); } -static void Pnacl_M24_PPB_ContentDecryptor_Private_KeyMessage(PP_Instance instance, struct PP_Var* key_system, struct PP_Var* session_id, struct PP_Var* message, struct PP_Var* default_url) { - const struct PPB_ContentDecryptor_Private_0_6 *iface = Pnacl_WrapperInfo_PPB_ContentDecryptor_Private_0_6.real_iface; +static void Pnacl_M31_PPB_ContentDecryptor_Private_KeyMessage(PP_Instance instance, struct PP_Var* key_system, struct PP_Var* session_id, struct PP_Var* message, struct PP_Var* default_url) { + const struct PPB_ContentDecryptor_Private_0_7 *iface = Pnacl_WrapperInfo_PPB_ContentDecryptor_Private_0_7.real_iface; iface->KeyMessage(instance, *key_system, *session_id, *message, *default_url); } -static void Pnacl_M24_PPB_ContentDecryptor_Private_KeyError(PP_Instance instance, struct PP_Var* key_system, struct PP_Var* session_id, int32_t media_error, int32_t system_code) { - const struct PPB_ContentDecryptor_Private_0_6 *iface = Pnacl_WrapperInfo_PPB_ContentDecryptor_Private_0_6.real_iface; +static void Pnacl_M31_PPB_ContentDecryptor_Private_KeyError(PP_Instance instance, struct PP_Var* key_system, struct PP_Var* session_id, int32_t media_error, int32_t system_code) { + const struct PPB_ContentDecryptor_Private_0_7 *iface = Pnacl_WrapperInfo_PPB_ContentDecryptor_Private_0_7.real_iface; iface->KeyError(instance, *key_system, *session_id, media_error, system_code); } -static void Pnacl_M24_PPB_ContentDecryptor_Private_DeliverBlock(PP_Instance instance, PP_Resource decrypted_block, const struct PP_DecryptedBlockInfo* decrypted_block_info) { - const struct PPB_ContentDecryptor_Private_0_6 *iface = Pnacl_WrapperInfo_PPB_ContentDecryptor_Private_0_6.real_iface; +static void Pnacl_M31_PPB_ContentDecryptor_Private_DeliverBlock(PP_Instance instance, PP_Resource decrypted_block, const struct PP_DecryptedBlockInfo* decrypted_block_info) { + const struct PPB_ContentDecryptor_Private_0_7 *iface = Pnacl_WrapperInfo_PPB_ContentDecryptor_Private_0_7.real_iface; iface->DeliverBlock(instance, decrypted_block, decrypted_block_info); } -static void Pnacl_M24_PPB_ContentDecryptor_Private_DecoderInitializeDone(PP_Instance instance, PP_DecryptorStreamType decoder_type, uint32_t request_id, PP_Bool success) { - const struct PPB_ContentDecryptor_Private_0_6 *iface = Pnacl_WrapperInfo_PPB_ContentDecryptor_Private_0_6.real_iface; +static void Pnacl_M31_PPB_ContentDecryptor_Private_DecoderInitializeDone(PP_Instance instance, PP_DecryptorStreamType decoder_type, uint32_t request_id, PP_Bool success) { + const struct PPB_ContentDecryptor_Private_0_7 *iface = Pnacl_WrapperInfo_PPB_ContentDecryptor_Private_0_7.real_iface; iface->DecoderInitializeDone(instance, decoder_type, request_id, success); } -static void Pnacl_M24_PPB_ContentDecryptor_Private_DecoderDeinitializeDone(PP_Instance instance, PP_DecryptorStreamType decoder_type, uint32_t request_id) { - const struct PPB_ContentDecryptor_Private_0_6 *iface = Pnacl_WrapperInfo_PPB_ContentDecryptor_Private_0_6.real_iface; +static void Pnacl_M31_PPB_ContentDecryptor_Private_DecoderDeinitializeDone(PP_Instance instance, PP_DecryptorStreamType decoder_type, uint32_t request_id) { + const struct PPB_ContentDecryptor_Private_0_7 *iface = Pnacl_WrapperInfo_PPB_ContentDecryptor_Private_0_7.real_iface; iface->DecoderDeinitializeDone(instance, decoder_type, request_id); } -static void Pnacl_M24_PPB_ContentDecryptor_Private_DecoderResetDone(PP_Instance instance, PP_DecryptorStreamType decoder_type, uint32_t request_id) { - const struct PPB_ContentDecryptor_Private_0_6 *iface = Pnacl_WrapperInfo_PPB_ContentDecryptor_Private_0_6.real_iface; +static void Pnacl_M31_PPB_ContentDecryptor_Private_DecoderResetDone(PP_Instance instance, PP_DecryptorStreamType decoder_type, uint32_t request_id) { + const struct PPB_ContentDecryptor_Private_0_7 *iface = Pnacl_WrapperInfo_PPB_ContentDecryptor_Private_0_7.real_iface; iface->DecoderResetDone(instance, decoder_type, request_id); } -static void Pnacl_M24_PPB_ContentDecryptor_Private_DeliverFrame(PP_Instance instance, PP_Resource decrypted_frame, const struct PP_DecryptedFrameInfo* decrypted_frame_info) { - const struct PPB_ContentDecryptor_Private_0_6 *iface = Pnacl_WrapperInfo_PPB_ContentDecryptor_Private_0_6.real_iface; +static void Pnacl_M31_PPB_ContentDecryptor_Private_DeliverFrame(PP_Instance instance, PP_Resource decrypted_frame, const struct PP_DecryptedFrameInfo* decrypted_frame_info) { + const struct PPB_ContentDecryptor_Private_0_7 *iface = Pnacl_WrapperInfo_PPB_ContentDecryptor_Private_0_7.real_iface; iface->DeliverFrame(instance, decrypted_frame, decrypted_frame_info); } -static void Pnacl_M24_PPB_ContentDecryptor_Private_DeliverSamples(PP_Instance instance, PP_Resource audio_frames, const struct PP_DecryptedBlockInfo* decrypted_block_info) { - const struct PPB_ContentDecryptor_Private_0_6 *iface = Pnacl_WrapperInfo_PPB_ContentDecryptor_Private_0_6.real_iface; +static void Pnacl_M31_PPB_ContentDecryptor_Private_DeliverSamples(PP_Instance instance, PP_Resource audio_frames, const struct PP_DecryptedBlockInfo* decrypted_block_info) { + const struct PPB_ContentDecryptor_Private_0_7 *iface = Pnacl_WrapperInfo_PPB_ContentDecryptor_Private_0_7.real_iface; iface->DeliverSamples(instance, audio_frames, decrypted_block_info); } -/* End wrapper methods for PPB_ContentDecryptor_Private_0_6 */ +/* End wrapper methods for PPB_ContentDecryptor_Private_0_7 */ /* Begin wrapper methods for PPB_Ext_CrxFileSystem_Private_0_1 */ @@ -2752,8 +2949,6 @@ static int32_t Pnacl_M14_PPB_Flash_Menu_Show(PP_Resource menu_id, const struct P /* Not generating wrapper methods for PPB_Flash_Print_1_0 */ -/* Not generating wrapper methods for PPB_GpuBlacklist_Private_0_2 */ - /* Begin wrapper methods for PPB_HostResolver_Private_0_1 */ static PP_Resource Pnacl_M19_PPB_HostResolver_Private_Create(PP_Instance instance) { @@ -2809,72 +3004,72 @@ static void Pnacl_M13_PPB_Instance_Private_ExecuteScript(struct PP_Var* _struct_ /* Begin wrapper methods for PPB_NaCl_Private_1_0 */ -static PP_ExternalPluginResult Pnacl_M13_PPB_NaCl_Private_LaunchSelLdr(PP_Instance instance, const char* alleged_url, PP_Bool uses_irt, PP_Bool uses_ppapi, PP_Bool enable_ppapi_dev, PP_Bool enable_dyncode_syscalls, PP_Bool enable_exception_handling, void* imc_handle, struct PP_Var* error_message) { +static PP_ExternalPluginResult Pnacl_M25_PPB_NaCl_Private_LaunchSelLdr(PP_Instance instance, const char* alleged_url, PP_Bool uses_irt, PP_Bool uses_ppapi, PP_Bool enable_ppapi_dev, PP_Bool enable_dyncode_syscalls, PP_Bool enable_exception_handling, PP_Bool enable_crash_throttling, void* imc_handle, struct PP_Var* error_message) { const struct PPB_NaCl_Private_1_0 *iface = Pnacl_WrapperInfo_PPB_NaCl_Private_1_0.real_iface; - return iface->LaunchSelLdr(instance, alleged_url, uses_irt, uses_ppapi, enable_ppapi_dev, enable_dyncode_syscalls, enable_exception_handling, imc_handle, error_message); + return iface->LaunchSelLdr(instance, alleged_url, uses_irt, uses_ppapi, enable_ppapi_dev, enable_dyncode_syscalls, enable_exception_handling, enable_crash_throttling, imc_handle, error_message); } -static PP_ExternalPluginResult Pnacl_M13_PPB_NaCl_Private_StartPpapiProxy(PP_Instance instance) { +static PP_ExternalPluginResult Pnacl_M25_PPB_NaCl_Private_StartPpapiProxy(PP_Instance instance) { const struct PPB_NaCl_Private_1_0 *iface = Pnacl_WrapperInfo_PPB_NaCl_Private_1_0.real_iface; return iface->StartPpapiProxy(instance); } -static int32_t Pnacl_M13_PPB_NaCl_Private_UrandomFD(void) { +static int32_t Pnacl_M25_PPB_NaCl_Private_UrandomFD(void) { const struct PPB_NaCl_Private_1_0 *iface = Pnacl_WrapperInfo_PPB_NaCl_Private_1_0.real_iface; return iface->UrandomFD(); } -static PP_Bool Pnacl_M13_PPB_NaCl_Private_Are3DInterfacesDisabled(void) { +static PP_Bool Pnacl_M25_PPB_NaCl_Private_Are3DInterfacesDisabled(void) { const struct PPB_NaCl_Private_1_0 *iface = Pnacl_WrapperInfo_PPB_NaCl_Private_1_0.real_iface; return iface->Are3DInterfacesDisabled(); } -static int32_t Pnacl_M13_PPB_NaCl_Private_BrokerDuplicateHandle(PP_FileHandle source_handle, uint32_t process_id, PP_FileHandle* target_handle, uint32_t desired_access, uint32_t options) { +static int32_t Pnacl_M25_PPB_NaCl_Private_BrokerDuplicateHandle(PP_FileHandle source_handle, uint32_t process_id, PP_FileHandle* target_handle, uint32_t desired_access, uint32_t options) { const struct PPB_NaCl_Private_1_0 *iface = Pnacl_WrapperInfo_PPB_NaCl_Private_1_0.real_iface; return iface->BrokerDuplicateHandle(source_handle, process_id, target_handle, desired_access, options); } -static int32_t Pnacl_M13_PPB_NaCl_Private_EnsurePnaclInstalled(PP_Instance instance, struct PP_CompletionCallback* callback) { +static int32_t Pnacl_M25_PPB_NaCl_Private_EnsurePnaclInstalled(PP_Instance instance, struct PP_CompletionCallback* callback) { const struct PPB_NaCl_Private_1_0 *iface = Pnacl_WrapperInfo_PPB_NaCl_Private_1_0.real_iface; return iface->EnsurePnaclInstalled(instance, *callback); } -static PP_FileHandle Pnacl_M13_PPB_NaCl_Private_GetReadonlyPnaclFd(const char* filename) { +static PP_FileHandle Pnacl_M25_PPB_NaCl_Private_GetReadonlyPnaclFd(const char* filename) { const struct PPB_NaCl_Private_1_0 *iface = Pnacl_WrapperInfo_PPB_NaCl_Private_1_0.real_iface; return iface->GetReadonlyPnaclFd(filename); } -static PP_FileHandle Pnacl_M13_PPB_NaCl_Private_CreateTemporaryFile(PP_Instance instance) { +static PP_FileHandle Pnacl_M25_PPB_NaCl_Private_CreateTemporaryFile(PP_Instance instance) { const struct PPB_NaCl_Private_1_0 *iface = Pnacl_WrapperInfo_PPB_NaCl_Private_1_0.real_iface; return iface->CreateTemporaryFile(instance); } -static int32_t Pnacl_M13_PPB_NaCl_Private_GetNexeFd(PP_Instance instance, const char* pexe_url, uint32_t abi_version, uint32_t opt_level, const char* last_modified, const char* etag, PP_Bool* is_hit, PP_FileHandle* nexe_handle, struct PP_CompletionCallback* callback) { +static int32_t Pnacl_M25_PPB_NaCl_Private_GetNexeFd(PP_Instance instance, const char* pexe_url, uint32_t abi_version, uint32_t opt_level, const char* last_modified, const char* etag, PP_Bool has_no_store_header, PP_Bool* is_hit, PP_FileHandle* nexe_handle, struct PP_CompletionCallback* callback) { const struct PPB_NaCl_Private_1_0 *iface = Pnacl_WrapperInfo_PPB_NaCl_Private_1_0.real_iface; - return iface->GetNexeFd(instance, pexe_url, abi_version, opt_level, last_modified, etag, is_hit, nexe_handle, *callback); + return iface->GetNexeFd(instance, pexe_url, abi_version, opt_level, last_modified, etag, has_no_store_header, is_hit, nexe_handle, *callback); } -static void Pnacl_M13_PPB_NaCl_Private_ReportTranslationFinished(PP_Instance instance, PP_Bool success) { +static void Pnacl_M25_PPB_NaCl_Private_ReportTranslationFinished(PP_Instance instance, PP_Bool success) { const struct PPB_NaCl_Private_1_0 *iface = Pnacl_WrapperInfo_PPB_NaCl_Private_1_0.real_iface; iface->ReportTranslationFinished(instance, success); } -static PP_Bool Pnacl_M13_PPB_NaCl_Private_IsOffTheRecord(void) { +static PP_Bool Pnacl_M25_PPB_NaCl_Private_IsOffTheRecord(void) { const struct PPB_NaCl_Private_1_0 *iface = Pnacl_WrapperInfo_PPB_NaCl_Private_1_0.real_iface; return iface->IsOffTheRecord(); } -static PP_Bool Pnacl_M13_PPB_NaCl_Private_IsPnaclEnabled(void) { +static PP_Bool Pnacl_M25_PPB_NaCl_Private_IsPnaclEnabled(void) { const struct PPB_NaCl_Private_1_0 *iface = Pnacl_WrapperInfo_PPB_NaCl_Private_1_0.real_iface; return iface->IsPnaclEnabled(); } -static PP_ExternalPluginResult Pnacl_M13_PPB_NaCl_Private_ReportNaClError(PP_Instance instance, PP_NaClError message_id) { +static PP_ExternalPluginResult Pnacl_M25_PPB_NaCl_Private_ReportNaClError(PP_Instance instance, PP_NaClError message_id) { const struct PPB_NaCl_Private_1_0 *iface = Pnacl_WrapperInfo_PPB_NaCl_Private_1_0.real_iface; return iface->ReportNaClError(instance, message_id); } -static PP_FileHandle Pnacl_M13_PPB_NaCl_Private_OpenNaClExecutable(PP_Instance instance, const char* file_url, uint64_t* file_token_lo, uint64_t* file_token_hi) { +static PP_FileHandle Pnacl_M25_PPB_NaCl_Private_OpenNaClExecutable(PP_Instance instance, const char* file_url, uint64_t* file_token_lo, uint64_t* file_token_hi) { const struct PPB_NaCl_Private_1_0 *iface = Pnacl_WrapperInfo_PPB_NaCl_Private_1_0.real_iface; return iface->OpenNaClExecutable(instance, file_url, file_token_lo, file_token_hi); } @@ -3013,51 +3208,53 @@ static void Pnacl_M19_1_PPB_NetAddress_Private_CreateFromIPv6Address(const uint8 /* End wrapper methods for PPB_NetAddress_Private_1_1 */ -/* Begin wrapper methods for PPB_NetworkList_Private_0_2 */ +/* Begin wrapper methods for PPB_OutputProtection_Private_0_1 */ -static PP_Bool Pnacl_M19_PPB_NetworkList_Private_IsNetworkList(PP_Resource resource) { - const struct PPB_NetworkList_Private_0_2 *iface = Pnacl_WrapperInfo_PPB_NetworkList_Private_0_2.real_iface; - return iface->IsNetworkList(resource); +static PP_Resource Pnacl_M31_PPB_OutputProtection_Private_Create(PP_Instance instance) { + const struct PPB_OutputProtection_Private_0_1 *iface = Pnacl_WrapperInfo_PPB_OutputProtection_Private_0_1.real_iface; + return iface->Create(instance); } -static uint32_t Pnacl_M19_PPB_NetworkList_Private_GetCount(PP_Resource resource) { - const struct PPB_NetworkList_Private_0_2 *iface = Pnacl_WrapperInfo_PPB_NetworkList_Private_0_2.real_iface; - return iface->GetCount(resource); +static PP_Bool Pnacl_M31_PPB_OutputProtection_Private_IsOutputProtection(PP_Resource resource) { + const struct PPB_OutputProtection_Private_0_1 *iface = Pnacl_WrapperInfo_PPB_OutputProtection_Private_0_1.real_iface; + return iface->IsOutputProtection(resource); } -static void Pnacl_M19_PPB_NetworkList_Private_GetName(struct PP_Var* _struct_result, PP_Resource resource, uint32_t index) { - const struct PPB_NetworkList_Private_0_2 *iface = Pnacl_WrapperInfo_PPB_NetworkList_Private_0_2.real_iface; - *_struct_result = iface->GetName(resource, index); +static int32_t Pnacl_M31_PPB_OutputProtection_Private_QueryStatus(PP_Resource resource, uint32_t* link_mask, uint32_t* protection_mask, struct PP_CompletionCallback* callback) { + const struct PPB_OutputProtection_Private_0_1 *iface = Pnacl_WrapperInfo_PPB_OutputProtection_Private_0_1.real_iface; + return iface->QueryStatus(resource, link_mask, protection_mask, *callback); } -static PP_NetworkListType_Private Pnacl_M19_PPB_NetworkList_Private_GetType(PP_Resource resource, uint32_t index) { - const struct PPB_NetworkList_Private_0_2 *iface = Pnacl_WrapperInfo_PPB_NetworkList_Private_0_2.real_iface; - return iface->GetType(resource, index); +static int32_t Pnacl_M31_PPB_OutputProtection_Private_EnableProtection(PP_Resource resource, uint32_t desired_protection_mask, struct PP_CompletionCallback* callback) { + const struct PPB_OutputProtection_Private_0_1 *iface = Pnacl_WrapperInfo_PPB_OutputProtection_Private_0_1.real_iface; + return iface->EnableProtection(resource, desired_protection_mask, *callback); } -static PP_NetworkListState_Private Pnacl_M19_PPB_NetworkList_Private_GetState(PP_Resource resource, uint32_t index) { - const struct PPB_NetworkList_Private_0_2 *iface = Pnacl_WrapperInfo_PPB_NetworkList_Private_0_2.real_iface; - return iface->GetState(resource, index); -} +/* End wrapper methods for PPB_OutputProtection_Private_0_1 */ + +/* Begin wrapper methods for PPB_PlatformVerification_Private_0_1 */ -static int32_t Pnacl_M19_PPB_NetworkList_Private_GetIpAddresses(PP_Resource resource, uint32_t index, struct PP_NetAddress_Private addresses[], uint32_t count) { - const struct PPB_NetworkList_Private_0_2 *iface = Pnacl_WrapperInfo_PPB_NetworkList_Private_0_2.real_iface; - return iface->GetIpAddresses(resource, index, addresses, count); +static PP_Resource Pnacl_M31_PPB_PlatformVerification_Private_Create(PP_Instance instance) { + const struct PPB_PlatformVerification_Private_0_1 *iface = Pnacl_WrapperInfo_PPB_PlatformVerification_Private_0_1.real_iface; + return iface->Create(instance); } -static void Pnacl_M19_PPB_NetworkList_Private_GetDisplayName(struct PP_Var* _struct_result, PP_Resource resource, uint32_t index) { - const struct PPB_NetworkList_Private_0_2 *iface = Pnacl_WrapperInfo_PPB_NetworkList_Private_0_2.real_iface; - *_struct_result = iface->GetDisplayName(resource, index); +static PP_Bool Pnacl_M31_PPB_PlatformVerification_Private_IsPlatformVerification(PP_Resource resource) { + const struct PPB_PlatformVerification_Private_0_1 *iface = Pnacl_WrapperInfo_PPB_PlatformVerification_Private_0_1.real_iface; + return iface->IsPlatformVerification(resource); } -static uint32_t Pnacl_M19_PPB_NetworkList_Private_GetMTU(PP_Resource resource, uint32_t index) { - const struct PPB_NetworkList_Private_0_2 *iface = Pnacl_WrapperInfo_PPB_NetworkList_Private_0_2.real_iface; - return iface->GetMTU(resource, index); +static int32_t Pnacl_M31_PPB_PlatformVerification_Private_CanChallengePlatform(PP_Resource instance, PP_Bool* can_challenge_platform, struct PP_CompletionCallback* callback) { + const struct PPB_PlatformVerification_Private_0_1 *iface = Pnacl_WrapperInfo_PPB_PlatformVerification_Private_0_1.real_iface; + return iface->CanChallengePlatform(instance, can_challenge_platform, *callback); } -/* End wrapper methods for PPB_NetworkList_Private_0_2 */ +static int32_t Pnacl_M31_PPB_PlatformVerification_Private_ChallengePlatform(PP_Resource instance, struct PP_Var* service_id, struct PP_Var* challenge, struct PP_Var* signed_data, struct PP_Var* signed_data_signature, struct PP_Var* platform_key_certificate, struct PP_CompletionCallback* callback) { + const struct PPB_PlatformVerification_Private_0_1 *iface = Pnacl_WrapperInfo_PPB_PlatformVerification_Private_0_1.real_iface; + return iface->ChallengePlatform(instance, *service_id, *challenge, signed_data, signed_data_signature, platform_key_certificate, *callback); +} -/* Not generating wrapper methods for PPB_NetworkMonitor_Private_0_2 */ +/* End wrapper methods for PPB_PlatformVerification_Private_0_1 */ /* Begin wrapper methods for PPB_Talk_Private_1_0 */ @@ -3580,72 +3777,79 @@ static void Pnacl_M19_PPB_X509Certificate_Private_GetField(struct PP_Var* _struc /* End wrapper methods for PPB_X509Certificate_Private_0_1 */ -/* Begin wrapper methods for PPP_ContentDecryptor_Private_0_6 */ +/* Begin wrapper methods for PPP_ContentDecryptor_Private_0_7 */ + +static void Pnacl_M31_PPP_ContentDecryptor_Private_Initialize(PP_Instance instance, struct PP_Var key_system, PP_Bool can_challenge_platform) { + const struct PPP_ContentDecryptor_Private_0_7 *iface = Pnacl_WrapperInfo_PPP_ContentDecryptor_Private_0_7.real_iface; + void (*temp_fp)(PP_Instance instance, struct PP_Var* key_system, PP_Bool can_challenge_platform) = + ((void (*)(PP_Instance instance, struct PP_Var* key_system, PP_Bool can_challenge_platform))iface->Initialize); + temp_fp(instance, &key_system, can_challenge_platform); +} -static void Pnacl_M24_PPP_ContentDecryptor_Private_GenerateKeyRequest(PP_Instance instance, struct PP_Var key_system, struct PP_Var type, struct PP_Var init_data) { - const struct PPP_ContentDecryptor_Private_0_6 *iface = Pnacl_WrapperInfo_PPP_ContentDecryptor_Private_0_6.real_iface; - void (*temp_fp)(PP_Instance instance, struct PP_Var* key_system, struct PP_Var* type, struct PP_Var* init_data) = - ((void (*)(PP_Instance instance, struct PP_Var* key_system, struct PP_Var* type, struct PP_Var* init_data))iface->GenerateKeyRequest); - temp_fp(instance, &key_system, &type, &init_data); +static void Pnacl_M31_PPP_ContentDecryptor_Private_GenerateKeyRequest(PP_Instance instance, struct PP_Var type, struct PP_Var init_data) { + const struct PPP_ContentDecryptor_Private_0_7 *iface = Pnacl_WrapperInfo_PPP_ContentDecryptor_Private_0_7.real_iface; + void (*temp_fp)(PP_Instance instance, struct PP_Var* type, struct PP_Var* init_data) = + ((void (*)(PP_Instance instance, struct PP_Var* type, struct PP_Var* init_data))iface->GenerateKeyRequest); + temp_fp(instance, &type, &init_data); } -static void Pnacl_M24_PPP_ContentDecryptor_Private_AddKey(PP_Instance instance, struct PP_Var session_id, struct PP_Var key, struct PP_Var init_data) { - const struct PPP_ContentDecryptor_Private_0_6 *iface = Pnacl_WrapperInfo_PPP_ContentDecryptor_Private_0_6.real_iface; +static void Pnacl_M31_PPP_ContentDecryptor_Private_AddKey(PP_Instance instance, struct PP_Var session_id, struct PP_Var key, struct PP_Var init_data) { + const struct PPP_ContentDecryptor_Private_0_7 *iface = Pnacl_WrapperInfo_PPP_ContentDecryptor_Private_0_7.real_iface; void (*temp_fp)(PP_Instance instance, struct PP_Var* session_id, struct PP_Var* key, struct PP_Var* init_data) = ((void (*)(PP_Instance instance, struct PP_Var* session_id, struct PP_Var* key, struct PP_Var* init_data))iface->AddKey); temp_fp(instance, &session_id, &key, &init_data); } -static void Pnacl_M24_PPP_ContentDecryptor_Private_CancelKeyRequest(PP_Instance instance, struct PP_Var session_id) { - const struct PPP_ContentDecryptor_Private_0_6 *iface = Pnacl_WrapperInfo_PPP_ContentDecryptor_Private_0_6.real_iface; +static void Pnacl_M31_PPP_ContentDecryptor_Private_CancelKeyRequest(PP_Instance instance, struct PP_Var session_id) { + const struct PPP_ContentDecryptor_Private_0_7 *iface = Pnacl_WrapperInfo_PPP_ContentDecryptor_Private_0_7.real_iface; void (*temp_fp)(PP_Instance instance, struct PP_Var* session_id) = ((void (*)(PP_Instance instance, struct PP_Var* session_id))iface->CancelKeyRequest); temp_fp(instance, &session_id); } -static void Pnacl_M24_PPP_ContentDecryptor_Private_Decrypt(PP_Instance instance, PP_Resource encrypted_block, const struct PP_EncryptedBlockInfo* encrypted_block_info) { - const struct PPP_ContentDecryptor_Private_0_6 *iface = Pnacl_WrapperInfo_PPP_ContentDecryptor_Private_0_6.real_iface; +static void Pnacl_M31_PPP_ContentDecryptor_Private_Decrypt(PP_Instance instance, PP_Resource encrypted_block, const struct PP_EncryptedBlockInfo* encrypted_block_info) { + const struct PPP_ContentDecryptor_Private_0_7 *iface = Pnacl_WrapperInfo_PPP_ContentDecryptor_Private_0_7.real_iface; void (*temp_fp)(PP_Instance instance, PP_Resource encrypted_block, const struct PP_EncryptedBlockInfo* encrypted_block_info) = ((void (*)(PP_Instance instance, PP_Resource encrypted_block, const struct PP_EncryptedBlockInfo* encrypted_block_info))iface->Decrypt); temp_fp(instance, encrypted_block, encrypted_block_info); } -static void Pnacl_M24_PPP_ContentDecryptor_Private_InitializeAudioDecoder(PP_Instance instance, const struct PP_AudioDecoderConfig* decoder_config, PP_Resource codec_extra_data) { - const struct PPP_ContentDecryptor_Private_0_6 *iface = Pnacl_WrapperInfo_PPP_ContentDecryptor_Private_0_6.real_iface; +static void Pnacl_M31_PPP_ContentDecryptor_Private_InitializeAudioDecoder(PP_Instance instance, const struct PP_AudioDecoderConfig* decoder_config, PP_Resource codec_extra_data) { + const struct PPP_ContentDecryptor_Private_0_7 *iface = Pnacl_WrapperInfo_PPP_ContentDecryptor_Private_0_7.real_iface; void (*temp_fp)(PP_Instance instance, const struct PP_AudioDecoderConfig* decoder_config, PP_Resource codec_extra_data) = ((void (*)(PP_Instance instance, const struct PP_AudioDecoderConfig* decoder_config, PP_Resource codec_extra_data))iface->InitializeAudioDecoder); temp_fp(instance, decoder_config, codec_extra_data); } -static void Pnacl_M24_PPP_ContentDecryptor_Private_InitializeVideoDecoder(PP_Instance instance, const struct PP_VideoDecoderConfig* decoder_config, PP_Resource codec_extra_data) { - const struct PPP_ContentDecryptor_Private_0_6 *iface = Pnacl_WrapperInfo_PPP_ContentDecryptor_Private_0_6.real_iface; +static void Pnacl_M31_PPP_ContentDecryptor_Private_InitializeVideoDecoder(PP_Instance instance, const struct PP_VideoDecoderConfig* decoder_config, PP_Resource codec_extra_data) { + const struct PPP_ContentDecryptor_Private_0_7 *iface = Pnacl_WrapperInfo_PPP_ContentDecryptor_Private_0_7.real_iface; void (*temp_fp)(PP_Instance instance, const struct PP_VideoDecoderConfig* decoder_config, PP_Resource codec_extra_data) = ((void (*)(PP_Instance instance, const struct PP_VideoDecoderConfig* decoder_config, PP_Resource codec_extra_data))iface->InitializeVideoDecoder); temp_fp(instance, decoder_config, codec_extra_data); } -static void Pnacl_M24_PPP_ContentDecryptor_Private_DeinitializeDecoder(PP_Instance instance, PP_DecryptorStreamType decoder_type, uint32_t request_id) { - const struct PPP_ContentDecryptor_Private_0_6 *iface = Pnacl_WrapperInfo_PPP_ContentDecryptor_Private_0_6.real_iface; +static void Pnacl_M31_PPP_ContentDecryptor_Private_DeinitializeDecoder(PP_Instance instance, PP_DecryptorStreamType decoder_type, uint32_t request_id) { + const struct PPP_ContentDecryptor_Private_0_7 *iface = Pnacl_WrapperInfo_PPP_ContentDecryptor_Private_0_7.real_iface; void (*temp_fp)(PP_Instance instance, PP_DecryptorStreamType decoder_type, uint32_t request_id) = ((void (*)(PP_Instance instance, PP_DecryptorStreamType decoder_type, uint32_t request_id))iface->DeinitializeDecoder); temp_fp(instance, decoder_type, request_id); } -static void Pnacl_M24_PPP_ContentDecryptor_Private_ResetDecoder(PP_Instance instance, PP_DecryptorStreamType decoder_type, uint32_t request_id) { - const struct PPP_ContentDecryptor_Private_0_6 *iface = Pnacl_WrapperInfo_PPP_ContentDecryptor_Private_0_6.real_iface; +static void Pnacl_M31_PPP_ContentDecryptor_Private_ResetDecoder(PP_Instance instance, PP_DecryptorStreamType decoder_type, uint32_t request_id) { + const struct PPP_ContentDecryptor_Private_0_7 *iface = Pnacl_WrapperInfo_PPP_ContentDecryptor_Private_0_7.real_iface; void (*temp_fp)(PP_Instance instance, PP_DecryptorStreamType decoder_type, uint32_t request_id) = ((void (*)(PP_Instance instance, PP_DecryptorStreamType decoder_type, uint32_t request_id))iface->ResetDecoder); temp_fp(instance, decoder_type, request_id); } -static void Pnacl_M24_PPP_ContentDecryptor_Private_DecryptAndDecode(PP_Instance instance, PP_DecryptorStreamType decoder_type, PP_Resource encrypted_buffer, const struct PP_EncryptedBlockInfo* encrypted_block_info) { - const struct PPP_ContentDecryptor_Private_0_6 *iface = Pnacl_WrapperInfo_PPP_ContentDecryptor_Private_0_6.real_iface; +static void Pnacl_M31_PPP_ContentDecryptor_Private_DecryptAndDecode(PP_Instance instance, PP_DecryptorStreamType decoder_type, PP_Resource encrypted_buffer, const struct PP_EncryptedBlockInfo* encrypted_block_info) { + const struct PPP_ContentDecryptor_Private_0_7 *iface = Pnacl_WrapperInfo_PPP_ContentDecryptor_Private_0_7.real_iface; void (*temp_fp)(PP_Instance instance, PP_DecryptorStreamType decoder_type, PP_Resource encrypted_buffer, const struct PP_EncryptedBlockInfo* encrypted_block_info) = ((void (*)(PP_Instance instance, PP_DecryptorStreamType decoder_type, PP_Resource encrypted_buffer, const struct PP_EncryptedBlockInfo* encrypted_block_info))iface->DecryptAndDecode); temp_fp(instance, decoder_type, encrypted_buffer, encrypted_block_info); } -/* End wrapper methods for PPP_ContentDecryptor_Private_0_6 */ +/* End wrapper methods for PPP_ContentDecryptor_Private_0_7 */ /* Not generating wrapper methods for PPP_Flash_BrowserOperations_1_0 */ @@ -3894,6 +4098,8 @@ static int32_t Pnacl_M29_PPB_Ext_Socket_Dev_GetJoinedGroups(PP_Instance instance /* Not generating wrapper interface for PPB_Audio_1_0 */ +/* Not generating wrapper interface for PPB_Audio_1_1 */ + /* Not generating wrapper interface for PPB_AudioConfig_1_0 */ /* Not generating wrapper interface for PPB_AudioConfig_1_1 */ @@ -4108,6 +4314,23 @@ struct PPB_NetAddress_1_0 Pnacl_Wrappers_PPB_NetAddress_1_0 = { .DescribeAsIPv6Address = (PP_Bool (*)(PP_Resource addr, struct PP_NetAddress_IPv6* ipv6_addr))&Pnacl_M29_PPB_NetAddress_DescribeAsIPv6Address }; +struct PPB_NetworkList_1_0 Pnacl_Wrappers_PPB_NetworkList_1_0 = { + .IsNetworkList = (PP_Bool (*)(PP_Resource resource))&Pnacl_M31_PPB_NetworkList_IsNetworkList, + .GetCount = (uint32_t (*)(PP_Resource resource))&Pnacl_M31_PPB_NetworkList_GetCount, + .GetName = (struct PP_Var (*)(PP_Resource resource, uint32_t index))&Pnacl_M31_PPB_NetworkList_GetName, + .GetType = (PP_NetworkList_Type (*)(PP_Resource resource, uint32_t index))&Pnacl_M31_PPB_NetworkList_GetType, + .GetState = (PP_NetworkList_State (*)(PP_Resource resource, uint32_t index))&Pnacl_M31_PPB_NetworkList_GetState, + .GetIpAddresses = (int32_t (*)(PP_Resource resource, uint32_t index, struct PP_ArrayOutput output))&Pnacl_M31_PPB_NetworkList_GetIpAddresses, + .GetDisplayName = (struct PP_Var (*)(PP_Resource resource, uint32_t index))&Pnacl_M31_PPB_NetworkList_GetDisplayName, + .GetMTU = (uint32_t (*)(PP_Resource resource, uint32_t index))&Pnacl_M31_PPB_NetworkList_GetMTU +}; + +struct PPB_NetworkMonitor_1_0 Pnacl_Wrappers_PPB_NetworkMonitor_1_0 = { + .Create = (PP_Resource (*)(PP_Instance instance))&Pnacl_M31_PPB_NetworkMonitor_Create, + .UpdateNetworkList = (int32_t (*)(PP_Resource network_monitor, PP_Resource* network_list, struct PP_CompletionCallback callback))&Pnacl_M31_PPB_NetworkMonitor_UpdateNetworkList, + .IsNetworkMonitor = (PP_Bool (*)(PP_Resource resource))&Pnacl_M31_PPB_NetworkMonitor_IsNetworkMonitor +}; + struct PPB_NetworkProxy_1_0 Pnacl_Wrappers_PPB_NetworkProxy_1_0 = { .GetProxyForURL = (int32_t (*)(PP_Instance instance, struct PP_Var url, struct PP_Var* proxy_string, struct PP_CompletionCallback callback))&Pnacl_M29_PPB_NetworkProxy_GetProxyForURL }; @@ -4124,6 +4347,21 @@ struct PPB_TCPSocket_1_0 Pnacl_Wrappers_PPB_TCPSocket_1_0 = { .SetOption = (int32_t (*)(PP_Resource tcp_socket, PP_TCPSocket_Option name, struct PP_Var value, struct PP_CompletionCallback callback))&Pnacl_M29_PPB_TCPSocket_SetOption }; +struct PPB_TCPSocket_1_1 Pnacl_Wrappers_PPB_TCPSocket_1_1 = { + .Create = (PP_Resource (*)(PP_Instance instance))&Pnacl_M31_PPB_TCPSocket_Create, + .IsTCPSocket = (PP_Bool (*)(PP_Resource resource))&Pnacl_M31_PPB_TCPSocket_IsTCPSocket, + .Bind = (int32_t (*)(PP_Resource tcp_socket, PP_Resource addr, struct PP_CompletionCallback callback))&Pnacl_M31_PPB_TCPSocket_Bind, + .Connect = (int32_t (*)(PP_Resource tcp_socket, PP_Resource addr, struct PP_CompletionCallback callback))&Pnacl_M31_PPB_TCPSocket_Connect, + .GetLocalAddress = (PP_Resource (*)(PP_Resource tcp_socket))&Pnacl_M31_PPB_TCPSocket_GetLocalAddress, + .GetRemoteAddress = (PP_Resource (*)(PP_Resource tcp_socket))&Pnacl_M31_PPB_TCPSocket_GetRemoteAddress, + .Read = (int32_t (*)(PP_Resource tcp_socket, char* buffer, int32_t bytes_to_read, struct PP_CompletionCallback callback))&Pnacl_M31_PPB_TCPSocket_Read, + .Write = (int32_t (*)(PP_Resource tcp_socket, const char* buffer, int32_t bytes_to_write, struct PP_CompletionCallback callback))&Pnacl_M31_PPB_TCPSocket_Write, + .Listen = (int32_t (*)(PP_Resource tcp_socket, int32_t backlog, struct PP_CompletionCallback callback))&Pnacl_M31_PPB_TCPSocket_Listen, + .Accept = (int32_t (*)(PP_Resource tcp_socket, PP_Resource* accepted_tcp_socket, struct PP_CompletionCallback callback))&Pnacl_M31_PPB_TCPSocket_Accept, + .Close = (void (*)(PP_Resource tcp_socket))&Pnacl_M31_PPB_TCPSocket_Close, + .SetOption = (int32_t (*)(PP_Resource tcp_socket, PP_TCPSocket_Option name, struct PP_Var value, struct PP_CompletionCallback callback))&Pnacl_M31_PPB_TCPSocket_SetOption +}; + struct PPB_TextInputController_1_0 Pnacl_Wrappers_PPB_TextInputController_1_0 = { .SetTextInputType = (void (*)(PP_Instance instance, PP_TextInput_Type type))&Pnacl_M30_PPB_TextInputController_SetTextInputType, .UpdateCaretPosition = (void (*)(PP_Instance instance, const struct PP_Rect* caret))&Pnacl_M30_PPB_TextInputController_UpdateCaretPosition, @@ -4352,7 +4590,11 @@ struct PPB_IMEInputEvent_Dev_0_2 Pnacl_Wrappers_PPB_IMEInputEvent_Dev_0_2 = { .GetSelection = (void (*)(PP_Resource ime_event, uint32_t* start, uint32_t* end))&Pnacl_M21_PPB_IMEInputEvent_Dev_GetSelection }; -/* Not generating wrapper interface for PPB_KeyboardInputEvent_Dev_0_1 */ +struct PPB_KeyboardInputEvent_Dev_0_2 Pnacl_Wrappers_PPB_KeyboardInputEvent_Dev_0_2 = { + .SetUsbKeyCode = (PP_Bool (*)(PP_Resource key_event, uint32_t usb_key_code))&Pnacl_M31_PPB_KeyboardInputEvent_Dev_SetUsbKeyCode, + .GetUsbKeyCode = (uint32_t (*)(PP_Resource key_event))&Pnacl_M31_PPB_KeyboardInputEvent_Dev_GetUsbKeyCode, + .GetCode = (struct PP_Var (*)(PP_Resource key_event))&Pnacl_M31_PPB_KeyboardInputEvent_Dev_GetCode +}; /* Not generating wrapper interface for PPB_Memory_Dev_0_1 */ @@ -4431,6 +4673,18 @@ struct PPB_URLUtil_Dev_0_6 Pnacl_Wrappers_PPB_URLUtil_Dev_0_6 = { .GetPluginInstanceURL = (struct PP_Var (*)(PP_Instance instance, struct PP_URLComponents_Dev* components))&Pnacl_M17_PPB_URLUtil_Dev_GetPluginInstanceURL }; +struct PPB_URLUtil_Dev_0_7 Pnacl_Wrappers_PPB_URLUtil_Dev_0_7 = { + .Canonicalize = (struct PP_Var (*)(struct PP_Var url, struct PP_URLComponents_Dev* components))&Pnacl_M31_PPB_URLUtil_Dev_Canonicalize, + .ResolveRelativeToURL = (struct PP_Var (*)(struct PP_Var base_url, struct PP_Var relative_string, struct PP_URLComponents_Dev* components))&Pnacl_M31_PPB_URLUtil_Dev_ResolveRelativeToURL, + .ResolveRelativeToDocument = (struct PP_Var (*)(PP_Instance instance, struct PP_Var relative_string, struct PP_URLComponents_Dev* components))&Pnacl_M31_PPB_URLUtil_Dev_ResolveRelativeToDocument, + .IsSameSecurityOrigin = (PP_Bool (*)(struct PP_Var url_a, struct PP_Var url_b))&Pnacl_M31_PPB_URLUtil_Dev_IsSameSecurityOrigin, + .DocumentCanRequest = (PP_Bool (*)(PP_Instance instance, struct PP_Var url))&Pnacl_M31_PPB_URLUtil_Dev_DocumentCanRequest, + .DocumentCanAccessDocument = (PP_Bool (*)(PP_Instance active, PP_Instance target))&Pnacl_M31_PPB_URLUtil_Dev_DocumentCanAccessDocument, + .GetDocumentURL = (struct PP_Var (*)(PP_Instance instance, struct PP_URLComponents_Dev* components))&Pnacl_M31_PPB_URLUtil_Dev_GetDocumentURL, + .GetPluginInstanceURL = (struct PP_Var (*)(PP_Instance instance, struct PP_URLComponents_Dev* components))&Pnacl_M31_PPB_URLUtil_Dev_GetPluginInstanceURL, + .GetPluginReferrerURL = (struct PP_Var (*)(PP_Instance instance, struct PP_URLComponents_Dev* components))&Pnacl_M31_PPB_URLUtil_Dev_GetPluginReferrerURL +}; + struct PPB_VideoCapture_Dev_0_2 Pnacl_Wrappers_PPB_VideoCapture_Dev_0_2 = { .Create = (PP_Resource (*)(PP_Instance instance))&Pnacl_M19_PPB_VideoCapture_Dev_Create, .IsVideoCapture = (PP_Bool (*)(PP_Resource video_capture))&Pnacl_M19_PPB_VideoCapture_Dev_IsVideoCapture, @@ -4499,17 +4753,16 @@ struct PPP_Selection_Dev_0_3 Pnacl_Wrappers_PPP_Selection_Dev_0_3 = { /* Not generating wrapper interface for PPP_Zoom_Dev_0_3 */ -struct PPB_ContentDecryptor_Private_0_6 Pnacl_Wrappers_PPB_ContentDecryptor_Private_0_6 = { - .NeedKey = (void (*)(PP_Instance instance, struct PP_Var key_system, struct PP_Var session_id, struct PP_Var init_data))&Pnacl_M24_PPB_ContentDecryptor_Private_NeedKey, - .KeyAdded = (void (*)(PP_Instance instance, struct PP_Var key_system, struct PP_Var session_id))&Pnacl_M24_PPB_ContentDecryptor_Private_KeyAdded, - .KeyMessage = (void (*)(PP_Instance instance, struct PP_Var key_system, struct PP_Var session_id, struct PP_Var message, struct PP_Var default_url))&Pnacl_M24_PPB_ContentDecryptor_Private_KeyMessage, - .KeyError = (void (*)(PP_Instance instance, struct PP_Var key_system, struct PP_Var session_id, int32_t media_error, int32_t system_code))&Pnacl_M24_PPB_ContentDecryptor_Private_KeyError, - .DeliverBlock = (void (*)(PP_Instance instance, PP_Resource decrypted_block, const struct PP_DecryptedBlockInfo* decrypted_block_info))&Pnacl_M24_PPB_ContentDecryptor_Private_DeliverBlock, - .DecoderInitializeDone = (void (*)(PP_Instance instance, PP_DecryptorStreamType decoder_type, uint32_t request_id, PP_Bool success))&Pnacl_M24_PPB_ContentDecryptor_Private_DecoderInitializeDone, - .DecoderDeinitializeDone = (void (*)(PP_Instance instance, PP_DecryptorStreamType decoder_type, uint32_t request_id))&Pnacl_M24_PPB_ContentDecryptor_Private_DecoderDeinitializeDone, - .DecoderResetDone = (void (*)(PP_Instance instance, PP_DecryptorStreamType decoder_type, uint32_t request_id))&Pnacl_M24_PPB_ContentDecryptor_Private_DecoderResetDone, - .DeliverFrame = (void (*)(PP_Instance instance, PP_Resource decrypted_frame, const struct PP_DecryptedFrameInfo* decrypted_frame_info))&Pnacl_M24_PPB_ContentDecryptor_Private_DeliverFrame, - .DeliverSamples = (void (*)(PP_Instance instance, PP_Resource audio_frames, const struct PP_DecryptedBlockInfo* decrypted_block_info))&Pnacl_M24_PPB_ContentDecryptor_Private_DeliverSamples +struct PPB_ContentDecryptor_Private_0_7 Pnacl_Wrappers_PPB_ContentDecryptor_Private_0_7 = { + .KeyAdded = (void (*)(PP_Instance instance, struct PP_Var key_system, struct PP_Var session_id))&Pnacl_M31_PPB_ContentDecryptor_Private_KeyAdded, + .KeyMessage = (void (*)(PP_Instance instance, struct PP_Var key_system, struct PP_Var session_id, struct PP_Var message, struct PP_Var default_url))&Pnacl_M31_PPB_ContentDecryptor_Private_KeyMessage, + .KeyError = (void (*)(PP_Instance instance, struct PP_Var key_system, struct PP_Var session_id, int32_t media_error, int32_t system_code))&Pnacl_M31_PPB_ContentDecryptor_Private_KeyError, + .DeliverBlock = (void (*)(PP_Instance instance, PP_Resource decrypted_block, const struct PP_DecryptedBlockInfo* decrypted_block_info))&Pnacl_M31_PPB_ContentDecryptor_Private_DeliverBlock, + .DecoderInitializeDone = (void (*)(PP_Instance instance, PP_DecryptorStreamType decoder_type, uint32_t request_id, PP_Bool success))&Pnacl_M31_PPB_ContentDecryptor_Private_DecoderInitializeDone, + .DecoderDeinitializeDone = (void (*)(PP_Instance instance, PP_DecryptorStreamType decoder_type, uint32_t request_id))&Pnacl_M31_PPB_ContentDecryptor_Private_DecoderDeinitializeDone, + .DecoderResetDone = (void (*)(PP_Instance instance, PP_DecryptorStreamType decoder_type, uint32_t request_id))&Pnacl_M31_PPB_ContentDecryptor_Private_DecoderResetDone, + .DeliverFrame = (void (*)(PP_Instance instance, PP_Resource decrypted_frame, const struct PP_DecryptedFrameInfo* decrypted_frame_info))&Pnacl_M31_PPB_ContentDecryptor_Private_DeliverFrame, + .DeliverSamples = (void (*)(PP_Instance instance, PP_Resource audio_frames, const struct PP_DecryptedBlockInfo* decrypted_block_info))&Pnacl_M31_PPB_ContentDecryptor_Private_DeliverSamples }; struct PPB_Ext_CrxFileSystem_Private_0_1 Pnacl_Wrappers_PPB_Ext_CrxFileSystem_Private_0_1 = { @@ -4637,8 +4890,6 @@ struct PPB_Flash_Menu_0_2 Pnacl_Wrappers_PPB_Flash_Menu_0_2 = { /* Not generating wrapper interface for PPB_Flash_Print_1_0 */ -/* Not generating wrapper interface for PPB_GpuBlacklist_Private_0_2 */ - struct PPB_HostResolver_Private_0_1 Pnacl_Wrappers_PPB_HostResolver_Private_0_1 = { .Create = (PP_Resource (*)(PP_Instance instance))&Pnacl_M19_PPB_HostResolver_Private_Create, .IsHostResolver = (PP_Bool (*)(PP_Resource resource))&Pnacl_M19_PPB_HostResolver_Private_IsHostResolver, @@ -4655,20 +4906,20 @@ struct PPB_Instance_Private_0_1 Pnacl_Wrappers_PPB_Instance_Private_0_1 = { }; struct PPB_NaCl_Private_1_0 Pnacl_Wrappers_PPB_NaCl_Private_1_0 = { - .LaunchSelLdr = (PP_ExternalPluginResult (*)(PP_Instance instance, const char* alleged_url, PP_Bool uses_irt, PP_Bool uses_ppapi, PP_Bool enable_ppapi_dev, PP_Bool enable_dyncode_syscalls, PP_Bool enable_exception_handling, void* imc_handle, struct PP_Var* error_message))&Pnacl_M13_PPB_NaCl_Private_LaunchSelLdr, - .StartPpapiProxy = (PP_ExternalPluginResult (*)(PP_Instance instance))&Pnacl_M13_PPB_NaCl_Private_StartPpapiProxy, - .UrandomFD = (int32_t (*)(void))&Pnacl_M13_PPB_NaCl_Private_UrandomFD, - .Are3DInterfacesDisabled = (PP_Bool (*)(void))&Pnacl_M13_PPB_NaCl_Private_Are3DInterfacesDisabled, - .BrokerDuplicateHandle = (int32_t (*)(PP_FileHandle source_handle, uint32_t process_id, PP_FileHandle* target_handle, uint32_t desired_access, uint32_t options))&Pnacl_M13_PPB_NaCl_Private_BrokerDuplicateHandle, - .EnsurePnaclInstalled = (int32_t (*)(PP_Instance instance, struct PP_CompletionCallback callback))&Pnacl_M13_PPB_NaCl_Private_EnsurePnaclInstalled, - .GetReadonlyPnaclFd = (PP_FileHandle (*)(const char* filename))&Pnacl_M13_PPB_NaCl_Private_GetReadonlyPnaclFd, - .CreateTemporaryFile = (PP_FileHandle (*)(PP_Instance instance))&Pnacl_M13_PPB_NaCl_Private_CreateTemporaryFile, - .GetNexeFd = (int32_t (*)(PP_Instance instance, const char* pexe_url, uint32_t abi_version, uint32_t opt_level, const char* last_modified, const char* etag, PP_Bool* is_hit, PP_FileHandle* nexe_handle, struct PP_CompletionCallback callback))&Pnacl_M13_PPB_NaCl_Private_GetNexeFd, - .ReportTranslationFinished = (void (*)(PP_Instance instance, PP_Bool success))&Pnacl_M13_PPB_NaCl_Private_ReportTranslationFinished, - .IsOffTheRecord = (PP_Bool (*)(void))&Pnacl_M13_PPB_NaCl_Private_IsOffTheRecord, - .IsPnaclEnabled = (PP_Bool (*)(void))&Pnacl_M13_PPB_NaCl_Private_IsPnaclEnabled, - .ReportNaClError = (PP_ExternalPluginResult (*)(PP_Instance instance, PP_NaClError message_id))&Pnacl_M13_PPB_NaCl_Private_ReportNaClError, - .OpenNaClExecutable = (PP_FileHandle (*)(PP_Instance instance, const char* file_url, uint64_t* file_token_lo, uint64_t* file_token_hi))&Pnacl_M13_PPB_NaCl_Private_OpenNaClExecutable + .LaunchSelLdr = (PP_ExternalPluginResult (*)(PP_Instance instance, const char* alleged_url, PP_Bool uses_irt, PP_Bool uses_ppapi, PP_Bool enable_ppapi_dev, PP_Bool enable_dyncode_syscalls, PP_Bool enable_exception_handling, PP_Bool enable_crash_throttling, void* imc_handle, struct PP_Var* error_message))&Pnacl_M25_PPB_NaCl_Private_LaunchSelLdr, + .StartPpapiProxy = (PP_ExternalPluginResult (*)(PP_Instance instance))&Pnacl_M25_PPB_NaCl_Private_StartPpapiProxy, + .UrandomFD = (int32_t (*)(void))&Pnacl_M25_PPB_NaCl_Private_UrandomFD, + .Are3DInterfacesDisabled = (PP_Bool (*)(void))&Pnacl_M25_PPB_NaCl_Private_Are3DInterfacesDisabled, + .BrokerDuplicateHandle = (int32_t (*)(PP_FileHandle source_handle, uint32_t process_id, PP_FileHandle* target_handle, uint32_t desired_access, uint32_t options))&Pnacl_M25_PPB_NaCl_Private_BrokerDuplicateHandle, + .EnsurePnaclInstalled = (int32_t (*)(PP_Instance instance, struct PP_CompletionCallback callback))&Pnacl_M25_PPB_NaCl_Private_EnsurePnaclInstalled, + .GetReadonlyPnaclFd = (PP_FileHandle (*)(const char* filename))&Pnacl_M25_PPB_NaCl_Private_GetReadonlyPnaclFd, + .CreateTemporaryFile = (PP_FileHandle (*)(PP_Instance instance))&Pnacl_M25_PPB_NaCl_Private_CreateTemporaryFile, + .GetNexeFd = (int32_t (*)(PP_Instance instance, const char* pexe_url, uint32_t abi_version, uint32_t opt_level, const char* last_modified, const char* etag, PP_Bool has_no_store_header, PP_Bool* is_hit, PP_FileHandle* nexe_handle, struct PP_CompletionCallback callback))&Pnacl_M25_PPB_NaCl_Private_GetNexeFd, + .ReportTranslationFinished = (void (*)(PP_Instance instance, PP_Bool success))&Pnacl_M25_PPB_NaCl_Private_ReportTranslationFinished, + .IsOffTheRecord = (PP_Bool (*)(void))&Pnacl_M25_PPB_NaCl_Private_IsOffTheRecord, + .IsPnaclEnabled = (PP_Bool (*)(void))&Pnacl_M25_PPB_NaCl_Private_IsPnaclEnabled, + .ReportNaClError = (PP_ExternalPluginResult (*)(PP_Instance instance, PP_NaClError message_id))&Pnacl_M25_PPB_NaCl_Private_ReportNaClError, + .OpenNaClExecutable = (PP_FileHandle (*)(PP_Instance instance, const char* file_url, uint64_t* file_token_lo, uint64_t* file_token_hi))&Pnacl_M25_PPB_NaCl_Private_OpenNaClExecutable }; struct PPB_NetAddress_Private_0_1 Pnacl_Wrappers_PPB_NetAddress_Private_0_1 = { @@ -4704,18 +4955,19 @@ struct PPB_NetAddress_Private_1_1 Pnacl_Wrappers_PPB_NetAddress_Private_1_1 = { .CreateFromIPv6Address = (void (*)(const uint8_t ip[16], uint32_t scope_id, uint16_t port, struct PP_NetAddress_Private* addr_out))&Pnacl_M19_1_PPB_NetAddress_Private_CreateFromIPv6Address }; -struct PPB_NetworkList_Private_0_2 Pnacl_Wrappers_PPB_NetworkList_Private_0_2 = { - .IsNetworkList = (PP_Bool (*)(PP_Resource resource))&Pnacl_M19_PPB_NetworkList_Private_IsNetworkList, - .GetCount = (uint32_t (*)(PP_Resource resource))&Pnacl_M19_PPB_NetworkList_Private_GetCount, - .GetName = (struct PP_Var (*)(PP_Resource resource, uint32_t index))&Pnacl_M19_PPB_NetworkList_Private_GetName, - .GetType = (PP_NetworkListType_Private (*)(PP_Resource resource, uint32_t index))&Pnacl_M19_PPB_NetworkList_Private_GetType, - .GetState = (PP_NetworkListState_Private (*)(PP_Resource resource, uint32_t index))&Pnacl_M19_PPB_NetworkList_Private_GetState, - .GetIpAddresses = (int32_t (*)(PP_Resource resource, uint32_t index, struct PP_NetAddress_Private addresses[], uint32_t count))&Pnacl_M19_PPB_NetworkList_Private_GetIpAddresses, - .GetDisplayName = (struct PP_Var (*)(PP_Resource resource, uint32_t index))&Pnacl_M19_PPB_NetworkList_Private_GetDisplayName, - .GetMTU = (uint32_t (*)(PP_Resource resource, uint32_t index))&Pnacl_M19_PPB_NetworkList_Private_GetMTU +struct PPB_OutputProtection_Private_0_1 Pnacl_Wrappers_PPB_OutputProtection_Private_0_1 = { + .Create = (PP_Resource (*)(PP_Instance instance))&Pnacl_M31_PPB_OutputProtection_Private_Create, + .IsOutputProtection = (PP_Bool (*)(PP_Resource resource))&Pnacl_M31_PPB_OutputProtection_Private_IsOutputProtection, + .QueryStatus = (int32_t (*)(PP_Resource resource, uint32_t* link_mask, uint32_t* protection_mask, struct PP_CompletionCallback callback))&Pnacl_M31_PPB_OutputProtection_Private_QueryStatus, + .EnableProtection = (int32_t (*)(PP_Resource resource, uint32_t desired_protection_mask, struct PP_CompletionCallback callback))&Pnacl_M31_PPB_OutputProtection_Private_EnableProtection }; -/* Not generating wrapper interface for PPB_NetworkMonitor_Private_0_2 */ +struct PPB_PlatformVerification_Private_0_1 Pnacl_Wrappers_PPB_PlatformVerification_Private_0_1 = { + .Create = (PP_Resource (*)(PP_Instance instance))&Pnacl_M31_PPB_PlatformVerification_Private_Create, + .IsPlatformVerification = (PP_Bool (*)(PP_Resource resource))&Pnacl_M31_PPB_PlatformVerification_Private_IsPlatformVerification, + .CanChallengePlatform = (int32_t (*)(PP_Resource instance, PP_Bool* can_challenge_platform, struct PP_CompletionCallback callback))&Pnacl_M31_PPB_PlatformVerification_Private_CanChallengePlatform, + .ChallengePlatform = (int32_t (*)(PP_Resource instance, struct PP_Var service_id, struct PP_Var challenge, struct PP_Var* signed_data, struct PP_Var* signed_data_signature, struct PP_Var* platform_key_certificate, struct PP_CompletionCallback callback))&Pnacl_M31_PPB_PlatformVerification_Private_ChallengePlatform +}; struct PPB_Talk_Private_1_0 Pnacl_Wrappers_PPB_Talk_Private_1_0 = { .Create = (PP_Resource (*)(PP_Instance instance))&Pnacl_M19_PPB_Talk_Private_Create, @@ -4852,16 +5104,17 @@ struct PPB_X509Certificate_Private_0_1 Pnacl_Wrappers_PPB_X509Certificate_Privat .GetField = (struct PP_Var (*)(PP_Resource resource, PP_X509Certificate_Private_Field field))&Pnacl_M19_PPB_X509Certificate_Private_GetField }; -struct PPP_ContentDecryptor_Private_0_6 Pnacl_Wrappers_PPP_ContentDecryptor_Private_0_6 = { - .GenerateKeyRequest = &Pnacl_M24_PPP_ContentDecryptor_Private_GenerateKeyRequest, - .AddKey = &Pnacl_M24_PPP_ContentDecryptor_Private_AddKey, - .CancelKeyRequest = &Pnacl_M24_PPP_ContentDecryptor_Private_CancelKeyRequest, - .Decrypt = &Pnacl_M24_PPP_ContentDecryptor_Private_Decrypt, - .InitializeAudioDecoder = &Pnacl_M24_PPP_ContentDecryptor_Private_InitializeAudioDecoder, - .InitializeVideoDecoder = &Pnacl_M24_PPP_ContentDecryptor_Private_InitializeVideoDecoder, - .DeinitializeDecoder = &Pnacl_M24_PPP_ContentDecryptor_Private_DeinitializeDecoder, - .ResetDecoder = &Pnacl_M24_PPP_ContentDecryptor_Private_ResetDecoder, - .DecryptAndDecode = &Pnacl_M24_PPP_ContentDecryptor_Private_DecryptAndDecode +struct PPP_ContentDecryptor_Private_0_7 Pnacl_Wrappers_PPP_ContentDecryptor_Private_0_7 = { + .Initialize = &Pnacl_M31_PPP_ContentDecryptor_Private_Initialize, + .GenerateKeyRequest = &Pnacl_M31_PPP_ContentDecryptor_Private_GenerateKeyRequest, + .AddKey = &Pnacl_M31_PPP_ContentDecryptor_Private_AddKey, + .CancelKeyRequest = &Pnacl_M31_PPP_ContentDecryptor_Private_CancelKeyRequest, + .Decrypt = &Pnacl_M31_PPP_ContentDecryptor_Private_Decrypt, + .InitializeAudioDecoder = &Pnacl_M31_PPP_ContentDecryptor_Private_InitializeAudioDecoder, + .InitializeVideoDecoder = &Pnacl_M31_PPP_ContentDecryptor_Private_InitializeVideoDecoder, + .DeinitializeDecoder = &Pnacl_M31_PPP_ContentDecryptor_Private_DeinitializeDecoder, + .ResetDecoder = &Pnacl_M31_PPP_ContentDecryptor_Private_ResetDecoder, + .DecryptAndDecode = &Pnacl_M31_PPP_ContentDecryptor_Private_DecryptAndDecode }; /* Not generating wrapper interface for PPP_Flash_BrowserOperations_1_0 */ @@ -5054,6 +5307,18 @@ static struct __PnaclWrapperInfo Pnacl_WrapperInfo_PPB_NetAddress_1_0 = { .real_iface = NULL }; +static struct __PnaclWrapperInfo Pnacl_WrapperInfo_PPB_NetworkList_1_0 = { + .iface_macro = PPB_NETWORKLIST_INTERFACE_1_0, + .wrapped_iface = (void *) &Pnacl_Wrappers_PPB_NetworkList_1_0, + .real_iface = NULL +}; + +static struct __PnaclWrapperInfo Pnacl_WrapperInfo_PPB_NetworkMonitor_1_0 = { + .iface_macro = PPB_NETWORKMONITOR_INTERFACE_1_0, + .wrapped_iface = (void *) &Pnacl_Wrappers_PPB_NetworkMonitor_1_0, + .real_iface = NULL +}; + static struct __PnaclWrapperInfo Pnacl_WrapperInfo_PPB_NetworkProxy_1_0 = { .iface_macro = PPB_NETWORKPROXY_INTERFACE_1_0, .wrapped_iface = (void *) &Pnacl_Wrappers_PPB_NetworkProxy_1_0, @@ -5066,6 +5331,12 @@ static struct __PnaclWrapperInfo Pnacl_WrapperInfo_PPB_TCPSocket_1_0 = { .real_iface = NULL }; +static struct __PnaclWrapperInfo Pnacl_WrapperInfo_PPB_TCPSocket_1_1 = { + .iface_macro = PPB_TCPSOCKET_INTERFACE_1_1, + .wrapped_iface = (void *) &Pnacl_Wrappers_PPB_TCPSocket_1_1, + .real_iface = NULL +}; + static struct __PnaclWrapperInfo Pnacl_WrapperInfo_PPB_TextInputController_1_0 = { .iface_macro = PPB_TEXTINPUTCONTROLLER_INTERFACE_1_0, .wrapped_iface = (void *) &Pnacl_Wrappers_PPB_TextInputController_1_0, @@ -5192,6 +5463,12 @@ static struct __PnaclWrapperInfo Pnacl_WrapperInfo_PPB_IMEInputEvent_Dev_0_2 = { .real_iface = NULL }; +static struct __PnaclWrapperInfo Pnacl_WrapperInfo_PPB_KeyboardInputEvent_Dev_0_2 = { + .iface_macro = PPB_KEYBOARD_INPUT_EVENT_DEV_INTERFACE_0_2, + .wrapped_iface = (void *) &Pnacl_Wrappers_PPB_KeyboardInputEvent_Dev_0_2, + .real_iface = NULL +}; + static struct __PnaclWrapperInfo Pnacl_WrapperInfo_PPB_Printing_Dev_0_7 = { .iface_macro = PPB_PRINTING_DEV_INTERFACE_0_7, .wrapped_iface = (void *) &Pnacl_Wrappers_PPB_Printing_Dev_0_7, @@ -5228,6 +5505,12 @@ static struct __PnaclWrapperInfo Pnacl_WrapperInfo_PPB_URLUtil_Dev_0_6 = { .real_iface = NULL }; +static struct __PnaclWrapperInfo Pnacl_WrapperInfo_PPB_URLUtil_Dev_0_7 = { + .iface_macro = PPB_URLUTIL_DEV_INTERFACE_0_7, + .wrapped_iface = (void *) &Pnacl_Wrappers_PPB_URLUtil_Dev_0_7, + .real_iface = NULL +}; + static struct __PnaclWrapperInfo Pnacl_WrapperInfo_PPB_VideoCapture_Dev_0_2 = { .iface_macro = PPB_VIDEOCAPTURE_DEV_INTERFACE_0_2, .wrapped_iface = (void *) &Pnacl_Wrappers_PPB_VideoCapture_Dev_0_2, @@ -5252,9 +5535,9 @@ static struct __PnaclWrapperInfo Pnacl_WrapperInfo_PPP_Selection_Dev_0_3 = { .real_iface = NULL }; -static struct __PnaclWrapperInfo Pnacl_WrapperInfo_PPB_ContentDecryptor_Private_0_6 = { - .iface_macro = PPB_CONTENTDECRYPTOR_PRIVATE_INTERFACE_0_6, - .wrapped_iface = (void *) &Pnacl_Wrappers_PPB_ContentDecryptor_Private_0_6, +static struct __PnaclWrapperInfo Pnacl_WrapperInfo_PPB_ContentDecryptor_Private_0_7 = { + .iface_macro = PPB_CONTENTDECRYPTOR_PRIVATE_INTERFACE_0_7, + .wrapped_iface = (void *) &Pnacl_Wrappers_PPB_ContentDecryptor_Private_0_7, .real_iface = NULL }; @@ -5366,9 +5649,15 @@ static struct __PnaclWrapperInfo Pnacl_WrapperInfo_PPB_NetAddress_Private_1_1 = .real_iface = NULL }; -static struct __PnaclWrapperInfo Pnacl_WrapperInfo_PPB_NetworkList_Private_0_2 = { - .iface_macro = PPB_NETWORKLIST_PRIVATE_INTERFACE_0_2, - .wrapped_iface = (void *) &Pnacl_Wrappers_PPB_NetworkList_Private_0_2, +static struct __PnaclWrapperInfo Pnacl_WrapperInfo_PPB_OutputProtection_Private_0_1 = { + .iface_macro = PPB_OUTPUTPROTECTION_PRIVATE_INTERFACE_0_1, + .wrapped_iface = (void *) &Pnacl_Wrappers_PPB_OutputProtection_Private_0_1, + .real_iface = NULL +}; + +static struct __PnaclWrapperInfo Pnacl_WrapperInfo_PPB_PlatformVerification_Private_0_1 = { + .iface_macro = PPB_PLATFORMVERIFICATION_PRIVATE_INTERFACE_0_1, + .wrapped_iface = (void *) &Pnacl_Wrappers_PPB_PlatformVerification_Private_0_1, .real_iface = NULL }; @@ -5456,9 +5745,9 @@ static struct __PnaclWrapperInfo Pnacl_WrapperInfo_PPB_X509Certificate_Private_0 .real_iface = NULL }; -static struct __PnaclWrapperInfo Pnacl_WrapperInfo_PPP_ContentDecryptor_Private_0_6 = { - .iface_macro = PPP_CONTENTDECRYPTOR_PRIVATE_INTERFACE_0_6, - .wrapped_iface = (void *) &Pnacl_Wrappers_PPP_ContentDecryptor_Private_0_6, +static struct __PnaclWrapperInfo Pnacl_WrapperInfo_PPP_ContentDecryptor_Private_0_7 = { + .iface_macro = PPP_CONTENTDECRYPTOR_PRIVATE_INTERFACE_0_7, + .wrapped_iface = (void *) &Pnacl_Wrappers_PPP_ContentDecryptor_Private_0_7, .real_iface = NULL }; @@ -5514,8 +5803,11 @@ static struct __PnaclWrapperInfo *s_ppb_wrappers[] = { &Pnacl_WrapperInfo_PPB_Messaging_1_0, &Pnacl_WrapperInfo_PPB_MouseLock_1_0, &Pnacl_WrapperInfo_PPB_NetAddress_1_0, + &Pnacl_WrapperInfo_PPB_NetworkList_1_0, + &Pnacl_WrapperInfo_PPB_NetworkMonitor_1_0, &Pnacl_WrapperInfo_PPB_NetworkProxy_1_0, &Pnacl_WrapperInfo_PPB_TCPSocket_1_0, + &Pnacl_WrapperInfo_PPB_TCPSocket_1_1, &Pnacl_WrapperInfo_PPB_TextInputController_1_0, &Pnacl_WrapperInfo_PPB_UDPSocket_1_0, &Pnacl_WrapperInfo_PPB_URLLoader_1_0, @@ -5536,16 +5828,18 @@ static struct __PnaclWrapperInfo *s_ppb_wrappers[] = { &Pnacl_WrapperInfo_PPB_Font_Dev_0_6, &Pnacl_WrapperInfo_PPB_IMEInputEvent_Dev_0_1, &Pnacl_WrapperInfo_PPB_IMEInputEvent_Dev_0_2, + &Pnacl_WrapperInfo_PPB_KeyboardInputEvent_Dev_0_2, &Pnacl_WrapperInfo_PPB_Printing_Dev_0_7, &Pnacl_WrapperInfo_PPB_Testing_Dev_0_9, &Pnacl_WrapperInfo_PPB_Testing_Dev_0_91, &Pnacl_WrapperInfo_PPB_Testing_Dev_0_92, &Pnacl_WrapperInfo_PPB_TrueTypeFont_Dev_0_1, &Pnacl_WrapperInfo_PPB_URLUtil_Dev_0_6, + &Pnacl_WrapperInfo_PPB_URLUtil_Dev_0_7, &Pnacl_WrapperInfo_PPB_VideoCapture_Dev_0_2, &Pnacl_WrapperInfo_PPB_VideoCapture_Dev_0_3, &Pnacl_WrapperInfo_PPB_VideoDecoder_Dev_0_16, - &Pnacl_WrapperInfo_PPB_ContentDecryptor_Private_0_6, + &Pnacl_WrapperInfo_PPB_ContentDecryptor_Private_0_7, &Pnacl_WrapperInfo_PPB_Ext_CrxFileSystem_Private_0_1, &Pnacl_WrapperInfo_PPB_FileIO_Private_0_1, &Pnacl_WrapperInfo_PPB_FileRefPrivate_0_1, @@ -5564,7 +5858,8 @@ static struct __PnaclWrapperInfo *s_ppb_wrappers[] = { &Pnacl_WrapperInfo_PPB_NetAddress_Private_0_1, &Pnacl_WrapperInfo_PPB_NetAddress_Private_1_0, &Pnacl_WrapperInfo_PPB_NetAddress_Private_1_1, - &Pnacl_WrapperInfo_PPB_NetworkList_Private_0_2, + &Pnacl_WrapperInfo_PPB_OutputProtection_Private_0_1, + &Pnacl_WrapperInfo_PPB_PlatformVerification_Private_0_1, &Pnacl_WrapperInfo_PPB_Talk_Private_1_0, &Pnacl_WrapperInfo_PPB_Talk_Private_2_0, &Pnacl_WrapperInfo_PPB_TCPServerSocket_Private_0_1, @@ -5589,7 +5884,7 @@ static struct __PnaclWrapperInfo *s_ppb_wrappers[] = { static struct __PnaclWrapperInfo *s_ppp_wrappers[] = { &Pnacl_WrapperInfo_PPP_Messaging_1_0, &Pnacl_WrapperInfo_PPP_Selection_Dev_0_3, - &Pnacl_WrapperInfo_PPP_ContentDecryptor_Private_0_6, + &Pnacl_WrapperInfo_PPP_ContentDecryptor_Private_0_7, &Pnacl_WrapperInfo_PPP_Instance_Private_0_1, NULL }; diff --git a/chromium/ppapi/native_client/tools/browser_tester/browser_tester.py b/chromium/ppapi/native_client/tools/browser_tester/browser_tester.py index 513a091605c..0fef6ea6713 100755 --- a/chromium/ppapi/native_client/tools/browser_tester/browser_tester.py +++ b/chromium/ppapi/native_client/tools/browser_tester/browser_tester.py @@ -47,6 +47,12 @@ def BuildArgParser(): metavar='DIRNAME', help='Add directory DIRNAME to be served from the HTTP ' 'server to be made visible under the root.') + parser.add_option('--output_dir', dest='output_dir', action='store', + type='string', default=None, + metavar='DIRNAME', + help='Set directory DIRNAME to be the output directory ' + 'when POSTing data to the server. NOTE: if this flag is ' + 'not set, POSTs will fail.') parser.add_option('--test_arg', dest='test_args', action='append', type='string', nargs=2, default=[], metavar='KEY VALUE', @@ -73,6 +79,10 @@ def BuildArgParser(): parser.add_option('--ppapi_plugin', dest='ppapi_plugin', action='store', type='string', default=None, help='Use the browser plugin located here.') + parser.add_option('--ppapi_plugin_mimetype', dest='ppapi_plugin_mimetype', + action='store', type='string', default='application/x-nacl', + help='Associate this mimetype with the browser plugin. ' + 'Unused if --ppapi_plugin is not specified.') parser.add_option('--sel_ldr', dest='sel_ldr', action='store', type='string', default=None, help='Use the sel_ldr located here.') @@ -138,6 +148,10 @@ def BuildArgParser(): parser.add_option('--enable_crash_reporter', dest='enable_crash_reporter', action='store_true', default=False, help='Force crash reporting on.') + parser.add_option('--enable_sockets', dest='enable_sockets', + action='store_true', default=False, + help='Pass --allow-nacl-socket-api=<host> to Chrome, where ' + '<host> is the name of the browser tester\'s web server.') return parser @@ -235,14 +249,15 @@ def RunTestsOnce(url, options): options.allow_404, options.bandwidth, listener, - options.serving_dirs) + options.serving_dirs, + options.output_dir) browser = browsertester.browserlauncher.ChromeLauncher(options) full_url = 'http://%s:%d/%s' % (host, port, url) if len(options.test_args) > 0: full_url += '?' + urllib.urlencode(options.test_args) - browser.Run(full_url, port) + browser.Run(full_url, host, port) server.TestingBegun(0.125) # In Python 2.5, server.handle_request may block indefinitely. Serving pages @@ -308,6 +323,13 @@ def RunTestsOnce(url, options): DumpNetLog(browser.NetLogName()) except Exception: listener.ever_failed = 1 + # Try to let the browser clean itself up normally before killing it. + sys.stdout.write('##################### Terminating the browser\n') + browser.WaitForProcessDeath() + if browser.IsRunning(): + sys.stdout.write('##################### TERM failed, KILLING\n') + # Always call Cleanup; it kills the process, but also removes the + # user-data-dir. browser.Cleanup() # We avoid calling server.server_close() here because it causes # the HTTP server thread to exit uncleanly with an EBADF error, diff --git a/chromium/ppapi/native_client/tools/browser_tester/browserdata/nacltest.js b/chromium/ppapi/native_client/tools/browser_tester/browserdata/nacltest.js index 6917d5a03de..59a1340075d 100644 --- a/chromium/ppapi/native_client/tools/browser_tester/browserdata/nacltest.js +++ b/chromium/ppapi/native_client/tools/browser_tester/browserdata/nacltest.js @@ -466,6 +466,17 @@ function embed_name(embed) { } +// Write data to the filesystem. This will only work if the browser_tester was +// initialized with --output_dir. +function outputFile(name, data, onload, onerror) { + var xhr = new XMLHttpRequest(); + xhr.onload = onload; + xhr.onerror = onerror; + xhr.open('POST', name, true); + xhr.send(data); +} + + // Webkit Bug Workaround // THIS SHOULD BE REMOVED WHEN Webkit IS FIXED // http://code.google.com/p/nativeclient/issues/detail?id=2428 diff --git a/chromium/ppapi/native_client/tools/browser_tester/browsertester/browserlauncher.py b/chromium/ppapi/native_client/tools/browser_tester/browsertester/browserlauncher.py index 256a1cb37f9..67ea29125e9 100755 --- a/chromium/ppapi/native_client/tools/browser_tester/browsertester/browserlauncher.py +++ b/chromium/ppapi/native_client/tools/browser_tester/browsertester/browserlauncher.py @@ -9,6 +9,7 @@ import shutil import sys import tempfile import time +import urlparse import browserprocess @@ -105,7 +106,7 @@ class BrowserLauncher(object): def CreateProfile(self): raise NotImplementedError - def MakeCmd(self, url): + def MakeCmd(self, url, host, port): raise NotImplementedError def CreateToolLogDir(self): @@ -205,12 +206,12 @@ class BrowserLauncher(object): def GetReturnCode(self): return self.browser_process.GetReturnCode() - def Run(self, url, port): + def Run(self, url, host, port): self.binary = EscapeSpaces(self.FindBinary()) self.profile = self.CreateProfile() if self.options.tool is not None: self.tool_log_dir = self.CreateToolLogDir() - cmd = self.MakeCmd(url, port) + cmd = self.MakeCmd(url, host, port) self.Launch(cmd, MakeEnv(self.options)) @@ -262,7 +263,7 @@ class ChromeLauncher(BrowserLauncher): def NetLogName(self): return os.path.join(self.profile, 'netlog.json') - def MakeCmd(self, url, port): + def MakeCmd(self, url, host, port): cmd = [self.binary, # Note that we do not use "--enable-logging" here because # it actually turns off logging to the Buildbot logs on @@ -279,6 +280,7 @@ class ChromeLauncher(BrowserLauncher): '--no-default-browser-check', '--log-level=1', '--safebrowsing-disable-auto-update', + '--disable-default-apps', # Suppress metrics reporting. This prevents misconfigured bots, # people testing at their desktop, etc from poisoning the UMA data. '--metrics-recording-only', @@ -302,8 +304,9 @@ class ChromeLauncher(BrowserLauncher): if disable_sandbox: cmd.append('--no-sandbox') else: - cmd.append('--register-pepper-plugins=%s;application/x-nacl' - % self.options.ppapi_plugin) + cmd.append('--register-pepper-plugins=%s;%s' + % (self.options.ppapi_plugin, + self.options.ppapi_plugin_mimetype)) cmd.append('--no-sandbox') if self.options.browser_extensions: cmd.append('--load-extension=%s' % @@ -335,6 +338,8 @@ class ChromeLauncher(BrowserLauncher): '--log-file=%s/log.%%p' % (self.tool_log_dir,)] + cmd elif self.options.tool != None: raise LaunchFailure('Invalid tool name "%s"' % (self.options.tool,)) + if self.options.enable_sockets: + cmd.append('--allow-nacl-socket-api=%s' % host) cmd.extend(self.options.browser_flags) cmd.append(url) return cmd diff --git a/chromium/ppapi/native_client/tools/browser_tester/browsertester/browserprocess.py b/chromium/ppapi/native_client/tools/browser_tester/browsertester/browserprocess.py index bca17340774..e10e6b5336f 100755 --- a/chromium/ppapi/native_client/tools/browser_tester/browsertester/browserprocess.py +++ b/chromium/ppapi/native_client/tools/browser_tester/browsertester/browserprocess.py @@ -21,7 +21,13 @@ class BrowserProcessBase(object): return self.handle.poll() is None def Wait(self, wait_steps, sleep_time): - self.term() + try: + self.term() + except Exception: + # Terminating the handle can raise an exception. There is likely no point + # in waiting if the termination didn't succeed. + return + i = 0 # subprocess.wait() doesn't have a timeout, unfortunately. while self.IsRunning() and i < wait_steps: diff --git a/chromium/ppapi/native_client/tools/browser_tester/browsertester/server.py b/chromium/ppapi/native_client/tools/browser_tester/browsertester/server.py index d1f9375b96e..971d0d6fc5e 100644 --- a/chromium/ppapi/native_client/tools/browser_tester/browsertester/server.py +++ b/chromium/ppapi/native_client/tools/browser_tester/browsertester/server.py @@ -124,8 +124,43 @@ class RequestHandler(SimpleHTTPServer.SimpleHTTPRequestHandler): self.end_headers() data = self.rfile.read(int(self.headers.getheader('content-length'))) self.wfile.write(data) + elif self.server.output_dir is not None: + # Try to write the file to disk. + path = self.NormalizePath(path) + output_path = os.path.join(self.server.output_dir, path) + try: + outfile = open(output_path, 'w') + except IOError: + error_message = 'File not found: %r' % output_path + self.server.listener.ServerError(error_message) + self.send_error(404, error_message) + return + + try: + data = self.rfile.read(int(self.headers.getheader('content-length'))) + outfile.write(data) + except IOError, e: + outfile.close() + try: + os.remove(output_path) + except OSError: + # Oh, well. + pass + error_message = 'Can\'t write file: %r\n' % output_path + error_message += 'Exception:\n%s' % str(e) + self.server.listener.ServerError(error_message) + self.send_error(500, error_message) + return + + outfile.close() + + # Send a success response. + self.send_response(200) + self.end_headers() else: - self.send_error(404, 'File not found') + error_message = 'File not found: %r' % path + self.server.listener.ServerError(error_message) + self.send_error(404, error_message) self.server.ResetTimeout() @@ -214,8 +249,8 @@ class RequestHandler(SimpleHTTPServer.SimpleHTTPRequestHandler): class Server(SocketServer.ThreadingMixIn, BaseHTTPServer.HTTPServer): def Configure( - self, file_mapping, redirect_mapping, extensions_mapping, allow_404, - bandwidth, listener, serving_dirs=[]): + self, file_mapping, redirect_mapping, extensions_mapping, allow_404, + bandwidth, listener, serving_dirs=[], output_dir=None): self.file_mapping = file_mapping self.redirect_mapping = redirect_mapping self.extensions_mapping.update(extensions_mapping) @@ -224,6 +259,7 @@ class Server(SocketServer.ThreadingMixIn, BaseHTTPServer.HTTPServer): self.listener = listener self.rpc_lock = threading.Lock() self.serving_dirs = serving_dirs + self.output_dir = output_dir def TestingBegun(self, timeout): self.test_in_progress = True diff --git a/chromium/ppapi/ppapi_internal.gyp b/chromium/ppapi/ppapi_internal.gyp index 08c1579c677..26bd9c4f0e4 100644 --- a/chromium/ppapi/ppapi_internal.gyp +++ b/chromium/ppapi/ppapi_internal.gyp @@ -48,6 +48,7 @@ '../gpu/command_buffer/command_buffer.gyp:gles2_utils', '../gpu/gpu.gyp:command_buffer_client', '../gpu/gpu.gyp:gles2_implementation', + '../ipc/ipc.gyp:ipc', '../media/media.gyp:shared_memory_support', '../skia/skia.gyp:skia', '../third_party/icu/icu.gyp:icuuc', @@ -225,6 +226,7 @@ 'ppapi.gyp:ppapi_c', '../base/base.gyp:base_nacl_win64', '../base/third_party/dynamic_annotations/dynamic_annotations.gyp:dynamic_annotations_win64', + '../ipc/ipc.gyp:ipc_win64', ], 'defines': [ '<@(nacl_win64_defines)', diff --git a/chromium/ppapi/ppapi_ipc_untrusted.gyp b/chromium/ppapi/ppapi_ipc_untrusted.gyp index 9b0b6785aac..9e13867308b 100644 --- a/chromium/ppapi/ppapi_ipc_untrusted.gyp +++ b/chromium/ppapi/ppapi_ipc_untrusted.gyp @@ -22,7 +22,7 @@ 'nacl_untrusted_build': 1, 'nlib_target': 'libppapi_ipc_untrusted.a', 'build_glibc': 0, - 'build_newlib': 1, + 'build_newlib': 0, 'build_irt': 1, }, 'include_dirs': [ diff --git a/chromium/ppapi/ppapi_proxy.gypi b/chromium/ppapi/ppapi_proxy.gypi index 884dc15817e..267402d6f5d 100644 --- a/chromium/ppapi/ppapi_proxy.gypi +++ b/chromium/ppapi/ppapi_proxy.gypi @@ -33,10 +33,12 @@ 'proxy/dispatcher.cc', 'proxy/dispatcher.h', 'proxy/enter_proxy.h', - 'proxy/extensions_common_resource.cc', - 'proxy/extensions_common_resource.h', + 'proxy/error_conversion.cc', + 'proxy/error_conversion.h', 'proxy/ext_crx_file_system_private_resource.cc', 'proxy/ext_crx_file_system_private_resource.h', + 'proxy/extensions_common_resource.cc', + 'proxy/extensions_common_resource.h', 'proxy/file_chooser_resource.cc', 'proxy/file_chooser_resource.h', 'proxy/file_ref_resource.cc', @@ -80,10 +82,16 @@ 'proxy/locking_resource_releaser.h', 'proxy/net_address_resource.cc', 'proxy/net_address_resource.h', + 'proxy/network_list_resource.cc', + 'proxy/network_list_resource.h', + 'proxy/network_monitor_resource.cc', + 'proxy/network_monitor_resource.h', 'proxy/network_proxy_resource.cc', 'proxy/network_proxy_resource.h', 'proxy/pdf_resource.cc', 'proxy/pdf_resource.h', + 'proxy/platform_verification_private_resource.cc', + 'proxy/platform_verification_private_resource.h', 'proxy/plugin_array_buffer_var.cc', 'proxy/plugin_array_buffer_var.h', 'proxy/plugin_dispatcher.cc', @@ -97,12 +105,14 @@ 'proxy/plugin_resource.h', 'proxy/plugin_resource_tracker.cc', 'proxy/plugin_resource_tracker.h', + 'proxy/plugin_resource_var.cc', + 'proxy/plugin_resource_var.h', 'proxy/plugin_var_serialization_rules.cc', 'proxy/plugin_var_serialization_rules.h', 'proxy/plugin_var_tracker.cc', 'proxy/plugin_var_tracker.h', - 'proxy/ppapi_command_buffer_proxy.h', 'proxy/ppapi_command_buffer_proxy.cc', + 'proxy/ppapi_command_buffer_proxy.h', 'proxy/ppapi_messages.h', 'proxy/ppapi_message_utils.h', 'proxy/ppb_audio_proxy.cc', @@ -113,8 +123,6 @@ 'proxy/ppb_buffer_proxy.h', 'proxy/ppb_core_proxy.cc', 'proxy/ppb_core_proxy.h', - 'proxy/ppb_file_ref_proxy.cc', - 'proxy/ppb_file_ref_proxy.h', 'proxy/ppb_flash_message_loop_proxy.cc', 'proxy/ppb_flash_message_loop_proxy.h', 'proxy/ppb_graphics_3d_proxy.cc', @@ -125,12 +133,6 @@ 'proxy/ppb_instance_proxy.h', 'proxy/ppb_message_loop_proxy.cc', 'proxy/ppb_message_loop_proxy.h', - 'proxy/ppb_network_monitor_private_proxy.cc', - 'proxy/ppb_network_monitor_private_proxy.h', - 'proxy/ppb_tcp_socket_proxy.cc', - 'proxy/ppb_tcp_socket_proxy.h', - 'proxy/ppb_tcp_socket_private_proxy.cc', - 'proxy/ppb_tcp_socket_private_proxy.h', 'proxy/ppb_testing_proxy.cc', 'proxy/ppb_testing_proxy.h', 'proxy/ppb_var_deprecated_proxy.cc', @@ -178,6 +180,12 @@ 'proxy/talk_resource.h', 'proxy/tcp_server_socket_private_resource.cc', 'proxy/tcp_server_socket_private_resource.h', + 'proxy/tcp_socket_private_resource.cc', + 'proxy/tcp_socket_private_resource.h', + 'proxy/tcp_socket_resource.cc', + 'proxy/tcp_socket_resource.h', + 'proxy/tcp_socket_resource_base.cc', + 'proxy/tcp_socket_resource_base.h', 'proxy/truetype_font_resource.cc', 'proxy/truetype_font_resource.h', 'proxy/truetype_font_singleton_resource.cc', @@ -227,6 +235,8 @@ 'proxy/host_dispatcher.cc', 'proxy/host_var_serialization_rules.cc', 'proxy/pdf_resource.cc', + 'proxy/platform_verification_private_resource.cc', + 'proxy/platform_verification_private_resource.h', 'proxy/ppb_broker_proxy.cc', 'proxy/ppb_buffer_proxy.cc', 'proxy/ppb_flash_message_loop_proxy.cc', diff --git a/chromium/ppapi/ppapi_proxy_untrusted.gyp b/chromium/ppapi/ppapi_proxy_untrusted.gyp index 727fbb5cf81..35dff872947 100644 --- a/chromium/ppapi/ppapi_proxy_untrusted.gyp +++ b/chromium/ppapi/ppapi_proxy_untrusted.gyp @@ -21,7 +21,7 @@ 'nacl_untrusted_build': 1, 'nlib_target': 'libppapi_proxy_untrusted.a', 'build_glibc': 0, - 'build_newlib': 1, + 'build_newlib': 0, 'build_irt': 1, }, 'include_dirs': [ diff --git a/chromium/ppapi/ppapi_shared.gypi b/chromium/ppapi/ppapi_shared.gypi index 1160143b771..7edeb2f2252 100644 --- a/chromium/ppapi/ppapi_shared.gypi +++ b/chromium/ppapi/ppapi_shared.gypi @@ -23,6 +23,7 @@ 'shared_impl/file_io_state_manager.h', 'shared_impl/file_path.cc', 'shared_impl/file_path.h', + 'shared_impl/file_ref_create_info.cc', 'shared_impl/file_ref_create_info.h', 'shared_impl/file_ref_util.cc', 'shared_impl/file_ref_util.h', @@ -53,8 +54,6 @@ 'shared_impl/ppb_crypto_shared.cc', 'shared_impl/ppb_device_ref_shared.cc', 'shared_impl/ppb_device_ref_shared.h', - 'shared_impl/ppb_file_ref_shared.cc', - 'shared_impl/ppb_file_ref_shared.h', 'shared_impl/ppb_gamepad_shared.cc', 'shared_impl/ppb_gamepad_shared.h', 'shared_impl/ppb_graphics_3d_shared.cc', @@ -68,12 +67,12 @@ 'shared_impl/ppb_memory_shared.cc', 'shared_impl/ppb_message_loop_shared.cc', 'shared_impl/ppb_message_loop_shared.h', - 'shared_impl/ppb_network_list_private_shared.cc', - 'shared_impl/ppb_network_list_private_shared.h', 'shared_impl/ppb_opengles2_shared.cc', 'shared_impl/ppb_opengles2_shared.h', 'shared_impl/ppb_resource_array_shared.cc', 'shared_impl/ppb_resource_array_shared.h', + 'shared_impl/ppb_tcp_socket_shared.cc', + 'shared_impl/ppb_tcp_socket_shared.h', 'shared_impl/ppb_trace_event_impl.cc', 'shared_impl/ppb_trace_event_impl.h', 'shared_impl/ppb_url_util_shared.cc', @@ -93,14 +92,14 @@ 'shared_impl/resource.h', 'shared_impl/resource_tracker.cc', 'shared_impl/resource_tracker.h', + 'shared_impl/resource_var.cc', + 'shared_impl/resource_var.h', 'shared_impl/scoped_pp_resource.cc', 'shared_impl/scoped_pp_resource.h', 'shared_impl/scoped_pp_var.cc', 'shared_impl/scoped_pp_var.h', 'shared_impl/socket_option_data.cc', 'shared_impl/socket_option_data.h', - 'shared_impl/tcp_socket_shared.cc', - 'shared_impl/tcp_socket_shared.h', 'shared_impl/thread_aware_callback.cc', 'shared_impl/thread_aware_callback.h', 'shared_impl/time_conversion.cc', @@ -126,8 +125,6 @@ 'shared_impl/private/ppb_char_set_shared.h', 'shared_impl/private/ppb_x509_certificate_private_shared.cc', 'shared_impl/private/ppb_x509_certificate_private_shared.h', - 'shared_impl/private/tcp_socket_private_impl.cc', - 'shared_impl/private/tcp_socket_private_impl.h', 'thunk/enter.cc', 'thunk/enter.h', @@ -211,13 +208,15 @@ 'thunk/ppb_net_address_api.h', 'thunk/ppb_net_address_thunk.cc', 'thunk/ppb_network_list_api.h', - 'thunk/ppb_network_list_private_thunk.cc', - 'thunk/ppb_network_monitor_private_api.h', - 'thunk/ppb_network_monitor_private_thunk.cc', + 'thunk/ppb_network_list_thunk.cc', + 'thunk/ppb_network_monitor_api.h', + 'thunk/ppb_network_monitor_thunk.cc', 'thunk/ppb_network_proxy_api.h', 'thunk/ppb_network_proxy_thunk.cc', 'thunk/ppb_pdf_api.h', 'thunk/ppb_pdf_thunk.cc', + 'thunk/ppb_platform_verification_api.h', + 'thunk/ppb_platform_verification_private_thunk.cc', 'thunk/ppb_printing_api.h', 'thunk/ppb_printing_dev_thunk.cc', 'thunk/ppb_resource_array_api.h', @@ -306,6 +305,7 @@ 'thunk/ppb_flash_message_loop_thunk.cc', 'thunk/ppb_gles_chromium_texture_mapping_thunk.cc', 'thunk/ppb_pdf_thunk.cc', + 'thunk/ppb_platform_verification_private_thunk.cc', 'thunk/ppb_scrollbar_thunk.cc', 'thunk/ppb_talk_private_thunk.cc', 'thunk/ppb_transport_thunk.cc', @@ -323,12 +323,8 @@ 'shared_impl/ppb_opengles2_shared.cc', 'shared_impl/private/ppb_host_resolver_shared.cc', 'shared_impl/private/net_address_private_impl.cc', - 'shared_impl/private/tcp_socket_private_impl.cc', - 'shared_impl/private/udp_socket_private_impl.cc', 'thunk/ppb_graphics_3d_thunk.cc', 'thunk/ppb_host_resolver_private_thunk.cc', - 'thunk/ppb_network_list_private_thunk.cc', - 'thunk/ppb_network_monitor_private_thunk.cc', 'thunk/ppb_tcp_server_socket_private_thunk.cc', 'thunk/ppb_tcp_socket_private_thunk.cc', 'thunk/ppb_udp_socket_private_thunk.cc', diff --git a/chromium/ppapi/ppapi_shared_untrusted.gyp b/chromium/ppapi/ppapi_shared_untrusted.gyp index 4043c3a039f..453e711b06a 100644 --- a/chromium/ppapi/ppapi_shared_untrusted.gyp +++ b/chromium/ppapi/ppapi_shared_untrusted.gyp @@ -22,7 +22,7 @@ 'nacl_untrusted_build': 1, 'nlib_target': 'libppapi_shared_untrusted.a', 'build_glibc': 0, - 'build_newlib': 1, + 'build_newlib': 0, 'build_irt': 1, }, 'include_dirs': [ diff --git a/chromium/ppapi/ppapi_sources.gypi b/chromium/ppapi/ppapi_sources.gypi index c6f7b0190ae..6ec54b7000a 100644 --- a/chromium/ppapi/ppapi_sources.gypi +++ b/chromium/ppapi/ppapi_sources.gypi @@ -44,7 +44,8 @@ 'c/ppb_mouse_cursor.h', 'c/ppb_mouse_lock.h', 'c/ppb_net_address.h', - 'c/ppb_network_proxy.h', + 'c/ppb_network_list.h', + 'c/ppb_network_monitor.h', 'c/ppb_network_proxy.h', 'c/ppb_opengles2.h', 'c/ppb_tcp_socket.h', @@ -110,16 +111,14 @@ 'c/private/ppb_flash_fullscreen.h', 'c/private/ppb_flash_menu.h', 'c/private/ppb_flash_message_loop.h', - 'c/private/ppb_gpu_blacklist_private.h', 'c/private/ppb_host_resolver_private.h', 'c/private/ppb_instance_private.h', 'c/private/ppb_nacl_private.h', 'c/private/ppb_net_address_private.h', 'c/private/ppb_pdf.h', + 'c/private/ppb_platform_verification_private.h', 'c/private/ppb_proxy_private.h', 'c/private/ppp_instance_private.h', - 'c/private/ppb_network_list_private.h', - 'c/private/ppb_network_monitor_private.h', 'c/private/ppb_tcp_server_socket_private.h', 'c/private/ppb_tcp_socket_private.h', 'c/private/ppb_udp_socket_private.h', @@ -194,6 +193,10 @@ 'cpp/mouse_lock.h', 'cpp/net_address.cc', 'cpp/net_address.h', + 'cpp/network_list.cc', + 'cpp/network_list.h', + 'cpp/network_monitor.cc', + 'cpp/network_monitor.h', 'cpp/network_proxy.cc', 'cpp/network_proxy.h', 'cpp/output_traits.h', @@ -318,14 +321,12 @@ 'cpp/private/instance_private.h', 'cpp/private/net_address_private.cc', 'cpp/private/net_address_private.h', - 'cpp/private/network_list_private.cc', - 'cpp/private/network_list_private.h', - 'cpp/private/network_monitor_private.cc', - 'cpp/private/network_monitor_private.h', 'cpp/private/pass_file_handle.cc', 'cpp/private/pass_file_handle.h', 'cpp/private/pdf.cc', 'cpp/private/pdf.h', + 'cpp/private/platform_verification.cc', + 'cpp/private/platform_verification.h', 'cpp/private/tcp_server_socket_private.cc', 'cpp/private/tcp_server_socket_private.h', 'cpp/private/tcp_socket_private.cc', @@ -375,8 +376,6 @@ 'utility/graphics/paint_aggregator.h', 'utility/graphics/paint_manager.cc', 'utility/graphics/paint_manager.h', - 'utility/private/network_list_observer_private.cc', - 'utility/private/network_list_observer_private.h', 'utility/threading/lock.cc', 'utility/threading/lock.h', 'utility/threading/simple_thread.cc', @@ -447,8 +446,8 @@ 'tests/test_net_address.h', 'tests/test_net_address_private_untrusted.cc', 'tests/test_net_address_private_untrusted.h', - 'tests/test_network_monitor_private.cc', - 'tests/test_network_monitor_private.h', + 'tests/test_network_monitor.cc', + 'tests/test_network_monitor.h', 'tests/test_network_proxy.cc', 'tests/test_network_proxy.h', 'tests/test_paint_aggregator.cc', @@ -538,6 +537,8 @@ 'tests/test_net_address_private.h', 'tests/test_pdf.cc', 'tests/test_pdf.h', + 'tests/test_platform_verification_private.cc', + 'tests/test_platform_verification_private.h', 'tests/test_resource_array.cc', 'tests/test_resource_array.h', 'tests/test_struct_sizes.c', diff --git a/chromium/ppapi/ppapi_tests.gypi b/chromium/ppapi/ppapi_tests.gypi index 3a1ac8735b6..4f439bafa42 100644 --- a/chromium/ppapi/ppapi_tests.gypi +++ b/chromium/ppapi/ppapi_tests.gypi @@ -143,6 +143,7 @@ 'ppapi_proxy', 'ppapi_shared', 'ppapi_unittest_shared', + '../base/base.gyp:run_all_unittests', '../base/base.gyp:test_support_base', '../gpu/gpu.gyp:gpu_ipc', '../ipc/ipc.gyp:ipc', @@ -157,8 +158,6 @@ '../ppapi', ], 'sources': [ - 'proxy/run_all_unittests.cc', - 'host/resource_message_filter_unittest.cc', # Piggy back on ppapi_unittests for a simple NaCl unittest, # which must not have dependencies on anything other than stdlibs. @@ -219,9 +218,6 @@ ['os_posix==1 and OS!="mac"', { 'cflags': ['-fvisibility=hidden'], 'type': 'shared_library', - # -gstabs, used in the official builds, causes an ICE. Simply remove - # it. - 'cflags!': ['-gstabs'], }], ['OS=="win"', { 'type': 'shared_library', diff --git a/chromium/ppapi/proxy/error_conversion.cc b/chromium/ppapi/proxy/error_conversion.cc new file mode 100644 index 00000000000..f3587ec671d --- /dev/null +++ b/chromium/ppapi/proxy/error_conversion.cc @@ -0,0 +1,26 @@ +// Copyright 2013 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/proxy/error_conversion.h" + +#include "ppapi/c/pp_errors.h" + +namespace ppapi { +namespace proxy { + +int32_t ConvertNetworkAPIErrorForCompatibility(int32_t pp_error, + bool private_api) { + // The private API doesn't return network-specific error codes or + // PP_ERROR_NOACCESS. In order to preserve the behavior, we convert those to + // PP_ERROR_FAILED. + if (private_api && + (pp_error <= PP_ERROR_CONNECTION_CLOSED || + pp_error == PP_ERROR_NOACCESS)) { + return PP_ERROR_FAILED; + } + return pp_error; +} + +} // namespace proxy +} // namespace ppapi diff --git a/chromium/ppapi/proxy/error_conversion.h b/chromium/ppapi/proxy/error_conversion.h new file mode 100644 index 00000000000..84bfb13a0ef --- /dev/null +++ b/chromium/ppapi/proxy/error_conversion.h @@ -0,0 +1,24 @@ +// Copyright 2013 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_PROXY_ERROR_CONVERSION_H_ +#define PPAPI_PROXY_ERROR_CONVERSION_H_ + +#include "ppapi/c/pp_stdint.h" +#include "ppapi/proxy/ppapi_proxy_export.h" + +namespace ppapi { +namespace proxy { + +// When |private_api| is true, coverts all network-related errors +; +// PP_ERROR_NOACCESS to PP_ERROR_FAILED. Otherwise, returns |pp_error| +// as is. +PPAPI_PROXY_EXPORT int32_t ConvertNetworkAPIErrorForCompatibility( + int32_t pp_error, + bool private_api); + +} // namespace proxy +} // namespace ppapi + +#endif // PPAPI_PROXY_ERROR_CONVERSION_H_ diff --git a/chromium/ppapi/proxy/ext_crx_file_system_private_resource.cc b/chromium/ppapi/proxy/ext_crx_file_system_private_resource.cc index f0de598c2de..be4c3f7bbd5 100644 --- a/chromium/ppapi/proxy/ext_crx_file_system_private_resource.cc +++ b/chromium/ppapi/proxy/ext_crx_file_system_private_resource.cc @@ -6,6 +6,8 @@ #include "base/bind.h" #include "ppapi/c/pp_errors.h" +#include "ppapi/c/pp_file_info.h" +#include "ppapi/proxy/file_system_resource.h" #include "ppapi/proxy/ppapi_messages.h" #include "ppapi/proxy/resource_message_params.h" #include "ppapi/shared_impl/host_resource.h" @@ -15,6 +17,13 @@ namespace ppapi { namespace proxy { +namespace { +void RunTrackedCallback(scoped_refptr<TrackedCallback> callback, + int32_t rc) { + callback->Run(rc); +} +} // namespace + ExtCrxFileSystemPrivateResource::ExtCrxFileSystemPrivateResource( Connection connection, PP_Instance instance) : PluginResource(connection, instance), called_open_(false) { @@ -61,19 +70,12 @@ void ExtCrxFileSystemPrivateResource::OnBrowserOpenComplete( return; } - thunk::EnterResourceCreationNoLock enter(pp_instance()); - if (enter.failed()) { - callback->Run(enter.retval()); - return; - } - - *file_system_resource = enter.functions()->CreateIsolatedFileSystem( - pp_instance(), fsid.c_str()); - if (*file_system_resource != 0) { - callback->Run(PP_OK); - } else { + FileSystemResource* fs = new FileSystemResource( + connection(), pp_instance(), PP_FILESYSTEMTYPE_ISOLATED); + *file_system_resource = fs->GetReference(); + if (*file_system_resource == 0) callback->Run(PP_ERROR_FAILED); - } + fs->InitIsolatedFileSystem(fsid, base::Bind(&RunTrackedCallback, callback)); } } // namespace proxy diff --git a/chromium/ppapi/proxy/file_chooser_resource.cc b/chromium/ppapi/proxy/file_chooser_resource.cc index ebd545cfc38..9847e295c9c 100644 --- a/chromium/ppapi/proxy/file_chooser_resource.cc +++ b/chromium/ppapi/proxy/file_chooser_resource.cc @@ -9,8 +9,8 @@ #include "ipc/ipc_message.h" #include "ppapi/c/pp_errors.h" #include "ppapi/proxy/dispatch_reply_message.h" +#include "ppapi/proxy/file_ref_resource.h" #include "ppapi/proxy/ppapi_messages.h" -#include "ppapi/proxy/ppb_file_ref_proxy.h" #include "ppapi/shared_impl/var.h" namespace ppapi { @@ -100,19 +100,25 @@ void FileChooserResource::PopulateAcceptTypes( void FileChooserResource::OnPluginMsgShowReply( const ResourceMessageReplyParams& params, - const std::vector<PPB_FileRef_CreateInfo>& chosen_files) { + const std::vector<FileRefCreateInfo>& chosen_files) { if (output_.is_valid()) { // Using v0.6 of the API with the output array. std::vector<PP_Resource> files; - for (size_t i = 0; i < chosen_files.size(); i++) - files.push_back(PPB_FileRef_Proxy::DeserializeFileRef(chosen_files[i])); + for (size_t i = 0; i < chosen_files.size(); i++) { + files.push_back(FileRefResource::CreateFileRef( + connection(), + pp_instance(), + chosen_files[i])); + } output_.StoreResourceVector(files); } else { // Convert each of the passed in file infos to resources. These will be // owned by the FileChooser object until they're passed to the plugin. DCHECK(file_queue_.empty()); for (size_t i = 0; i < chosen_files.size(); i++) { - file_queue_.push(PPB_FileRef_Proxy::DeserializeFileRef( + file_queue_.push(FileRefResource::CreateFileRef( + connection(), + pp_instance(), chosen_files[i])); } } diff --git a/chromium/ppapi/proxy/file_chooser_resource.h b/chromium/ppapi/proxy/file_chooser_resource.h index 58331db7f4f..b744e917fce 100644 --- a/chromium/ppapi/proxy/file_chooser_resource.h +++ b/chromium/ppapi/proxy/file_chooser_resource.h @@ -17,7 +17,7 @@ namespace ppapi { -struct PPB_FileRef_CreateInfo; +struct FileRefCreateInfo; namespace proxy { @@ -56,7 +56,7 @@ class PPAPI_PROXY_EXPORT FileChooserResource private: void OnPluginMsgShowReply( const ResourceMessageReplyParams& params, - const std::vector<PPB_FileRef_CreateInfo>& chosen_files); + const std::vector<FileRefCreateInfo>& chosen_files); int32_t ShowInternal(PP_Bool save_as, const PP_Var& suggested_file_name, diff --git a/chromium/ppapi/proxy/file_chooser_resource_unittest.cc b/chromium/ppapi/proxy/file_chooser_resource_unittest.cc index a5801eed161..4ba5bd9da88 100644 --- a/chromium/ppapi/proxy/file_chooser_resource_unittest.cc +++ b/chromium/ppapi/proxy/file_chooser_resource_unittest.cc @@ -5,6 +5,7 @@ #include "base/message_loop/message_loop.h" #include "ppapi/c/dev/ppb_file_chooser_dev.h" #include "ppapi/c/pp_errors.h" +#include "ppapi/c/ppb_file_ref.h" #include "ppapi/proxy/file_chooser_resource.h" #include "ppapi/proxy/locking_resource_releaser.h" #include "ppapi/proxy/ppapi_messages.h" @@ -91,13 +92,14 @@ TEST_F(FileChooserResourceTest, Show) { reply_params.set_result(PP_OK); // Synthesize a response with one file ref in it. Note that it must have a - // host resource value set or deserialization will fail. Since there isn't - // actually a host, this can be whatever we want. - std::vector<PPB_FileRef_CreateInfo> create_info_array; - PPB_FileRef_CreateInfo create_info; - create_info.resource.SetHostResource(pp_instance(), 123); - create_info.path = "foo/bar"; - create_info.name = "baz"; + // pending_host_resource_id set. Since there isn't actually a host, this can + // be whatever we want. + std::vector<FileRefCreateInfo> create_info_array; + FileRefCreateInfo create_info; + create_info.file_system_type = PP_FILESYSTEMTYPE_EXTERNAL; + create_info.display_name = "bar"; + create_info.browser_pending_host_resource_id = 12; + create_info.renderer_pending_host_resource_id = 15; create_info_array.push_back(create_info); ASSERT_TRUE(plugin_dispatcher()->OnMessageReceived( PpapiPluginMsg_ResourceReply(reply_params, @@ -115,9 +117,8 @@ TEST_F(FileChooserResourceTest, Show) { { ProxyAutoLock lock; ScopedPPVar release_name_var(ScopedPPVar::PassRef(), name_var); - EXPECT_VAR_IS_STRING(create_info.name, name_var); + EXPECT_VAR_IS_STRING("bar", name_var); } - // Path should be undefined since it's external filesystem. PP_Var path_var(file_ref_iface->GetPath(dest[0])); { ProxyAutoLock lock; diff --git a/chromium/ppapi/proxy/file_io_resource.cc b/chromium/ppapi/proxy/file_io_resource.cc index 76ee51c4e9c..fc53fb05243 100644 --- a/chromium/ppapi/proxy/file_io_resource.cc +++ b/chromium/ppapi/proxy/file_io_resource.cc @@ -111,9 +111,13 @@ int32_t FileIOResource::Open(PP_Resource file_ref, if (rv != PP_OK) return rv; + // Take a reference on the FileRef resource while we're opening the file; we + // don't want the plugin destroying it during the Open operation. + file_ref_ = enter.resource(); + Call<PpapiPluginMsg_FileIO_OpenReply>(RENDERER, PpapiHostMsg_FileIO_Open( - enter.resource()->host_resource().host_resource(), + file_ref, open_flags), base::Bind(&FileIOResource::OnPluginMsgOpenFileComplete, this, callback)); @@ -410,6 +414,9 @@ void FileIOResource::OnPluginMsgOpenFileComplete( const ResourceMessageReplyParams& params) { DCHECK(state_manager_.get_pending_operation() == FileIOStateManager::OPERATION_EXCLUSIVE); + + // Release the FileRef resource. + file_ref_ = NULL; if (params.result() == PP_OK) state_manager_.SetOpenSucceed(); diff --git a/chromium/ppapi/proxy/file_io_resource.h b/chromium/ppapi/proxy/file_io_resource.h index 1a888d199d6..26c4abb9488 100644 --- a/chromium/ppapi/proxy/file_io_resource.h +++ b/chromium/ppapi/proxy/file_io_resource.h @@ -7,11 +7,13 @@ #include <string> +#include "base/memory/scoped_ptr.h" #include "ppapi/c/private/pp_file_handle.h" #include "ppapi/proxy/connection.h" #include "ppapi/proxy/plugin_resource.h" #include "ppapi/proxy/ppapi_proxy_export.h" #include "ppapi/shared_impl/file_io_state_manager.h" +#include "ppapi/shared_impl/resource.h" #include "ppapi/thunk/ppb_file_io_api.h" namespace ppapi { @@ -137,6 +139,8 @@ class PPAPI_PROXY_EXPORT FileIOResource PP_FileSystemType file_system_type_; FileIOStateManager state_manager_; + scoped_refptr<Resource> file_ref_; + DISALLOW_COPY_AND_ASSIGN(FileIOResource); }; diff --git a/chromium/ppapi/proxy/file_ref_resource.cc b/chromium/ppapi/proxy/file_ref_resource.cc index 4c098a567a9..7cd96bc60a0 100644 --- a/chromium/ppapi/proxy/file_ref_resource.cc +++ b/chromium/ppapi/proxy/file_ref_resource.cc @@ -22,7 +22,7 @@ namespace proxy { FileRefResource::FileRefResource( Connection connection, PP_Instance instance, - const FileRef_CreateInfo& create_info) + const FileRefCreateInfo& create_info) : PluginResource(connection, instance), create_info_(create_info), file_system_resource_(create_info.file_system_plugin_resource) { @@ -34,19 +34,26 @@ FileRefResource::FileRefResource( create_info_.internal_path.erase(path_size - 1, 1); path_var_ = new StringVar(create_info_.internal_path); - create_info_.display_name = GetNameForInternalFilePath( create_info_.internal_path); } name_var_ = new StringVar(create_info_.display_name); - if (create_info_.pending_host_resource_id != 0) { - AttachToPendingHost(BROWSER, create_info_.pending_host_resource_id); + if (create_info_.browser_pending_host_resource_id != 0 && + create_info_.renderer_pending_host_resource_id != 0) { + AttachToPendingHost(BROWSER, create_info_.browser_pending_host_resource_id); + AttachToPendingHost(RENDERER, + create_info_.renderer_pending_host_resource_id); } else { + CHECK(create_info_.browser_pending_host_resource_id == 0); + CHECK(create_info_.renderer_pending_host_resource_id == 0); CHECK(create_info_.file_system_type != PP_FILESYSTEMTYPE_EXTERNAL); SendCreate(BROWSER, PpapiHostMsg_FileRef_CreateInternal( create_info.file_system_plugin_resource, create_info.internal_path)); + SendCreate(RENDERER, PpapiHostMsg_FileRef_CreateInternal( + create_info.file_system_plugin_resource, + create_info.internal_path)); } } @@ -57,7 +64,7 @@ FileRefResource::~FileRefResource() { PP_Resource FileRefResource::CreateFileRef( Connection connection, PP_Instance instance, - const FileRef_CreateInfo& create_info) { + const FileRefCreateInfo& create_info) { // If we have a valid file_system resource, ensure that its type matches that // of the fs_type parameter. if (create_info.file_system_plugin_resource != 0) { @@ -82,9 +89,7 @@ PP_Resource FileRefResource::CreateFileRef( } thunk::PPB_FileRef_API* FileRefResource::AsPPB_FileRef_API() { - // TODO: return "this" once we update PPB_FileRef_API. - NOTREACHED(); - return NULL; + return this; } PP_FileSystemType FileRefResource::GetFileSystemType() const { @@ -111,7 +116,7 @@ PP_Resource FileRefResource::GetParent() { pos++; std::string parent_path = create_info_.internal_path.substr(0, pos); - ppapi::FileRef_CreateInfo parent_info; + ppapi::FileRefCreateInfo parent_info; parent_info.file_system_type = create_info_.file_system_type; parent_info.internal_path = parent_path; parent_info.display_name = GetNameForInternalFilePath(parent_path); @@ -184,33 +189,9 @@ int32_t FileRefResource::ReadDirectoryEntries( return PP_OK_COMPLETIONPENDING; } -/* -const FileRef_CreateInfo& FileRefResource::GetCreateInfo() const { +const FileRefCreateInfo& FileRefResource::GetCreateInfo() const { return create_info_; } -*/ -const PPB_FileRef_CreateInfo& FileRefResource::GetCreateInfo() const { - // FIXME - NOTREACHED(); - PPB_FileRef_CreateInfo *info = new PPB_FileRef_CreateInfo(); - return *info; -} - -// TODO(teravest): Remove this when we are finished moving to the new proxy. -int32_t FileRefResource::QueryInHost(linked_ptr<PP_FileInfo> info, - scoped_refptr<TrackedCallback> callback) { - NOTREACHED(); - return PP_ERROR_FAILED; -} - -// TODO(teravest): Remove this when we are finished moving to the new proxy. -int32_t FileRefResource::ReadDirectoryEntriesInHost( - linked_ptr<std::vector<ppapi::PPB_FileRef_CreateInfo> > files, - linked_ptr<std::vector<PP_FileType> > file_types, - scoped_refptr<TrackedCallback> callback) { - NOTREACHED(); - return PP_ERROR_FAILED; -} PP_Var FileRefResource::GetAbsolutePath() { if (!absolute_path_var_.get()) { @@ -248,7 +229,7 @@ void FileRefResource::OnDirectoryEntriesReply( const PP_ArrayOutput& output, scoped_refptr<TrackedCallback> callback, const ResourceMessageReplyParams& params, - const std::vector<ppapi::FileRef_CreateInfo>& infos, + const std::vector<ppapi::FileRefCreateInfo>& infos, const std::vector<PP_FileType>& file_types) { if (!TrackedCallback::IsPending(callback)) return; diff --git a/chromium/ppapi/proxy/file_ref_resource.h b/chromium/ppapi/proxy/file_ref_resource.h index 82570fbc09c..f982438fb0d 100644 --- a/chromium/ppapi/proxy/file_ref_resource.h +++ b/chromium/ppapi/proxy/file_ref_resource.h @@ -29,7 +29,7 @@ class PPAPI_PROXY_EXPORT FileRefResource public: static PP_Resource CreateFileRef(Connection connection, PP_Instance instance, - const FileRef_CreateInfo& info); + const FileRefCreateInfo& info); virtual ~FileRefResource(); @@ -55,13 +55,7 @@ class PPAPI_PROXY_EXPORT FileRefResource virtual int32_t ReadDirectoryEntries( const PP_ArrayOutput& output, scoped_refptr<TrackedCallback> callback) OVERRIDE; - virtual const PPB_FileRef_CreateInfo& GetCreateInfo() const OVERRIDE; - virtual int32_t QueryInHost(linked_ptr<PP_FileInfo> info, - scoped_refptr<TrackedCallback> callback) OVERRIDE; - virtual int32_t ReadDirectoryEntriesInHost( - linked_ptr<std::vector<ppapi::PPB_FileRef_CreateInfo> > files, - linked_ptr<std::vector<PP_FileType> > file_types, - scoped_refptr<TrackedCallback> callback) OVERRIDE; + virtual const FileRefCreateInfo& GetCreateInfo() const OVERRIDE; // Private API virtual PP_Var GetAbsolutePath() OVERRIDE; @@ -69,7 +63,7 @@ class PPAPI_PROXY_EXPORT FileRefResource private: FileRefResource(Connection connection, PP_Instance instance, - const FileRef_CreateInfo& info); + const FileRefCreateInfo& info); void RunTrackedCallback(scoped_refptr<TrackedCallback> callback, const ResourceMessageReplyParams& params); @@ -83,11 +77,11 @@ class PPAPI_PROXY_EXPORT FileRefResource const PP_ArrayOutput& output, scoped_refptr<TrackedCallback> callback, const ResourceMessageReplyParams& params, - const std::vector<ppapi::FileRef_CreateInfo>& infos, + const std::vector<ppapi::FileRefCreateInfo>& infos, const std::vector<PP_FileType>& file_types); // Populated after creation. - FileRef_CreateInfo create_info_; + FileRefCreateInfo create_info_; // Some file ref operations may fail if the the file system resource inside // create_info_ is destroyed. Therefore, we explicitly hold a reference to diff --git a/chromium/ppapi/proxy/file_system_resource.cc b/chromium/ppapi/proxy/file_system_resource.cc index 5acac00964b..bab771929ac 100644 --- a/chromium/ppapi/proxy/file_system_resource.cc +++ b/chromium/ppapi/proxy/file_system_resource.cc @@ -38,6 +38,7 @@ PPB_FileSystem_API* FileSystemResource::AsPPB_FileSystem_API() { int32_t FileSystemResource::Open(int64_t expected_size, scoped_refptr<TrackedCallback> callback) { + DCHECK(type_ != PP_FILESYSTEMTYPE_ISOLATED); if (called_open_) return PP_ERROR_FAILED; called_open_ = true; @@ -59,11 +60,27 @@ PP_FileSystemType FileSystemResource::GetType() { return type_; } -void FileSystemResource::InitIsolatedFileSystem(const char* fsid) { - Post(RENDERER, - PpapiHostMsg_FileSystem_InitIsolatedFileSystem(std::string(fsid))); - Post(BROWSER, - PpapiHostMsg_FileSystem_InitIsolatedFileSystem(std::string(fsid))); +int32_t FileSystemResource::InitIsolatedFileSystem( + const std::string& fsid, + const base::Callback<void(int32_t)>& callback) { + // This call is mutually exclusive with Open() above, so we can reuse the + // called_open state. + DCHECK(type_ == PP_FILESYSTEMTYPE_ISOLATED); + if (called_open_) + return PP_ERROR_FAILED; + called_open_ = true; + + Call<PpapiPluginMsg_FileSystem_InitIsolatedFileSystemReply>(RENDERER, + PpapiHostMsg_FileSystem_InitIsolatedFileSystem(fsid), + base::Bind(&FileSystemResource::InitIsolatedFileSystemComplete, + this, + callback)); + Call<PpapiPluginMsg_FileSystem_InitIsolatedFileSystemReply>(BROWSER, + PpapiHostMsg_FileSystem_InitIsolatedFileSystem(fsid), + base::Bind(&FileSystemResource::InitIsolatedFileSystemComplete, + this, + callback)); + return PP_OK_COMPLETIONPENDING; } void FileSystemResource::OpenComplete( @@ -75,5 +92,14 @@ void FileSystemResource::OpenComplete( callback->Run(params.result()); } +void FileSystemResource::InitIsolatedFileSystemComplete( + const base::Callback<void(int32_t)>& callback, + const ResourceMessageReplyParams& params) { + ++callback_count_; + // Received callback from browser and renderer. + if (callback_count_ == 2) + callback.Run(params.result()); +} + } // namespace proxy } // namespace ppapi diff --git a/chromium/ppapi/proxy/file_system_resource.h b/chromium/ppapi/proxy/file_system_resource.h index b104db32420..74677f724ed 100644 --- a/chromium/ppapi/proxy/file_system_resource.h +++ b/chromium/ppapi/proxy/file_system_resource.h @@ -38,13 +38,18 @@ class PPAPI_PROXY_EXPORT FileSystemResource scoped_refptr<TrackedCallback> callback) OVERRIDE; virtual PP_FileSystemType GetType() OVERRIDE; - void InitIsolatedFileSystem(const char* fsid); + int32_t InitIsolatedFileSystem(const std::string& fsid, + const base::Callback<void(int32_t)>& callback); private: - // Called when the host has responded to our open request. void OpenComplete(scoped_refptr<TrackedCallback> callback, const ResourceMessageReplyParams& params); + // Called when the host has responded to our InitIsolatedFileSystem request. + void InitIsolatedFileSystemComplete( + const base::Callback<void(int32_t)>& callback, + const ResourceMessageReplyParams& params); + PP_FileSystemType type_; bool called_open_; uint32_t callback_count_; diff --git a/chromium/ppapi/proxy/flash_drm_resource.cc b/chromium/ppapi/proxy/flash_drm_resource.cc index a4be23beb8a..889aa72b457 100644 --- a/chromium/ppapi/proxy/flash_drm_resource.cc +++ b/chromium/ppapi/proxy/flash_drm_resource.cc @@ -7,9 +7,8 @@ #include "base/bind.h" #include "ppapi/c/pp_errors.h" #include "ppapi/proxy/dispatch_reply_message.h" +#include "ppapi/proxy/file_ref_resource.h" #include "ppapi/proxy/ppapi_messages.h" -#include "ppapi/proxy/ppb_file_ref_proxy.h" -#include "ppapi/shared_impl/ppb_file_ref_shared.h" #include "ppapi/shared_impl/var.h" namespace ppapi { @@ -88,10 +87,14 @@ void FlashDRMResource::OnPluginMsgGetVoucherFileReply( PP_Resource* dest, scoped_refptr<TrackedCallback> callback, const ResourceMessageReplyParams& params, - const PPB_FileRef_CreateInfo& file_info) { + const FileRefCreateInfo& file_info) { if (TrackedCallback::IsPending(callback)) { - if (params.result() == PP_OK) - *dest = PPB_FileRef_Proxy::DeserializeFileRef(file_info); + if (params.result() == PP_OK) { + *dest = FileRefResource::CreateFileRef( + connection(), + pp_instance(), + file_info); + } callback->Run(params.result()); } } diff --git a/chromium/ppapi/proxy/flash_drm_resource.h b/chromium/ppapi/proxy/flash_drm_resource.h index 12c71e82817..9a4b31c941d 100644 --- a/chromium/ppapi/proxy/flash_drm_resource.h +++ b/chromium/ppapi/proxy/flash_drm_resource.h @@ -11,7 +11,7 @@ #include "ppapi/thunk/ppb_flash_drm_api.h" namespace ppapi { -struct PPB_FileRef_CreateInfo; +struct FileRefCreateInfo; } namespace ppapi { @@ -44,7 +44,7 @@ class FlashDRMResource void OnPluginMsgGetVoucherFileReply(PP_Resource* dest, scoped_refptr<TrackedCallback> callback, const ResourceMessageReplyParams& params, - const PPB_FileRef_CreateInfo& file_info); + const FileRefCreateInfo& file_info); DISALLOW_COPY_AND_ASSIGN(FlashDRMResource); }; diff --git a/chromium/ppapi/proxy/flash_file_resource.cc b/chromium/ppapi/proxy/flash_file_resource.cc index 1387eb7c58b..ce7a2cee110 100644 --- a/chromium/ppapi/proxy/flash_file_resource.cc +++ b/chromium/ppapi/proxy/flash_file_resource.cc @@ -13,6 +13,7 @@ #include "ppapi/shared_impl/time_conversion.h" #include "ppapi/shared_impl/var.h" #include "ppapi/thunk/enter.h" +#include "ppapi/thunk/ppb_file_ref_api.h" namespace ppapi { namespace proxy { diff --git a/chromium/ppapi/proxy/host_resolver_resource_base.cc b/chromium/ppapi/proxy/host_resolver_resource_base.cc index 5cbbbb2aa9a..d552b76a578 100644 --- a/chromium/ppapi/proxy/host_resolver_resource_base.cc +++ b/chromium/ppapi/proxy/host_resolver_resource_base.cc @@ -6,6 +6,7 @@ #include "base/bind.h" #include "ppapi/c/pp_errors.h" +#include "ppapi/proxy/error_conversion.h" #include "ppapi/proxy/net_address_resource.h" #include "ppapi/proxy/ppapi_messages.h" #include "ppapi/shared_impl/tracked_callback.h" @@ -14,25 +15,6 @@ namespace ppapi { namespace proxy { -namespace { - -int32_t ConvertPPError(int32_t pp_error, bool private_api) { - // The private API doesn't return network-specific error codes or - // PP_ERROR_NOACCESS. In order to preserve the behavior, we convert those to - // PP_ERROR_FAILED. - // TODO(yzshen): Consider defining ranges for different kinds of PP_Error - // codes, so that we can detect network-specific error codes in a better way. - if (private_api && - (pp_error <= PP_ERROR_CONNECTION_CLOSED || - pp_error == PP_ERROR_NOACCESS)) { - return PP_ERROR_FAILED; - } - - return pp_error; -} - -} // namespace - HostResolverResourceBase::HostResolverResourceBase(Connection connection, PP_Instance instance, bool private_api) @@ -110,7 +92,8 @@ void HostResolverResourceBase::OnPluginMsgResolveReply( canonical_name_.clear(); net_address_list_.clear(); } - resolve_callback_->Run(ConvertPPError(params.result(), private_api_)); + resolve_callback_->Run(ConvertNetworkAPIErrorForCompatibility(params.result(), + private_api_)); } void HostResolverResourceBase::SendResolve( diff --git a/chromium/ppapi/proxy/interface_list.cc b/chromium/ppapi/proxy/interface_list.cc index d9feb89d08c..9c810a350ce 100644 --- a/chromium/ppapi/proxy/interface_list.cc +++ b/chromium/ppapi/proxy/interface_list.cc @@ -48,6 +48,8 @@ #include "ppapi/c/ppb_messaging.h" #include "ppapi/c/ppb_mouse_lock.h" #include "ppapi/c/ppb_net_address.h" +#include "ppapi/c/ppb_network_list.h" +#include "ppapi/c/ppb_network_monitor.h" #include "ppapi/c/ppb_network_proxy.h" #include "ppapi/c/ppb_opengles2.h" #include "ppapi/c/ppb_tcp_socket.h" @@ -79,9 +81,8 @@ #include "ppapi/c/private/ppb_flash_print.h" #include "ppapi/c/private/ppb_host_resolver_private.h" #include "ppapi/c/private/ppb_net_address_private.h" -#include "ppapi/c/private/ppb_network_list_private.h" -#include "ppapi/c/private/ppb_network_monitor_private.h" #include "ppapi/c/private/ppb_pdf.h" +#include "ppapi/c/private/ppb_platform_verification_private.h" #include "ppapi/c/private/ppb_talk_private.h" #include "ppapi/c/private/ppb_tcp_server_socket_private.h" #include "ppapi/c/private/ppb_tcp_socket_private.h" @@ -101,15 +102,11 @@ #include "ppapi/proxy/ppb_broker_proxy.h" #include "ppapi/proxy/ppb_buffer_proxy.h" #include "ppapi/proxy/ppb_core_proxy.h" -#include "ppapi/proxy/ppb_file_ref_proxy.h" #include "ppapi/proxy/ppb_flash_message_loop_proxy.h" #include "ppapi/proxy/ppb_graphics_3d_proxy.h" #include "ppapi/proxy/ppb_image_data_proxy.h" #include "ppapi/proxy/ppb_instance_proxy.h" #include "ppapi/proxy/ppb_message_loop_proxy.h" -#include "ppapi/proxy/ppb_network_monitor_private_proxy.h" -#include "ppapi/proxy/ppb_tcp_socket_private_proxy.h" -#include "ppapi/proxy/ppb_tcp_socket_proxy.h" #include "ppapi/proxy/ppb_testing_proxy.h" #include "ppapi/proxy/ppb_var_deprecated_proxy.h" #include "ppapi/proxy/ppb_video_decoder_proxy.h" diff --git a/chromium/ppapi/proxy/network_list_resource.cc b/chromium/ppapi/proxy/network_list_resource.cc new file mode 100644 index 00000000000..466e533daf7 --- /dev/null +++ b/chromium/ppapi/proxy/network_list_resource.cc @@ -0,0 +1,89 @@ +// Copyright (c) 2012 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "ppapi/proxy/network_list_resource.h" + +#include <algorithm> + +#include "base/logging.h" +#include "ppapi/c/pp_errors.h" +#include "ppapi/shared_impl/array_writer.h" +#include "ppapi/shared_impl/var.h" +#include "ppapi/thunk/enter.h" + +namespace ppapi { +namespace proxy { + +NetworkListResource::NetworkListResource(PP_Instance instance, + const SerializedNetworkList& list) + : Resource(OBJECT_IS_PROXY, instance), + list_(list) { +} + +NetworkListResource::~NetworkListResource() {} + +thunk::PPB_NetworkList_API* NetworkListResource::AsPPB_NetworkList_API() { + return this; +} + +uint32_t NetworkListResource::GetCount() { + return static_cast<uint32_t>(list_.size()); +} + +PP_Var NetworkListResource::GetName(uint32_t index) { + if (index >= list_.size()) + return PP_MakeUndefined(); + return StringVar::StringToPPVar(list_.at(index).name); +} + +PP_NetworkList_Type NetworkListResource::GetType(uint32_t index) { + if (index >= list_.size()) + return PP_NETWORKLIST_TYPE_UNKNOWN; + return list_.at(index).type; +} + +PP_NetworkList_State NetworkListResource::GetState(uint32_t index) { + if (index >= list_.size()) + return PP_NETWORKLIST_STATE_DOWN; + return list_.at(index).state; +} + +int32_t NetworkListResource::GetIpAddresses(uint32_t index, + const PP_ArrayOutput& output) { + ArrayWriter writer(output); + if (index >= list_.size() || !writer.is_valid()) + return PP_ERROR_BADARGUMENT; + + thunk::EnterResourceCreationNoLock enter(pp_instance()); + if (enter.failed()) + return PP_ERROR_FAILED; + + const std::vector<PP_NetAddress_Private>& addresses = + list_.at(index).addresses; + std::vector<PP_Resource> addr_resources; + for (size_t i = 0; i < addresses.size(); ++i) { + addr_resources.push_back( + enter.functions()->CreateNetAddressFromNetAddressPrivate( + pp_instance(), addresses[i])); + } + if (!writer.StoreResourceVector(addr_resources)) + return PP_ERROR_FAILED; + + return PP_OK; +} + +PP_Var NetworkListResource::GetDisplayName(uint32_t index) { + if (index >= list_.size()) + return PP_MakeUndefined(); + return StringVar::StringToPPVar(list_.at(index).display_name); +} + +uint32_t NetworkListResource::GetMTU(uint32_t index) { + if (index >= list_.size()) + return 0; + return list_.at(index).mtu; +} + +} // namespace proxy +} // namespace thunk diff --git a/chromium/ppapi/proxy/network_list_resource.h b/chromium/ppapi/proxy/network_list_resource.h new file mode 100644 index 00000000000..36c98774ef7 --- /dev/null +++ b/chromium/ppapi/proxy/network_list_resource.h @@ -0,0 +1,52 @@ +// Copyright (c) 2012 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef PPAPI_PROXY_NETWORK_LIST_RESOURCE_H_ +#define PPAPI_PROXY_NETWORK_LIST_RESOURCE_H_ + +#include <string> +#include <vector> + +#include "base/basictypes.h" +#include "base/memory/ref_counted.h" +#include "ppapi/c/private/ppb_net_address_private.h" +#include "ppapi/proxy/ppapi_proxy_export.h" +#include "ppapi/proxy/serialized_structs.h" +#include "ppapi/shared_impl/resource.h" +#include "ppapi/thunk/ppb_network_list_api.h" + +namespace ppapi { +namespace proxy { + +class NetworkListResource + : public Resource, + public thunk::PPB_NetworkList_API { + public: + NetworkListResource(PP_Instance instance, + const SerializedNetworkList& list); + virtual ~NetworkListResource(); + + // Resource override. + virtual thunk::PPB_NetworkList_API* AsPPB_NetworkList_API() OVERRIDE; + + // PPB_NetworkList_API implementation. + virtual uint32_t GetCount() OVERRIDE; + virtual PP_Var GetName(uint32_t index) OVERRIDE; + virtual PP_NetworkList_Type GetType(uint32_t index) OVERRIDE; + virtual PP_NetworkList_State GetState(uint32_t index) OVERRIDE; + virtual int32_t GetIpAddresses(uint32_t index, + const PP_ArrayOutput& output) OVERRIDE; + virtual PP_Var GetDisplayName(uint32_t index) OVERRIDE; + virtual uint32_t GetMTU(uint32_t index) OVERRIDE; + + private: + SerializedNetworkList list_; + + DISALLOW_COPY_AND_ASSIGN(NetworkListResource); +}; + +} // namespace proxy +} // namespace ppapi + +#endif // PPAPI_PROXY_NETWORK_LIST_RESOURCE_H_ diff --git a/chromium/ppapi/proxy/network_monitor_resource.cc b/chromium/ppapi/proxy/network_monitor_resource.cc new file mode 100644 index 00000000000..0dfb0b4b3eb --- /dev/null +++ b/chromium/ppapi/proxy/network_monitor_resource.cc @@ -0,0 +1,85 @@ +// Copyright 2013 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/proxy/network_monitor_resource.h" + +#include "ppapi/proxy/dispatch_reply_message.h" +#include "ppapi/proxy/ppapi_messages.h" +#include "ppapi/thunk/enter.h" +#include "ppapi/thunk/ppb_network_monitor_api.h" + +namespace ppapi { +namespace proxy { + +NetworkMonitorResource::NetworkMonitorResource(Connection connection, + PP_Instance instance) + : PluginResource(connection, instance), + current_list_(0), + forbidden_(false), + network_list_(NULL) { + SendCreate(BROWSER, PpapiHostMsg_NetworkMonitor_Create()); +} + +NetworkMonitorResource::~NetworkMonitorResource() {} + +ppapi::thunk::PPB_NetworkMonitor_API* +NetworkMonitorResource::AsPPB_NetworkMonitor_API() { + return this; +} + +void NetworkMonitorResource::OnReplyReceived( + const ResourceMessageReplyParams& params, + const IPC::Message& msg) { + IPC_BEGIN_MESSAGE_MAP(NetworkMonitorResource, msg) + PPAPI_DISPATCH_PLUGIN_RESOURCE_CALL( + PpapiPluginMsg_NetworkMonitor_NetworkList, OnPluginMsgNetworkList) + PPAPI_DISPATCH_PLUGIN_RESOURCE_CALL_0( + PpapiPluginMsg_NetworkMonitor_Forbidden, OnPluginMsgForbidden) + PPAPI_DISPATCH_PLUGIN_RESOURCE_CALL_UNHANDLED( + PluginResource::OnReplyReceived(params, msg)) + IPC_END_MESSAGE_MAP() +} + +int32_t NetworkMonitorResource::UpdateNetworkList( + PP_Resource* network_list, + scoped_refptr<TrackedCallback> callback) { + if (!network_list) + return PP_ERROR_BADARGUMENT; + if (TrackedCallback::IsPending(update_callback_)) + return PP_ERROR_INPROGRESS; + if (forbidden_) + return PP_ERROR_NOACCESS; + + if (current_list_.get()) { + *network_list = current_list_.Release(); + return PP_OK; + } + + network_list_ = network_list; + update_callback_ = callback; + return PP_OK_COMPLETIONPENDING; +} + +void NetworkMonitorResource::OnPluginMsgNetworkList( + const ResourceMessageReplyParams& params, + const SerializedNetworkList& list) { + current_list_ = ScopedPPResource( + new NetworkListResource(pp_instance(), list)); + + if (TrackedCallback::IsPending(update_callback_)) { + *network_list_ = current_list_.Release(); + update_callback_->Run(PP_OK); + } +} + +void NetworkMonitorResource::OnPluginMsgForbidden( + const ResourceMessageReplyParams& params) { + forbidden_ = true; + + if (TrackedCallback::IsPending(update_callback_)) + update_callback_->Run(PP_ERROR_NOACCESS); +} + +} // namespace proxy +} // namespace ppapi diff --git a/chromium/ppapi/proxy/network_monitor_resource.h b/chromium/ppapi/proxy/network_monitor_resource.h new file mode 100644 index 00000000000..d227934aab0 --- /dev/null +++ b/chromium/ppapi/proxy/network_monitor_resource.h @@ -0,0 +1,58 @@ +// Copyright 2013 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_PROXY_NETWORK_MONITOR_RESOURCE_H_ +#define PPAPI_PROXY_NETWORK_MONITOR_RESOURCE_H_ + +#include <list> + +#include "ppapi/proxy/network_list_resource.h" +#include "ppapi/proxy/plugin_resource.h" +#include "ppapi/shared_impl/scoped_pp_resource.h" +#include "ppapi/thunk/ppb_network_monitor_api.h" + +namespace base { +class MessageLoopProxy; +} // namespace base + +namespace ppapi { +namespace proxy { + +class NetworkMonitorResource : public PluginResource, + public thunk::PPB_NetworkMonitor_API { + public: + explicit NetworkMonitorResource(Connection connection, + PP_Instance instance); + virtual ~NetworkMonitorResource(); + + // PluginResource overrides. + ppapi::thunk::PPB_NetworkMonitor_API* AsPPB_NetworkMonitor_API() OVERRIDE; + virtual void OnReplyReceived(const ResourceMessageReplyParams& params, + const IPC::Message& msg) OVERRIDE; + + // thunk::PPB_NetworkMonitor_API interface + virtual int32_t UpdateNetworkList( + PP_Resource* network_list, + scoped_refptr<TrackedCallback> callback) OVERRIDE; + + private: + // IPC message handlers for the messages received from the browser. + void OnPluginMsgNetworkList(const ResourceMessageReplyParams& params, + const SerializedNetworkList& list); + void OnPluginMsgForbidden(const ResourceMessageReplyParams& params); + + ScopedPPResource current_list_; + bool forbidden_; + + // Parameters passed to UpdateNetworkList(). + PP_Resource* network_list_; + scoped_refptr<TrackedCallback> update_callback_; + + DISALLOW_COPY_AND_ASSIGN(NetworkMonitorResource); +}; + +} // namespace proxy +} // namespace ppapi + +#endif // PPAPI_PROXY_NETWORK_MONITOR_RESOURCE_H_ diff --git a/chromium/ppapi/proxy/platform_verification_private_resource.cc b/chromium/ppapi/proxy/platform_verification_private_resource.cc new file mode 100644 index 00000000000..4da3ca0f34e --- /dev/null +++ b/chromium/ppapi/proxy/platform_verification_private_resource.cc @@ -0,0 +1,132 @@ +// Copyright 2013 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/proxy/platform_verification_private_resource.h" + +#include "base/bind.h" +#include "ppapi/c/pp_errors.h" +#include "ppapi/proxy/dispatch_reply_message.h" +#include "ppapi/proxy/ppapi_messages.h" +#include "ppapi/shared_impl/ppapi_globals.h" +#include "ppapi/shared_impl/tracked_callback.h" +#include "ppapi/shared_impl/var.h" +#include "ppapi/shared_impl/var_tracker.h" + +namespace ppapi { +namespace proxy { + +PlatformVerificationPrivateResource::PlatformVerificationPrivateResource( + Connection connection, + PP_Instance instance) + : PluginResource(connection, instance) { + SendCreate(BROWSER, PpapiHostMsg_PlatformVerification_Create()); +} + +PlatformVerificationPrivateResource::~PlatformVerificationPrivateResource() {} + +thunk::PPB_PlatformVerification_API* +PlatformVerificationPrivateResource::AsPPB_PlatformVerification_API() { + return this; +} + +int32_t PlatformVerificationPrivateResource::CanChallengePlatform( + PP_Bool* can_challenge_platform, + const scoped_refptr<TrackedCallback>& callback) { + if (!can_challenge_platform) + return PP_ERROR_BADARGUMENT; + + Call<PpapiHostMsg_PlatformVerification_CanChallengePlatformReply>( + BROWSER, PpapiHostMsg_PlatformVerification_CanChallengePlatform(), + base::Bind( + &PlatformVerificationPrivateResource::OnCanChallengePlatformReply, + base::Unretained(this), can_challenge_platform, callback)); + + return PP_OK_COMPLETIONPENDING; +} + +void PlatformVerificationPrivateResource::OnCanChallengePlatformReply( + PP_Bool* can_challenge_platform, + const scoped_refptr<TrackedCallback>& callback, + const ResourceMessageReplyParams& params, + bool can_challenge_platform_response) { + if (!TrackedCallback::IsPending(callback) || + TrackedCallback::IsScheduledToRun(callback)) { + return; + } + + *can_challenge_platform = PP_FromBool(can_challenge_platform_response); + callback->Run(params.result()); +} + +int32_t PlatformVerificationPrivateResource::ChallengePlatform( + const PP_Var& service_id, + const PP_Var& challenge, + PP_Var* signed_data, + PP_Var* signed_data_signature, + PP_Var* platform_key_certificate, + const scoped_refptr<TrackedCallback>& callback) { + // Prevent null types for obvious reasons, but also ref-counted types to avoid + // leaks on challenge failures (since they're only written to on success). + if (!signed_data || !signed_data_signature || !platform_key_certificate || + VarTracker::IsVarTypeRefcounted(signed_data->type) || + VarTracker::IsVarTypeRefcounted(signed_data_signature->type) || + VarTracker::IsVarTypeRefcounted(platform_key_certificate->type)) { + return PP_ERROR_BADARGUMENT; + } + + StringVar* service_id_str = StringVar::FromPPVar(service_id); + if (!service_id_str) + return PP_ERROR_BADARGUMENT; + + scoped_refptr<ArrayBufferVar> challenge_buffer = + ArrayBufferVar::FromPPVar(challenge); + if (!challenge_buffer) + return PP_ERROR_BADARGUMENT; + + uint8_t* challenge_data = static_cast<uint8_t*>(challenge_buffer->Map()); + uint32 challenge_length = challenge_buffer->ByteLength(); + std::vector<uint8_t> challenge_vector(challenge_data, + challenge_data + challenge_length); + challenge_buffer->Unmap(); + + PpapiHostMsg_PlatformVerification_ChallengePlatform challenge_message( + service_id_str->value(), challenge_vector); + + ChallengePlatformParams output_params = { + signed_data, signed_data_signature, platform_key_certificate, callback }; + + Call<PpapiHostMsg_PlatformVerification_ChallengePlatformReply>( + BROWSER, challenge_message, base::Bind( + &PlatformVerificationPrivateResource::OnChallengePlatformReply, + base::Unretained(this), output_params)); + return PP_OK_COMPLETIONPENDING; +} + +void PlatformVerificationPrivateResource::OnChallengePlatformReply( + ChallengePlatformParams output_params, + const ResourceMessageReplyParams& params, + const std::vector<uint8_t>& raw_signed_data, + const std::vector<uint8_t>& raw_signed_data_signature, + const std::string& raw_platform_key_certificate) { + if (!TrackedCallback::IsPending(output_params.callback) || + TrackedCallback::IsScheduledToRun(output_params.callback)) { + return; + } + + if (params.result() == PP_OK) { + *(output_params.signed_data) = + (PpapiGlobals::Get()->GetVarTracker()->MakeArrayBufferVar( + raw_signed_data.size(), &raw_signed_data.front()))->GetPPVar(); + *(output_params.signed_data_signature) = + (PpapiGlobals::Get()->GetVarTracker()->MakeArrayBufferVar( + raw_signed_data_signature.size(), + &raw_signed_data_signature.front()))->GetPPVar(); + *(output_params.platform_key_certificate) = + (new StringVar(raw_platform_key_certificate))->GetPPVar(); + } + output_params.callback->Run(params.result()); +} + +} // namespace proxy +} // namespace ppapi diff --git a/chromium/ppapi/proxy/platform_verification_private_resource.h b/chromium/ppapi/proxy/platform_verification_private_resource.h new file mode 100644 index 00000000000..ba7d3b14014 --- /dev/null +++ b/chromium/ppapi/proxy/platform_verification_private_resource.h @@ -0,0 +1,66 @@ +// Copyright 2013 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_PROXY_PLATFORM_VERIFICATION_PRIVATE_RESOURCE_H_ +#define PPAPI_PROXY_PLATFORM_VERIFICATION_PRIVATE_RESOURCE_H_ + +#include "ppapi/proxy/plugin_resource.h" +#include "ppapi/proxy/ppapi_proxy_export.h" +#include "ppapi/thunk/ppb_platform_verification_api.h" + +namespace ppapi { +namespace proxy { + +class PPAPI_PROXY_EXPORT PlatformVerificationPrivateResource + : public PluginResource, + public thunk::PPB_PlatformVerification_API { + public: + PlatformVerificationPrivateResource(Connection connection, + PP_Instance instance); + + private: + struct ChallengePlatformParams { + PP_Var* signed_data; + PP_Var* signed_data_signature; + PP_Var* platform_key_certificate; + scoped_refptr<TrackedCallback> callback; + }; + + virtual ~PlatformVerificationPrivateResource(); + + // PluginResource overrides. + virtual thunk::PPB_PlatformVerification_API* + AsPPB_PlatformVerification_API() OVERRIDE; + + // PPB_PlatformVerification_API implementation. + virtual int32_t CanChallengePlatform( + PP_Bool* can_challenge_platform, + const scoped_refptr<TrackedCallback>& callback) OVERRIDE; + virtual int32_t ChallengePlatform( + const PP_Var& service_id, + const PP_Var& challenge, + PP_Var* signed_data, + PP_Var* signed_data_signature, + PP_Var* platform_key_certificate, + const scoped_refptr<TrackedCallback>& callback) OVERRIDE; + + void OnCanChallengePlatformReply( + PP_Bool* can_challenge_platform, + const scoped_refptr<TrackedCallback>& callback, + const ResourceMessageReplyParams& params, + bool can_challenge_platform_response); + void OnChallengePlatformReply( + ChallengePlatformParams output_params, + const ResourceMessageReplyParams& params, + const std::vector<uint8_t>& raw_signed_data, + const std::vector<uint8_t>& raw_signed_data_signature, + const std::string& raw_platform_key_certificate); + + DISALLOW_COPY_AND_ASSIGN(PlatformVerificationPrivateResource); +}; + +} // namespace proxy +} // namespace ppapi + +#endif // PPAPI_PROXY_PLATFORM_VERIFICATION_PRIVATE_RESOURCE_H_ diff --git a/chromium/ppapi/proxy/plugin_globals.cc b/chromium/ppapi/proxy/plugin_globals.cc index 07ac6885601..83217f0d96b 100644 --- a/chromium/ppapi/proxy/plugin_globals.cc +++ b/chromium/ppapi/proxy/plugin_globals.cc @@ -128,10 +128,6 @@ void PluginGlobals::PreCacheFontForFlash(const void* logfontw) { plugin_proxy_delegate_->PreCacheFont(logfontw); } -base::Lock* PluginGlobals::GetProxyLock() { - return &proxy_lock_; -} - void PluginGlobals::LogWithSource(PP_Instance instance, PP_LogLevel level, const std::string& source, diff --git a/chromium/ppapi/proxy/plugin_globals.h b/chromium/ppapi/proxy/plugin_globals.h index 044cac7e25c..31adef55841 100644 --- a/chromium/ppapi/proxy/plugin_globals.h +++ b/chromium/ppapi/proxy/plugin_globals.h @@ -9,7 +9,6 @@ #include "base/compiler_specific.h" #include "base/memory/scoped_ptr.h" -#include "base/synchronization/lock.h" #include "base/threading/thread_local_storage.h" #include "ppapi/proxy/connection.h" #include "ppapi/proxy/plugin_resource_tracker.h" @@ -64,7 +63,6 @@ class PPAPI_PROXY_EXPORT PluginGlobals : public PpapiGlobals { virtual PP_Module GetModuleForInstance(PP_Instance instance) OVERRIDE; virtual std::string GetCmdLine() OVERRIDE; virtual void PreCacheFontForFlash(const void* logfontw) OVERRIDE; - virtual base::Lock* GetProxyLock() OVERRIDE; virtual void LogWithSource(PP_Instance instance, PP_LogLevel level, const std::string& source, @@ -143,8 +141,6 @@ class PPAPI_PROXY_EXPORT PluginGlobals : public PpapiGlobals { PluginVarTracker plugin_var_tracker_; scoped_refptr<CallbackTracker> callback_tracker_; - base::Lock proxy_lock_; - scoped_ptr<base::ThreadLocalStorage::Slot> msg_loop_slot_; // Note that loop_for_main_thread's constructor sets msg_loop_slot_, so it // must be initialized after msg_loop_slot_ (hence the order here). diff --git a/chromium/ppapi/proxy/plugin_resource_tracker.cc b/chromium/ppapi/proxy/plugin_resource_tracker.cc index 12e9d3faf6a..86cbf7cee43 100644 --- a/chromium/ppapi/proxy/plugin_resource_tracker.cc +++ b/chromium/ppapi/proxy/plugin_resource_tracker.cc @@ -18,6 +18,7 @@ namespace ppapi { namespace proxy { PluginResourceTracker::PluginResourceTracker() : ResourceTracker(THREAD_SAFE) { + UseOddResourceValueInDebugMode(); } PluginResourceTracker::~PluginResourceTracker() { diff --git a/chromium/ppapi/proxy/plugin_resource_var.cc b/chromium/ppapi/proxy/plugin_resource_var.cc new file mode 100644 index 00000000000..0ccff749e4d --- /dev/null +++ b/chromium/ppapi/proxy/plugin_resource_var.cc @@ -0,0 +1,20 @@ +// Copyright 2013 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/proxy/plugin_resource_var.h" + +PluginResourceVar::PluginResourceVar() {} + +PluginResourceVar::PluginResourceVar(ppapi::Resource* resource) + : resource_(resource) {} + +PP_Resource PluginResourceVar::GetPPResource() const { + return resource_->pp_resource(); +} + +bool PluginResourceVar::IsPending() const { + return false; +} + +PluginResourceVar::~PluginResourceVar() {} diff --git a/chromium/ppapi/proxy/plugin_resource_var.h b/chromium/ppapi/proxy/plugin_resource_var.h new file mode 100644 index 00000000000..b02718b6a9f --- /dev/null +++ b/chromium/ppapi/proxy/plugin_resource_var.h @@ -0,0 +1,39 @@ +// Copyright 2013 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_PROXY_PLUGIN_RESOURCE_VAR_H_ +#define PPAPI_PROXY_PLUGIN_RESOURCE_VAR_H_ + +#include "ppapi/c/pp_resource.h" +#include "ppapi/proxy/ppapi_proxy_export.h" +#include "ppapi/shared_impl/resource.h" +#include "ppapi/shared_impl/resource_var.h" +#include "ppapi/shared_impl/var.h" + +// Represents a resource Var, usable on the plugin side. +class PPAPI_PROXY_EXPORT PluginResourceVar : public ppapi::ResourceVar { + public: + // Makes a null resource var. + PluginResourceVar(); + + // Makes a resource var with an existing resource. + // Takes one reference to the given resource. + explicit PluginResourceVar(ppapi::Resource* resource); + + // ResourceVar override. + virtual PP_Resource GetPPResource() const OVERRIDE; + virtual bool IsPending() const OVERRIDE; + + scoped_refptr<ppapi::Resource> resource() const { return resource_; } + + protected: + virtual ~PluginResourceVar(); + + private: + scoped_refptr<ppapi::Resource> resource_; + + DISALLOW_COPY_AND_ASSIGN(PluginResourceVar); +}; + +#endif diff --git a/chromium/ppapi/proxy/plugin_var_tracker.cc b/chromium/ppapi/proxy/plugin_var_tracker.cc index ee299852514..d2a4d74d0e3 100644 --- a/chromium/ppapi/proxy/plugin_var_tracker.cc +++ b/chromium/ppapi/proxy/plugin_var_tracker.cc @@ -10,10 +10,13 @@ #include "ppapi/c/ppb_var.h" #include "ppapi/proxy/plugin_array_buffer_var.h" #include "ppapi/proxy/plugin_dispatcher.h" +#include "ppapi/proxy/plugin_resource_var.h" #include "ppapi/proxy/ppapi_messages.h" #include "ppapi/proxy/proxy_object_var.h" #include "ppapi/shared_impl/api_id.h" +#include "ppapi/shared_impl/ppapi_globals.h" #include "ppapi/shared_impl/proxy_lock.h" +#include "ppapi/shared_impl/resource_tracker.h" #include "ppapi/shared_impl/var.h" namespace ppapi { @@ -151,6 +154,14 @@ void PluginVarTracker::ReleaseHostObject(PluginDispatcher* dispatcher, ReleaseVar(found->second); } +ResourceVar* PluginVarTracker::MakeResourceVar(PP_Resource pp_resource) { + ResourceTracker* resource_tracker = PpapiGlobals::Get()->GetResourceTracker(); + ppapi::Resource* resource = resource_tracker->GetResource(pp_resource); + if (!resource) + return NULL; + return new PluginResourceVar(resource); +} + void PluginVarTracker::DidDeleteInstance(PP_Instance instance) { // Calling the destructors on plugin objects may in turn release other // objects which will mutate the map out from under us. So do a two-step diff --git a/chromium/ppapi/proxy/plugin_var_tracker.h b/chromium/ppapi/proxy/plugin_var_tracker.h index 670457f9c05..126c8fcac59 100644 --- a/chromium/ppapi/proxy/plugin_var_tracker.h +++ b/chromium/ppapi/proxy/plugin_var_tracker.h @@ -59,6 +59,7 @@ class PPAPI_PROXY_EXPORT PluginVarTracker : public VarTracker { const PP_Var& host_object); // VarTracker public overrides. + virtual ResourceVar* MakeResourceVar(PP_Resource pp_resource) OVERRIDE; virtual void DidDeleteInstance(PP_Instance instance) OVERRIDE; virtual int TrackSharedMemoryHandle(PP_Instance instance, base::SharedMemoryHandle file, diff --git a/chromium/ppapi/proxy/ppapi_messages.h b/chromium/ppapi/proxy/ppapi_messages.h index 3767f8f4c1c..60cc37fafdf 100644 --- a/chromium/ppapi/proxy/ppapi_messages.h +++ b/chromium/ppapi/proxy/ppapi_messages.h @@ -47,6 +47,7 @@ #include "ppapi/c/private/ppb_talk_private.h" #include "ppapi/c/private/ppp_flash_browser_operations.h" #include "ppapi/proxy/host_resolver_private_resource.h" +#include "ppapi/proxy/network_list_resource.h" #include "ppapi/proxy/ppapi_param_traits.h" #include "ppapi/proxy/ppapi_proxy_export.h" #include "ppapi/proxy/resource_message_params.h" @@ -61,7 +62,7 @@ #include "ppapi/shared_impl/ppapi_preferences.h" #include "ppapi/shared_impl/ppb_device_ref_shared.h" #include "ppapi/shared_impl/ppb_input_event_shared.h" -#include "ppapi/shared_impl/ppb_network_list_private_shared.h" +#include "ppapi/shared_impl/ppb_tcp_socket_shared.h" #include "ppapi/shared_impl/ppb_view_shared.h" #include "ppapi/shared_impl/ppp_flash_browser_operations_shared.h" #include "ppapi/shared_impl/private/ppb_x509_certificate_private_shared.h" @@ -74,6 +75,8 @@ #define IPC_MESSAGE_START PpapiMsgStart +IPC_ENUM_TRAITS_MAX_VALUE(ppapi::TCPSocketVersion, + ppapi::TCP_SOCKET_VERSION_1_1_OR_ABOVE) IPC_ENUM_TRAITS(PP_AudioSampleRate) IPC_ENUM_TRAITS(PP_DeviceType_Dev) IPC_ENUM_TRAITS(PP_DecryptorStreamType) @@ -87,8 +90,8 @@ IPC_ENUM_TRAITS(PP_InputEvent_MouseButton) IPC_ENUM_TRAITS(PP_InputEvent_Type) IPC_ENUM_TRAITS_MAX_VALUE(PP_NetAddressFamily_Private, PP_NETADDRESSFAMILY_PRIVATE_IPV6) -IPC_ENUM_TRAITS(PP_NetworkListState_Private) -IPC_ENUM_TRAITS(PP_NetworkListType_Private) +IPC_ENUM_TRAITS_MAX_VALUE(PP_NetworkList_State, PP_NETWORKLIST_STATE_UP) +IPC_ENUM_TRAITS_MAX_VALUE(PP_NetworkList_Type, PP_NETWORKLIST_TYPE_CELLULAR) IPC_ENUM_TRAITS(PP_PrintOrientation_Dev) IPC_ENUM_TRAITS(PP_PrintOutputFormat_Dev) IPC_ENUM_TRAITS(PP_PrintScalingOption_Dev) @@ -202,11 +205,12 @@ IPC_STRUCT_TRAITS_BEGIN(ppapi::DirEntry) IPC_STRUCT_TRAITS_MEMBER(is_dir) IPC_STRUCT_TRAITS_END() -IPC_STRUCT_TRAITS_BEGIN(ppapi::FileRef_CreateInfo) +IPC_STRUCT_TRAITS_BEGIN(ppapi::FileRefCreateInfo) IPC_STRUCT_TRAITS_MEMBER(file_system_type) IPC_STRUCT_TRAITS_MEMBER(internal_path) IPC_STRUCT_TRAITS_MEMBER(display_name) - IPC_STRUCT_TRAITS_MEMBER(pending_host_resource_id) + IPC_STRUCT_TRAITS_MEMBER(browser_pending_host_resource_id) + IPC_STRUCT_TRAITS_MEMBER(renderer_pending_host_resource_id) IPC_STRUCT_TRAITS_MEMBER(file_system_plugin_resource) IPC_STRUCT_TRAITS_END() @@ -259,6 +263,7 @@ IPC_STRUCT_TRAITS_BEGIN(ppapi::InputEventData) IPC_STRUCT_TRAITS_MEMBER(wheel_scroll_by_page) IPC_STRUCT_TRAITS_MEMBER(key_code) IPC_STRUCT_TRAITS_MEMBER(usb_key_code) + IPC_STRUCT_TRAITS_MEMBER(code) IPC_STRUCT_TRAITS_MEMBER(character_text) IPC_STRUCT_TRAITS_MEMBER(composition_segment_offsets) IPC_STRUCT_TRAITS_MEMBER(composition_target_segment) @@ -298,8 +303,7 @@ IPC_STRUCT_TRAITS_END() IPC_STRUCT_TRAITS_BEGIN(ppapi::URLRequestInfoData::BodyItem) IPC_STRUCT_TRAITS_MEMBER(is_file) IPC_STRUCT_TRAITS_MEMBER(data) - // Note: we don't serialize file_ref. - IPC_STRUCT_TRAITS_MEMBER(file_ref_host_resource) + IPC_STRUCT_TRAITS_MEMBER(file_ref_pp_resource) IPC_STRUCT_TRAITS_MEMBER(start_offset) IPC_STRUCT_TRAITS_MEMBER(number_of_bytes) IPC_STRUCT_TRAITS_MEMBER(expected_last_modified_time) @@ -314,7 +318,7 @@ IPC_STRUCT_TRAITS_BEGIN(ppapi::URLResponseInfoData) IPC_STRUCT_TRAITS_MEMBER(body_as_file_ref) IPC_STRUCT_TRAITS_END() -IPC_STRUCT_TRAITS_BEGIN(ppapi::NetworkInfo) +IPC_STRUCT_TRAITS_BEGIN(ppapi::proxy::SerializedNetworkInfo) IPC_STRUCT_TRAITS_MEMBER(name) IPC_STRUCT_TRAITS_MEMBER(type) IPC_STRUCT_TRAITS_MEMBER(state) @@ -486,30 +490,6 @@ IPC_MESSAGE_ROUTED4(PpapiMsg_PPBAudio_NotifyAudioStreamCreated, ppapi::proxy::SerializedHandle /* socket_handle */, ppapi::proxy::SerializedHandle /* handle */) -// PPB_FileRef. -// TODO(teravest): Remove these messages when we've switched over to the "new" -// proxy. -IPC_MESSAGE_ROUTED3( - PpapiMsg_PPBFileRef_CallbackComplete, - ppapi::HostResource /* resource */, - uint32_t /* callback_id */, - int32_t /* result */) - -IPC_MESSAGE_ROUTED4( - PpapiMsg_PPBFileRef_QueryCallbackComplete, - ppapi::HostResource /* resource */, - PP_FileInfo /* file_info */, - uint32_t /* callback_id */, - int32_t /* result */) - -IPC_MESSAGE_ROUTED5( - PpapiMsg_PPBFileRef_ReadDirectoryEntriesCallbackComplete, - ppapi::HostResource /* resource */, - std::vector<ppapi::PPB_FileRef_CreateInfo> /* files */, - std::vector<PP_FileType> /* file_types */, - uint32_t /* callback_id */, - int32_t /* result */) - // PPB_FileSystem. IPC_MESSAGE_ROUTED2( PpapiMsg_PPBFileSystem_OpenComplete, @@ -624,11 +604,6 @@ IPC_MESSAGE_ROUTED2(PpapiMsg_PPPMessaging_HandleMessage, IPC_MESSAGE_ROUTED1(PpapiMsg_PPPMouseLock_MouseLockLost, PP_Instance /* instance */) -// PPB_NetworkMonitor_Private. -IPC_MESSAGE_ROUTED2(PpapiMsg_PPBNetworkMonitor_NetworkList, - uint32 /* plugin_dispatcher_id */, - ppapi::NetworkList /* network_list */) - // PPP_Printing IPC_SYNC_MESSAGE_ROUTED1_1(PpapiMsg_PPPPrinting_QuerySupportedFormats, PP_Instance /* instance */, @@ -661,9 +636,12 @@ IPC_MESSAGE_ROUTED3( int32_t /* result */) // PPP_ContentDecryptor_Dev -IPC_MESSAGE_ROUTED4(PpapiMsg_PPPContentDecryptor_GenerateKeyRequest, +IPC_MESSAGE_ROUTED3(PpapiMsg_PPPContentDecryptor_Initialize, PP_Instance /* instance */, ppapi::proxy::SerializedVar /* key_system, String */, + bool /* can_challenge_platform */) +IPC_MESSAGE_ROUTED3(PpapiMsg_PPPContentDecryptor_GenerateKeyRequest, + PP_Instance /* instance */, ppapi::proxy::SerializedVar /* type, String */, ppapi::proxy::SerializedVar /* init_data, ArrayBuffer */) IPC_MESSAGE_ROUTED4(PpapiMsg_PPPContentDecryptor_AddKey, @@ -703,32 +681,6 @@ IPC_MESSAGE_ROUTED4(PpapiMsg_PPPContentDecryptor_DecryptAndDecode, std::string /* serialized_block_info */) #endif // !defined(OS_NACL) && !defined(NACL_WIN64) -// PPB_TCPSocket and PPB_TCPSocket_Private. -IPC_MESSAGE_ROUTED5(PpapiMsg_PPBTCPSocket_ConnectACK, - uint32 /* plugin_dispatcher_id */, - uint32 /* socket_id */, - int32_t /* result */, - PP_NetAddress_Private /* local_addr */, - PP_NetAddress_Private /* remote_addr */) -IPC_MESSAGE_ROUTED4(PpapiMsg_PPBTCPSocket_SSLHandshakeACK, - uint32 /* plugin_dispatcher_id */, - uint32 /* socket_id */, - bool /* succeeded */, - ppapi::PPB_X509Certificate_Fields /* certificate_fields */) -IPC_MESSAGE_ROUTED4(PpapiMsg_PPBTCPSocket_ReadACK, - uint32 /* plugin_dispatcher_id */, - uint32 /* socket_id */, - int32_t /* result */, - std::string /* data */) -IPC_MESSAGE_ROUTED3(PpapiMsg_PPBTCPSocket_WriteACK, - uint32 /* plugin_dispatcher_id */, - uint32 /* socket_id */, - int32_t /* result */) -IPC_MESSAGE_ROUTED3(PpapiMsg_PPBTCPSocket_SetOptionACK, - uint32 /* plugin_dispatcher_id */, - uint32 /* socket_id */, - int32_t /* result */) - #if !defined(OS_NACL) && !defined(NACL_WIN64) // PPP_Instance_Private. IPC_SYNC_MESSAGE_ROUTED1_1(PpapiMsg_PPPInstancePrivate_GetInstanceObject, @@ -798,43 +750,6 @@ IPC_MESSAGE_ROUTED1(PpapiHostMsg_PPBCore_AddRefResource, IPC_MESSAGE_ROUTED1(PpapiHostMsg_PPBCore_ReleaseResource, ppapi::HostResource) -// PPB_FileRef. -// TODO(teravest): Remove these messages when we've switched over to the "new" -// proxy. -IPC_SYNC_MESSAGE_ROUTED3_1(PpapiHostMsg_PPBFileRef_Create, - PP_Instance /* instance */, - PP_Resource /* file_system */, - std::string /* path */, - ppapi::PPB_FileRef_CreateInfo /* result */) -IPC_SYNC_MESSAGE_ROUTED1_1(PpapiHostMsg_PPBFileRef_GetParent, - ppapi::HostResource /* file_ref */, - ppapi::PPB_FileRef_CreateInfo /* result */) -IPC_MESSAGE_ROUTED3(PpapiHostMsg_PPBFileRef_MakeDirectory, - ppapi::HostResource /* file_ref */, - PP_Bool /* make_ancestors */, - uint32_t /* callback_id */) -IPC_MESSAGE_ROUTED4(PpapiHostMsg_PPBFileRef_Touch, - ppapi::HostResource /* file_ref */, - PP_Time /* last_access */, - PP_Time /* last_modified */, - uint32_t /* callback_id */) -IPC_MESSAGE_ROUTED2(PpapiHostMsg_PPBFileRef_Delete, - ppapi::HostResource /* file_ref */, - uint32_t /* callback_id */) -IPC_MESSAGE_ROUTED3(PpapiHostMsg_PPBFileRef_Rename, - ppapi::HostResource /* file_ref */, - ppapi::HostResource /* new_file_ref */, - uint32_t /* callback_id */) -IPC_MESSAGE_ROUTED2(PpapiHostMsg_PPBFileRef_Query, - ppapi::HostResource /* file_ref */, - uint32_t /* callback_id */) -IPC_SYNC_MESSAGE_ROUTED1_1(PpapiHostMsg_PPBFileRef_GetAbsolutePath, - ppapi::HostResource /* file_ref */, - ppapi::proxy::SerializedVar /* result */) -IPC_MESSAGE_ROUTED2(PpapiHostMsg_PPBFileRef_ReadDirectoryEntries, - ppapi::HostResource /* file_ref */, - uint32_t /* callback_id */) - // PPB_Graphics3D. IPC_SYNC_MESSAGE_ROUTED3_1(PpapiHostMsg_PPBGraphics3D_Create, PP_Instance /* instance */, @@ -962,6 +877,9 @@ IPC_SYNC_MESSAGE_ROUTED1_2(PpapiHostMsg_PPBInstance_GetDocumentURL, IPC_SYNC_MESSAGE_ROUTED1_1(PpapiHostMsg_PPBInstance_GetPluginInstanceURL, PP_Instance /* active */, ppapi::proxy::SerializedVar /* result */) +IPC_SYNC_MESSAGE_ROUTED1_1(PpapiHostMsg_PPBInstance_GetPluginReferrerURL, + PP_Instance /* instance */, + ppapi::proxy::SerializedVar /* result */) IPC_MESSAGE_ROUTED4(PpapiHostMsg_PPBInstance_SetCursor, PP_Instance /* instance */, int32_t /* type */, @@ -1056,11 +974,6 @@ IPC_SYNC_MESSAGE_ROUTED2_2( ppapi::proxy::SerializedHandle /* result_shm_handle */) // PPB_ContentDecryptor_Dev messages handled in PPB_Instance_Proxy. -IPC_MESSAGE_ROUTED4(PpapiHostMsg_PPBInstance_NeedKey, - PP_Instance /* instance */, - ppapi::proxy::SerializedVar /* key_system, String */, - ppapi::proxy::SerializedVar /* session_id, String */, - ppapi::proxy::SerializedVar /* init_data, ArrayBuffer */) IPC_MESSAGE_ROUTED3(PpapiHostMsg_PPBInstance_KeyAdded, PP_Instance /* instance */, ppapi::proxy::SerializedVar /* key_system, String */, @@ -1104,12 +1017,6 @@ IPC_MESSAGE_ROUTED3(PpapiHostMsg_PPBInstance_DeliverSamples, std::string /* serialized_block_info */) #endif // !defined(OS_NACL) && !defined(NACL_WIN64) -// PPB_NetworkMonitor_Private. -IPC_MESSAGE_CONTROL1(PpapiHostMsg_PPBNetworkMonitor_Start, - uint32 /* plugin_dispatcher_id */) -IPC_MESSAGE_CONTROL1(PpapiHostMsg_PPBNetworkMonitor_Stop, - uint32 /* plugin_dispatcher_id */) - // PPB_Testing. IPC_SYNC_MESSAGE_ROUTED3_1( PpapiHostMsg_PPBTesting_ReadImageData, @@ -1164,45 +1071,6 @@ IPC_SYNC_MESSAGE_ROUTED1_0(PpapiHostMsg_PPBFlashMessageLoop_Quit, ppapi::HostResource /* flash_message_loop */) #endif // !defined(OS_NACL) && !defined(NACL_WIN64) -// PPB_TCPSocket and PPB_TCPSocket_Private. -// Creates a PPB_TCPSocket resource. -IPC_SYNC_MESSAGE_CONTROL2_1(PpapiHostMsg_PPBTCPSocket_Create, - int32 /* routing_id */, - uint32 /* plugin_dispatcher_id */, - uint32 /* socket_id */) -// Creates a PPB_TCPSocket_Private resource. -IPC_SYNC_MESSAGE_CONTROL2_1(PpapiHostMsg_PPBTCPSocket_CreatePrivate, - int32 /* routing_id */, - uint32 /* plugin_dispatcher_id */, - uint32 /* socket_id */) -IPC_MESSAGE_CONTROL4(PpapiHostMsg_PPBTCPSocket_Connect, - int32 /* routing_id */, - uint32 /* socket_id */, - std::string /* host */, - uint16_t /* port */) -IPC_MESSAGE_CONTROL3(PpapiHostMsg_PPBTCPSocket_ConnectWithNetAddress, - int32 /* routing_id */, - uint32 /* socket_id */, - PP_NetAddress_Private /* net_addr */) -IPC_MESSAGE_CONTROL5(PpapiHostMsg_PPBTCPSocket_SSLHandshake, - uint32 /* socket_id */, - std::string /* server_name */, - uint16_t /* server_port */, - std::vector<std::vector<char> > /* trusted_certs */, - std::vector<std::vector<char> > /* untrusted_certs */) -IPC_MESSAGE_CONTROL2(PpapiHostMsg_PPBTCPSocket_Read, - uint32 /* socket_id */, - int32_t /* bytes_to_read */) -IPC_MESSAGE_CONTROL2(PpapiHostMsg_PPBTCPSocket_Write, - uint32 /* socket_id */, - std::string /* data */) -IPC_MESSAGE_CONTROL1(PpapiHostMsg_PPBTCPSocket_Disconnect, - uint32 /* socket_id */) -IPC_MESSAGE_CONTROL3(PpapiHostMsg_PPBTCPSocket_SetOption, - uint32 /* socket_id */, - PP_TCPSocket_Option /* name */, - ppapi::SocketOptionData /* value */) - // PPB_X509Certificate_Private IPC_SYNC_MESSAGE_CONTROL1_2(PpapiHostMsg_PPBX509Certificate_ParseDER, std::vector<char> /* der */, @@ -1267,7 +1135,6 @@ IPC_MESSAGE_ROUTED2( ppapi::proxy::ResourceMessageReplyParams /* reply_params */, IPC::Message /* nested_msg */) - IPC_SYNC_MESSAGE_CONTROL2_2(PpapiHostMsg_ResourceSyncCall, ppapi::proxy::ResourceMessageCallParams /* call_params */, IPC::Message /* nested_msg */, @@ -1275,27 +1142,27 @@ IPC_SYNC_MESSAGE_CONTROL2_2(PpapiHostMsg_ResourceSyncCall, IPC::Message /* reply_msg */) // This message is sent from the renderer to the browser when it wants to create -// a ResourceHost in the browser. It contains the process ID of the plugin and +// ResourceHosts in the browser. It contains the process ID of the plugin and // the instance of the plugin for which to create the resource for. params // contains the sequence number for the message to track the response. -// The nested message is a ResourceHost creation message. +// The nested messages are ResourceHost creation messages. IPC_MESSAGE_CONTROL5( - PpapiHostMsg_CreateResourceHostFromHost, + PpapiHostMsg_CreateResourceHostsFromHost, int /* routing_id */, int /* child_process_id */, ppapi::proxy::ResourceMessageCallParams /* params */, PP_Instance /* instance */, - IPC::Message /* nested_msg */) + std::vector<IPC::Message> /* nested_msgs */) -// This message is sent from the browser to the renderer when it has created a -// ResourceHost for the renderer. It contains the sequence number that was sent -// in the request and the ID of the pending ResourceHost which was created in -// the browser. This ID is only useful for the plugin which can attach to the -// ResourceHost in the browser. +// This message is sent from the browser to the renderer when it has created +// ResourceHosts for the renderer. It contains the sequence number that was sent +// in the request and the IDs of the pending ResourceHosts which were created in +// the browser. These IDs are only useful for the plugin which can attach to the +// ResourceHosts in the browser. IPC_MESSAGE_ROUTED2( - PpapiHostMsg_CreateResourceHostFromHostReply, + PpapiHostMsg_CreateResourceHostsFromHostReply, int32_t /* sequence */, - int /* pending_host_id */) + std::vector<int> /* pending_host_ids */) //----------------------------------------------------------------------------- // Messages for resources using call/reply above. @@ -1341,7 +1208,7 @@ IPC_MESSAGE_CONTROL4(PpapiHostMsg_FileChooser_Show, std::string /* suggested_file_name */, std::vector<std::string> /* accept_mime_types */) IPC_MESSAGE_CONTROL1(PpapiPluginMsg_FileChooser_ShowReply, - std::vector<ppapi::PPB_FileRef_CreateInfo> /* files */) + std::vector<ppapi::FileRefCreateInfo> /* files */) // FileIO IPC_MESSAGE_CONTROL0(PpapiHostMsg_FileIO_Create) @@ -1417,10 +1284,10 @@ IPC_MESSAGE_CONTROL1(PpapiPluginMsg_FileRef_QueryReply, // location indicated by the FileRef. IPC_MESSAGE_CONTROL0(PpapiHostMsg_FileRef_ReadDirectoryEntries) -// FileRef_CreateInfo does not provide file type information, so two +// FileRefCreateInfo does not provide file type information, so two // corresponding vectors are returned. IPC_MESSAGE_CONTROL2(PpapiPluginMsg_FileRef_ReadDirectoryEntriesReply, - std::vector<ppapi::FileRef_CreateInfo> /* files */, + std::vector<ppapi::FileRefCreateInfo> /* files */, std::vector<PP_FileType> /* file_types */) // Requests that the browser reply with the absolute path to the indicated @@ -1437,6 +1304,7 @@ IPC_MESSAGE_CONTROL1(PpapiHostMsg_FileSystem_Open, IPC_MESSAGE_CONTROL0(PpapiPluginMsg_FileSystem_OpenReply) IPC_MESSAGE_CONTROL1(PpapiHostMsg_FileSystem_InitIsolatedFileSystem, std::string /* fsid */) +IPC_MESSAGE_CONTROL0(PpapiPluginMsg_FileSystem_InitIsolatedFileSystemReply) // Flash DRM ------------------------------------------------------------------ IPC_MESSAGE_CONTROL0(PpapiHostMsg_FlashDRM_Create) @@ -1460,7 +1328,7 @@ IPC_MESSAGE_CONTROL0(PpapiHostMsg_FlashDRM_GetVoucherFile) // Reply message for GetVoucherFile which contains the CreateInfo for a // PPB_FileRef which points to the voucher file. IPC_MESSAGE_CONTROL1(PpapiPluginMsg_FlashDRM_GetVoucherFileReply, - ppapi::PPB_FileRef_CreateInfo /* file_info */) + ppapi::FileRefCreateInfo /* file_info */) // Gamepad. IPC_MESSAGE_CONTROL0(PpapiHostMsg_Gamepad_Create) @@ -1501,6 +1369,13 @@ IPC_MESSAGE_CONTROL2(PpapiHostMsg_Graphics2D_ReadImageData, PP_Point /* top_left */) IPC_MESSAGE_CONTROL0(PpapiPluginMsg_Graphics2D_ReadImageDataAck) +// NetworkMonitor. +IPC_MESSAGE_CONTROL0(PpapiHostMsg_NetworkMonitor_Create) +IPC_MESSAGE_CONTROL1(PpapiPluginMsg_NetworkMonitor_NetworkList, + ppapi::proxy::SerializedNetworkList /* network_list */) +IPC_MESSAGE_CONTROL0(PpapiPluginMsg_NetworkMonitor_Forbidden) + + // NetworkProxy ---------------------------------------------------------------- IPC_MESSAGE_CONTROL0(PpapiHostMsg_NetworkProxy_Create) @@ -1556,12 +1431,74 @@ IPC_MESSAGE_CONTROL2(PpapiPluginMsg_HostResolver_ResolveReply, std::string /* canonical_name */, std::vector<PP_NetAddress_Private> /* net_address_list */) +// Platform Verification ------------------------------------------------------- +IPC_MESSAGE_CONTROL0(PpapiHostMsg_PlatformVerification_Create) +IPC_MESSAGE_CONTROL0(PpapiHostMsg_PlatformVerification_CanChallengePlatform) +IPC_MESSAGE_CONTROL1( + PpapiHostMsg_PlatformVerification_CanChallengePlatformReply, + bool /* can_challenge_platform */) +IPC_MESSAGE_CONTROL2(PpapiHostMsg_PlatformVerification_ChallengePlatform, + std::string /* service_id */, + std::vector<uint8_t> /* challenge */) +IPC_MESSAGE_CONTROL3(PpapiHostMsg_PlatformVerification_ChallengePlatformReply, + std::vector<uint8_t> /* signed_data */, + std::vector<uint8_t> /* signed_data_signature */, + std::string /* platform_key_certificate */) + // Printing. IPC_MESSAGE_CONTROL0(PpapiHostMsg_Printing_Create) IPC_MESSAGE_CONTROL0(PpapiHostMsg_Printing_GetDefaultPrintSettings) IPC_MESSAGE_CONTROL1(PpapiPluginMsg_Printing_GetDefaultPrintSettingsReply, PP_PrintSettings_Dev /* print_settings */) +// TCP Socket ------------------------------------------------------------------ +// Creates a PPB_TCPSocket resource. +IPC_MESSAGE_CONTROL1(PpapiHostMsg_TCPSocket_Create, + ppapi::TCPSocketVersion /* version */) + +// Creates a PPB_TCPSocket_Private resource. +IPC_MESSAGE_CONTROL0(PpapiHostMsg_TCPSocket_CreatePrivate) + +IPC_MESSAGE_CONTROL1(PpapiHostMsg_TCPSocket_Bind, + PP_NetAddress_Private /* net_addr */) +IPC_MESSAGE_CONTROL1(PpapiPluginMsg_TCPSocket_BindReply, + PP_NetAddress_Private /* local_addr */) +IPC_MESSAGE_CONTROL2(PpapiHostMsg_TCPSocket_Connect, + std::string /* host */, + uint16_t /* port */) +IPC_MESSAGE_CONTROL1(PpapiHostMsg_TCPSocket_ConnectWithNetAddress, + PP_NetAddress_Private /* net_addr */) +IPC_MESSAGE_CONTROL2(PpapiPluginMsg_TCPSocket_ConnectReply, + PP_NetAddress_Private /* local_addr */, + PP_NetAddress_Private /* remote_addr */) +IPC_MESSAGE_CONTROL4(PpapiHostMsg_TCPSocket_SSLHandshake, + std::string /* server_name */, + uint16_t /* server_port */, + std::vector<std::vector<char> > /* trusted_certs */, + std::vector<std::vector<char> > /* untrusted_certs */) +IPC_MESSAGE_CONTROL1(PpapiPluginMsg_TCPSocket_SSLHandshakeReply, + ppapi::PPB_X509Certificate_Fields /* certificate_fields */) +IPC_MESSAGE_CONTROL1(PpapiHostMsg_TCPSocket_Read, + int32_t /* bytes_to_read */) +IPC_MESSAGE_CONTROL1(PpapiPluginMsg_TCPSocket_ReadReply, + std::string /* data */) +IPC_MESSAGE_CONTROL1(PpapiHostMsg_TCPSocket_Write, + std::string /* data */) +IPC_MESSAGE_CONTROL0(PpapiPluginMsg_TCPSocket_WriteReply) +IPC_MESSAGE_CONTROL1(PpapiHostMsg_TCPSocket_Listen, + int32_t /* backlog */) +IPC_MESSAGE_CONTROL0(PpapiPluginMsg_TCPSocket_ListenReply) +IPC_MESSAGE_CONTROL0(PpapiHostMsg_TCPSocket_Accept) +IPC_MESSAGE_CONTROL3(PpapiPluginMsg_TCPSocket_AcceptReply, + int /* pending_host_id*/, + PP_NetAddress_Private /* local_addr */, + PP_NetAddress_Private /* remote_addr */) +IPC_MESSAGE_CONTROL0(PpapiHostMsg_TCPSocket_Close) +IPC_MESSAGE_CONTROL2(PpapiHostMsg_TCPSocket_SetOption, + PP_TCPSocket_Option /* name */, + ppapi::SocketOptionData /* value */) +IPC_MESSAGE_CONTROL0(PpapiPluginMsg_TCPSocket_SetOptionReply) + // TCP Server Socket ----------------------------------------------------------- // Creates a PPB_TCPServerSocket_Private resource. IPC_MESSAGE_CONTROL0(PpapiHostMsg_TCPServerSocket_CreatePrivate) @@ -1571,10 +1508,9 @@ IPC_MESSAGE_CONTROL2(PpapiHostMsg_TCPServerSocket_Listen, int32_t /* backlog */) IPC_MESSAGE_CONTROL1(PpapiPluginMsg_TCPServerSocket_ListenReply, PP_NetAddress_Private /* local_addr */) -IPC_MESSAGE_CONTROL1(PpapiHostMsg_TCPServerSocket_Accept, - uint32 /* plugin_dispatcher_id */) +IPC_MESSAGE_CONTROL0(PpapiHostMsg_TCPServerSocket_Accept) IPC_MESSAGE_CONTROL3(PpapiPluginMsg_TCPServerSocket_AcceptReply, - uint32 /* accepted_socket_id */, + int /* pending_resource_id */, PP_NetAddress_Private /* local_addr */, PP_NetAddress_Private /* remote_addr */) IPC_MESSAGE_CONTROL0(PpapiHostMsg_TCPServerSocket_StopListening) @@ -1805,30 +1741,6 @@ IPC_MESSAGE_CONTROL0(PpapiHostMsg_BrowserFontSingleton_GetFontFamilies) IPC_MESSAGE_CONTROL1(PpapiPluginMsg_BrowserFontSingleton_GetFontFamiliesReply, std::string /* families */) -// FileRef. -// Requests that the browser reply with file system and path information about -// the resource indicated in |params| which exists in the given -// |child_process_id|. |routing_id| is sent so that the reply can be routed -// properly in the renderer. -// Only sent from the renderer to the browser. -IPC_MESSAGE_CONTROL4(PpapiHostMsg_FileRef_GetInfoForRenderer, - int /* routing_id */, - int /* child_process_id */, - int32_t /* sequence */, - std::vector<PP_Resource> /* resources */) - -// Reply to PpapiHostMsg_FileRef_GetInfoForRenderer with a sequence number for -// invoking the right callback, |fs_type| which indicates the file system, and -// path information in either |file_system_url_spec| (for internal file systems) -// or |external_path| (for external file systems). -// Only sent from the browser to the renderer. -IPC_MESSAGE_ROUTED5(PpapiHostMsg_FileRef_GetInfoForRendererReply, - int32_t /* sequence */, - std::vector<PP_Resource> /* resources */, - std::vector<PP_FileSystemType> /* fs_type */, - std::vector<std::string> /* file_system_url_spec */, - std::vector<base::FilePath> /* external_path */) - // Flash ----------------------------------------------------------------------- IPC_MESSAGE_CONTROL0(PpapiHostMsg_Flash_Create) diff --git a/chromium/ppapi/proxy/ppapi_param_traits.cc b/chromium/ppapi/proxy/ppapi_param_traits.cc index ca25f82f257..5d4345f85aa 100644 --- a/chromium/ppapi/proxy/ppapi_param_traits.cc +++ b/chromium/ppapi/proxy/ppapi_param_traits.cc @@ -175,36 +175,6 @@ void ParamTraits<PP_NetAddress_Private>::Log(const param_type& p, l->append(" bytes)>"); } -// TODO(teravest): Remove this when FileRef is moved to the "new" proxy. -// PPB_FileRef_CreateInfo ------------------------------------------------------ - -// static -void ParamTraits<ppapi::PPB_FileRef_CreateInfo>::Write(Message* m, - const param_type& p) { - ParamTraits<ppapi::HostResource>::Write(m, p.resource); - ParamTraits<int>::Write(m, p.file_system_type); - ParamTraits<std::string>::Write(m, p.path); - ParamTraits<std::string>::Write(m, p.name); - ParamTraits<PP_Resource>::Write(m, p.file_system_plugin_resource); -} - -// static -bool ParamTraits<ppapi::PPB_FileRef_CreateInfo>::Read(const Message* m, - PickleIterator* iter, - param_type* r) { - return - ParamTraits<ppapi::HostResource>::Read(m, iter, &r->resource) && - ParamTraits<int>::Read(m, iter, &r->file_system_type) && - ParamTraits<std::string>::Read(m, iter, &r->path) && - ParamTraits<std::string>::Read(m, iter, &r->name) && - ParamTraits<PP_Resource>::Read(m, iter, &r->file_system_plugin_resource); -} - -// static -void ParamTraits<ppapi::PPB_FileRef_CreateInfo>::Log(const param_type& p, - std::string* l) { -} - // HostResource ---------------------------------------------------------------- // static @@ -274,28 +244,6 @@ void ParamTraits< std::vector<ppapi::proxy::SerializedVar> >::Log( std::string* l) { } -// std::vector<PPB_FileRef_CreateInfo> ----------------------------------------- - -void ParamTraits< std::vector<ppapi::PPB_FileRef_CreateInfo> >::Write( - Message* m, - const param_type& p) { - WriteVectorWithoutCopy(m, p); -} - -// static -bool ParamTraits< std::vector<ppapi::PPB_FileRef_CreateInfo> >::Read( - const Message* m, - PickleIterator* iter, - param_type* r) { - return ReadVectorWithoutCopy(m, iter, r); -} - -// static -void ParamTraits< std::vector<ppapi::PPB_FileRef_CreateInfo> >::Log( - const param_type& p, - std::string* l) { -} - // ppapi::PpapiPermissions ----------------------------------------------------- void ParamTraits<ppapi::PpapiPermissions>::Write(Message* m, diff --git a/chromium/ppapi/proxy/ppapi_param_traits.h b/chromium/ppapi/proxy/ppapi_param_traits.h index f56415a869f..b56ec3e3d4b 100644 --- a/chromium/ppapi/proxy/ppapi_param_traits.h +++ b/chromium/ppapi/proxy/ppapi_param_traits.h @@ -17,7 +17,6 @@ #include "ppapi/shared_impl/file_path.h" #include "ppapi/shared_impl/file_ref_create_info.h" #include "ppapi/shared_impl/ppapi_permissions.h" -#include "ppapi/shared_impl/ppb_file_ref_shared.h" #include "ppapi/shared_impl/socket_option_data.h" struct PP_FileInfo; @@ -77,15 +76,6 @@ struct PPAPI_PROXY_EXPORT ParamTraits< static void Log(const param_type& p, std::string* l); }; -// TODO(teravest): Remove this when we've switched over to the new proxy. -template<> -struct PPAPI_PROXY_EXPORT ParamTraits<ppapi::PPB_FileRef_CreateInfo> { - typedef ppapi::PPB_FileRef_CreateInfo param_type; - static void Write(Message* m, const param_type& p); - static bool Read(const Message* m, PickleIterator* iter, param_type* r); - static void Log(const param_type& p, std::string* l); -}; - template<> struct PPAPI_PROXY_EXPORT ParamTraits< ppapi::proxy::PPBURLLoader_UpdateProgress_Params> { @@ -154,15 +144,6 @@ struct PPAPI_PROXY_EXPORT ParamTraits< }; template<> -struct PPAPI_PROXY_EXPORT ParamTraits< std::vector< - ppapi::PPB_FileRef_CreateInfo> > { - typedef std::vector<ppapi::PPB_FileRef_CreateInfo> param_type; - static void Write(Message* m, const param_type& p); - static bool Read(const Message* m, PickleIterator* iter, param_type* r); - static void Log(const param_type& p, std::string* l); -}; - -template<> struct PPAPI_PROXY_EXPORT ParamTraits<ppapi::PpapiPermissions> { typedef ppapi::PpapiPermissions param_type; static void Write(Message* m, const param_type& p); diff --git a/chromium/ppapi/proxy/ppapi_proxy_test.cc b/chromium/ppapi/proxy/ppapi_proxy_test.cc index 5e4b67bc4f3..87aa22b2860 100644 --- a/chromium/ppapi/proxy/ppapi_proxy_test.cc +++ b/chromium/ppapi/proxy/ppapi_proxy_test.cc @@ -227,8 +227,12 @@ void PluginProxyTestHarness::CreatePluginGlobals() { if (globals_config_ == PER_THREAD_GLOBALS) { plugin_globals_.reset(new PluginGlobals(PpapiGlobals::PerThreadForTest())); PpapiGlobals::SetPpapiGlobalsOnThreadForTest(GetGlobals()); + // Enable locking in case some other unit test ran before us and disabled + // locking. + ProxyLock::EnableLockingOnThreadForTest(); } else { plugin_globals_.reset(new PluginGlobals()); + ProxyLock::EnableLockingOnThreadForTest(); } } @@ -471,7 +475,10 @@ void HostProxyTestHarness::CreateHostGlobals() { if (globals_config_ == PER_THREAD_GLOBALS) { host_globals_.reset(new TestGlobals(PpapiGlobals::PerThreadForTest())); PpapiGlobals::SetPpapiGlobalsOnThreadForTest(GetGlobals()); + // The host side of the proxy does not lock. + ProxyLock::DisableLockingOnThreadForTest(); } else { + ProxyLock::DisableLockingOnThreadForTest(); host_globals_.reset(new TestGlobals()); } } diff --git a/chromium/ppapi/proxy/ppb_audio_proxy.cc b/chromium/ppapi/proxy/ppb_audio_proxy.cc index aae9a5de198..49ed0afb2d2 100644 --- a/chromium/ppapi/proxy/ppb_audio_proxy.cc +++ b/chromium/ppapi/proxy/ppb_audio_proxy.cc @@ -37,7 +37,7 @@ class Audio : public Resource, public PPB_Audio_Shared { public: Audio(const HostResource& audio_id, PP_Resource config_id, - PPB_Audio_Callback callback, + const AudioCallbackCombined& callback, void* user_data); virtual ~Audio(); @@ -64,7 +64,7 @@ class Audio : public Resource, public PPB_Audio_Shared { Audio::Audio(const HostResource& audio_id, PP_Resource config_id, - PPB_Audio_Callback callback, + const AudioCallbackCombined& callback, void* user_data) : Resource(OBJECT_IS_PROXY, audio_id), config_(config_id) { @@ -138,7 +138,7 @@ PPB_Audio_Proxy::~PPB_Audio_Proxy() { PP_Resource PPB_Audio_Proxy::CreateProxyResource( PP_Instance instance_id, PP_Resource config_id, - PPB_Audio_Callback audio_callback, + const AudioCallbackCombined& audio_callback, void* user_data) { PluginDispatcher* dispatcher = PluginDispatcher::GetForInstance(instance_id); if (!dispatcher) @@ -148,7 +148,7 @@ PP_Resource PPB_Audio_Proxy::CreateProxyResource( if (config.failed()) return 0; - if (!audio_callback) + if (!audio_callback.IsValid()) return 0; HostResource result; @@ -341,6 +341,7 @@ void PPB_Audio_Proxy::OnMsgNotifyAudioStreamCreated( enter.resource()->pp_instance(), handle.shmem(), media::PacketSizeInBytes(handle.size()), IPC::PlatformFileForTransitToPlatformFile(socket_handle.descriptor()), + config.object()->GetSampleRate(), config.object()->GetSampleFrameCount()); } } diff --git a/chromium/ppapi/proxy/ppb_audio_proxy.h b/chromium/ppapi/proxy/ppb_audio_proxy.h index fa887de7f1a..cc8af6cb9da 100644 --- a/chromium/ppapi/proxy/ppb_audio_proxy.h +++ b/chromium/ppapi/proxy/ppb_audio_proxy.h @@ -21,6 +21,7 @@ namespace ppapi { +class AudioCallbackCombined; class HostResource; namespace proxy { @@ -33,11 +34,11 @@ class PPB_Audio_Proxy : public InterfaceProxy { virtual ~PPB_Audio_Proxy(); // Creates an Audio object in the plugin process. - static PP_Resource CreateProxyResource(PP_Instance instance_id, - PP_Resource config_id, - PPB_Audio_Callback audio_callback, - void* user_data); - + static PP_Resource CreateProxyResource( + PP_Instance instance_id, + PP_Resource config_id, + const AudioCallbackCombined& audio_callback, + void* user_data); // InterfaceProxy implementation. virtual bool OnMessageReceived(const IPC::Message& msg); diff --git a/chromium/ppapi/proxy/ppb_file_ref_proxy.cc b/chromium/ppapi/proxy/ppb_file_ref_proxy.cc deleted file mode 100644 index 62c55da9d8b..00000000000 --- a/chromium/ppapi/proxy/ppb_file_ref_proxy.cc +++ /dev/null @@ -1,549 +0,0 @@ -// Copyright (c) 2012 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#include "ppapi/proxy/ppb_file_ref_proxy.h" - -#include <map> - -#include "base/bind.h" -#include "ppapi/c/pp_directory_entry.h" -#include "ppapi/c/pp_errors.h" -#include "ppapi/c/ppb_file_ref.h" -#include "ppapi/c/private/ppb_file_ref_private.h" -#include "ppapi/c/private/ppb_proxy_private.h" -#include "ppapi/proxy/enter_proxy.h" -#include "ppapi/proxy/host_dispatcher.h" -#include "ppapi/proxy/plugin_dispatcher.h" -#include "ppapi/proxy/ppapi_messages.h" -#include "ppapi/proxy/serialized_var.h" -#include "ppapi/shared_impl/array_writer.h" -#include "ppapi/shared_impl/ppb_file_ref_shared.h" -#include "ppapi/shared_impl/scoped_pp_resource.h" -#include "ppapi/shared_impl/tracked_callback.h" -#include "ppapi/thunk/resource_creation_api.h" -#include "ppapi/thunk/thunk.h" - -using ppapi::thunk::EnterResourceNoLock; -using ppapi::thunk::PPB_FileRef_API; -using ppapi::thunk::ResourceCreationAPI; - -namespace ppapi { -namespace proxy { - -namespace { - -void ReleaseEntries(const std::vector<PP_DirectoryEntry>& entries) { - ResourceTracker* tracker = PpapiGlobals::Get()->GetResourceTracker(); - for (std::vector<PP_DirectoryEntry>::const_iterator it = entries.begin(); - it != entries.end(); ++it) - tracker->ReleaseResource(it->file_ref); -} - -} // namespace - -class FileRef : public PPB_FileRef_Shared { - public: - explicit FileRef(const PPB_FileRef_CreateInfo& info); - virtual ~FileRef(); - - // Resource overrides. - virtual void LastPluginRefWasDeleted() OVERRIDE; - - // PPB_FileRef_API implementation (not provided by PPB_FileRef_Shared). - virtual PP_Resource GetParent() OVERRIDE; - virtual int32_t MakeDirectory( - PP_Bool make_ancestors, - scoped_refptr<TrackedCallback> callback) OVERRIDE; - virtual int32_t Touch(PP_Time last_access_time, - PP_Time last_modified_time, - scoped_refptr<TrackedCallback> callback) OVERRIDE; - virtual int32_t Delete(scoped_refptr<TrackedCallback> callback) OVERRIDE; - virtual int32_t Rename(PP_Resource new_file_ref, - scoped_refptr<TrackedCallback> callback) OVERRIDE; - virtual int32_t Query(PP_FileInfo* info, - scoped_refptr<TrackedCallback> callback) OVERRIDE; - virtual int32_t ReadDirectoryEntries( - const PP_ArrayOutput& output, - scoped_refptr<TrackedCallback> callback) OVERRIDE; - virtual int32_t QueryInHost( - linked_ptr<PP_FileInfo> info, - scoped_refptr<TrackedCallback> callback) OVERRIDE; - virtual int32_t ReadDirectoryEntriesInHost( - linked_ptr<std::vector<ppapi::PPB_FileRef_CreateInfo> > files, - linked_ptr<std::vector<PP_FileType> > file_types, - scoped_refptr<TrackedCallback> callback) OVERRIDE; - virtual PP_Var GetAbsolutePath() OVERRIDE; - - // Executes the pending callback with the given ID. See pending_callbacks_. - void ExecuteCallback(uint32_t callback_id, int32_t result); - int32_t SetFileInfo(uint32_t callback_id, const PP_FileInfo& info); - int32_t SetReadDirectoryEntriesOutput( - uint32_t callback_id, - const std::vector<ppapi::PPB_FileRef_CreateInfo>& infos, - const std::vector<PP_FileType>& file_types); - - private: - PluginDispatcher* GetDispatcher() const { - return PluginDispatcher::GetForResource(this); - } - - // Adds a callback to the list and returns its ID. - uint32_t SendCallback(scoped_refptr<TrackedCallback> callback); - - // This class can have any number of out-standing requests with completion - // callbacks, in contrast to most resources which have one possible pending - // callback pending (like a Flush callback). - // - // To keep track of them, assign integer IDs to the callbacks, which is how - // the callback will be identified when it's passed to the host and then - // back here. Use unsigned so that overflow is well-defined. - uint32_t next_callback_id_; - typedef std::map<uint32_t, - scoped_refptr<TrackedCallback> > PendingCallbackMap; - PendingCallbackMap pending_callbacks_; - - // Used to keep pointers to PP_FileInfo instances that are written before - // callbacks are invoked. The id of a pending file info will match that of - // the corresponding callback. - typedef std::map<uint32_t, PP_FileInfo*> PendingFileInfoMap; - PendingFileInfoMap pending_file_infos_; - - // Used to keep PP_ArrayOutput instances that are written before callbacks - // are invoked. The id of a pending array output will match that of the - // corresponding callback. - typedef std::map<uint32_t, PP_ArrayOutput> - PendingReadDirectoryEntriesOutputMap; - PendingReadDirectoryEntriesOutputMap pending_read_entries_outputs_; - - // Holds a reference on plugin side when running out of process, so that - // FileSystem won't die before FileRef. See PPB_FileRef_Impl for - // corresponding code for in-process mode. Note that this workaround will - // be no longer needed after FileRef refactoring. - ScopedPPResource file_system_; - - DISALLOW_IMPLICIT_CONSTRUCTORS(FileRef); -}; - -FileRef::FileRef(const PPB_FileRef_CreateInfo& info) - : PPB_FileRef_Shared(OBJECT_IS_PROXY, info), - next_callback_id_(0u), - file_system_(info.file_system_plugin_resource) { -} - -FileRef::~FileRef() { - // The callbacks map should have been cleared by LastPluginRefWasDeleted. - DCHECK(pending_callbacks_.empty()); - DCHECK(pending_file_infos_.empty()); - DCHECK(pending_read_entries_outputs_.empty()); -} - -void FileRef::LastPluginRefWasDeleted() { - // The callback tracker will abort our callbacks for us. - pending_callbacks_.clear(); - pending_file_infos_.clear(); - pending_read_entries_outputs_.clear(); -} - -PP_Resource FileRef::GetParent() { - PPB_FileRef_CreateInfo create_info; - GetDispatcher()->Send(new PpapiHostMsg_PPBFileRef_GetParent( - API_ID_PPB_FILE_REF, host_resource(), &create_info)); - return PPB_FileRef_Proxy::DeserializeFileRef(create_info); -} - -int32_t FileRef::MakeDirectory(PP_Bool make_ancestors, - scoped_refptr<TrackedCallback> callback) { - GetDispatcher()->Send(new PpapiHostMsg_PPBFileRef_MakeDirectory( - API_ID_PPB_FILE_REF, host_resource(), make_ancestors, - SendCallback(callback))); - return PP_OK_COMPLETIONPENDING; -} - -int32_t FileRef::Touch(PP_Time last_access_time, - PP_Time last_modified_time, - scoped_refptr<TrackedCallback> callback) { - GetDispatcher()->Send(new PpapiHostMsg_PPBFileRef_Touch( - API_ID_PPB_FILE_REF, host_resource(), last_access_time, - last_modified_time, SendCallback(callback))); - return PP_OK_COMPLETIONPENDING; -} - -int32_t FileRef::Delete(scoped_refptr<TrackedCallback> callback) { - GetDispatcher()->Send(new PpapiHostMsg_PPBFileRef_Delete( - API_ID_PPB_FILE_REF, host_resource(), SendCallback(callback))); - return PP_OK_COMPLETIONPENDING; -} - -int32_t FileRef::Rename(PP_Resource new_file_ref, - scoped_refptr<TrackedCallback> callback) { - Resource* new_file_ref_object = - PpapiGlobals::Get()->GetResourceTracker()->GetResource(new_file_ref); - if (!new_file_ref_object || - new_file_ref_object->host_resource().instance() != pp_instance()) - return PP_ERROR_BADRESOURCE; - - GetDispatcher()->Send(new PpapiHostMsg_PPBFileRef_Rename( - API_ID_PPB_FILE_REF, host_resource(), - new_file_ref_object->host_resource(), SendCallback(callback))); - return PP_OK_COMPLETIONPENDING; -} - -int32_t FileRef::Query(PP_FileInfo* info, - scoped_refptr<TrackedCallback> callback) { - // Store the pending file info id. - uint32_t id = SendCallback(callback); - pending_file_infos_[id] = info; - GetDispatcher()->Send(new PpapiHostMsg_PPBFileRef_Query( - API_ID_PPB_FILE_REF, host_resource(), id)); - return PP_OK_COMPLETIONPENDING; -} - -int32_t FileRef::ReadDirectoryEntries( - const PP_ArrayOutput& output, - scoped_refptr<TrackedCallback> callback) { - // Store the pending read entries output id. - uint32_t id = SendCallback(callback); - pending_read_entries_outputs_[id] = output; - GetDispatcher()->Send(new PpapiHostMsg_PPBFileRef_ReadDirectoryEntries( - API_ID_PPB_FILE_REF, host_resource(), id)); - return PP_OK_COMPLETIONPENDING; -} - -int32_t FileRef::QueryInHost( - linked_ptr<PP_FileInfo> info, - scoped_refptr<TrackedCallback> callback) { - NOTREACHED(); - return PP_ERROR_FAILED; -} - -int32_t FileRef::ReadDirectoryEntriesInHost( - linked_ptr<std::vector<ppapi::PPB_FileRef_CreateInfo> > files, - linked_ptr<std::vector<PP_FileType> > file_types, - scoped_refptr<TrackedCallback> callback) { - NOTREACHED(); - return PP_ERROR_FAILED; -} - -PP_Var FileRef::GetAbsolutePath() { - ReceiveSerializedVarReturnValue result; - GetDispatcher()->Send(new PpapiHostMsg_PPBFileRef_GetAbsolutePath( - API_ID_PPB_FILE_REF, host_resource(), &result)); - return result.Return(GetDispatcher()); -} - -void FileRef::ExecuteCallback(uint32_t callback_id, int32_t result) { - PendingCallbackMap::iterator found = pending_callbacks_.find(callback_id); - if (found == pending_callbacks_.end()) { - // This will happen when the plugin deletes its resource with a pending - // callback. The callback will be locally issued with an ABORTED call while - // the operation may still be pending in the renderer. - return; - } - - // Executing the callback may mutate the callback list. - scoped_refptr<TrackedCallback> callback = found->second; - pending_callbacks_.erase(found); - callback->Run(result); -} - -int32_t FileRef::SetFileInfo(uint32_t callback_id, const PP_FileInfo& info) { - PendingFileInfoMap::iterator found = pending_file_infos_.find(callback_id); - if (found == pending_file_infos_.end()) - return PP_ERROR_FAILED; - PP_FileInfo* target_info = found->second; - *target_info = info; - pending_file_infos_.erase(found); - return PP_OK; -} - -int32_t FileRef::SetReadDirectoryEntriesOutput( - uint32_t callback_id, - const std::vector<ppapi::PPB_FileRef_CreateInfo>& infos, - const std::vector<PP_FileType>& file_types) { - PendingReadDirectoryEntriesOutputMap::iterator found = - pending_read_entries_outputs_.find(callback_id); - if (found == pending_read_entries_outputs_.end()) - return PP_ERROR_FAILED; - - PP_ArrayOutput output = found->second; - pending_read_entries_outputs_.erase(found); - - std::vector<PP_DirectoryEntry> entries; - for (size_t i = 0; i < infos.size(); ++i) { - PP_DirectoryEntry entry; - entry.file_ref = PPB_FileRef_Proxy::DeserializeFileRef(infos[i]); - entry.file_type = file_types[i]; - entries.push_back(entry); - } - - ArrayWriter writer(output); - if (!writer.is_valid()) { - ReleaseEntries(entries); - return PP_ERROR_BADARGUMENT; - } - - writer.StoreVector(entries); - return PP_OK; -} - -uint32_t FileRef::SendCallback(scoped_refptr<TrackedCallback> callback) { - // In extreme cases the IDs may wrap around, so avoid duplicates. - while (pending_callbacks_.count(next_callback_id_)) - ++next_callback_id_; - - pending_callbacks_[next_callback_id_] = callback; - return next_callback_id_++; -} - -PPB_FileRef_Proxy::PPB_FileRef_Proxy(Dispatcher* dispatcher) - : InterfaceProxy(dispatcher), - callback_factory_(this) { -} - -PPB_FileRef_Proxy::~PPB_FileRef_Proxy() { -} - -// static -PP_Resource PPB_FileRef_Proxy::CreateProxyResource(PP_Instance instance, - PP_Resource file_system, - const char* path) { - PPB_FileRef_CreateInfo create_info; - PluginDispatcher::GetForInstance(instance)->Send( - new PpapiHostMsg_PPBFileRef_Create( - API_ID_PPB_FILE_REF, instance, file_system, path, &create_info)); - return PPB_FileRef_Proxy::DeserializeFileRef(create_info); -} - -bool PPB_FileRef_Proxy::OnMessageReceived(const IPC::Message& msg) { - bool handled = true; - IPC_BEGIN_MESSAGE_MAP(PPB_FileRef_Proxy, msg) -#if !defined(OS_NACL) - IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBFileRef_Create, OnMsgCreate) - IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBFileRef_GetParent, OnMsgGetParent) - IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBFileRef_MakeDirectory, - OnMsgMakeDirectory) - IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBFileRef_Touch, OnMsgTouch) - IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBFileRef_Delete, OnMsgDelete) - IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBFileRef_Rename, OnMsgRename) - IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBFileRef_Query, OnMsgQuery) - IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBFileRef_ReadDirectoryEntries, - OnMsgReadDirectoryEntries) - IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBFileRef_GetAbsolutePath, - OnMsgGetAbsolutePath) -#endif // !defined(OS_NACL) - - IPC_MESSAGE_HANDLER(PpapiMsg_PPBFileRef_CallbackComplete, - OnMsgCallbackComplete) - IPC_MESSAGE_HANDLER(PpapiMsg_PPBFileRef_QueryCallbackComplete, - OnMsgQueryCallbackComplete) - IPC_MESSAGE_HANDLER( - PpapiMsg_PPBFileRef_ReadDirectoryEntriesCallbackComplete, - OnMsgReadDirectoryEntriesCallbackComplete) - IPC_MESSAGE_UNHANDLED(handled = false) - IPC_END_MESSAGE_MAP() - return handled; -} - -// static -void PPB_FileRef_Proxy::SerializeFileRef(PP_Resource file_ref, - PPB_FileRef_CreateInfo* result) { - EnterResourceNoLock<PPB_FileRef_API> enter(file_ref, false); - if (enter.succeeded()) - *result = enter.object()->GetCreateInfo(); -} - -// static -PP_Resource PPB_FileRef_Proxy::DeserializeFileRef( - const PPB_FileRef_CreateInfo& serialized) { - if (serialized.resource.is_null()) - return 0; // Resource invalid. - return (new FileRef(serialized))->GetReference(); -} - -#if !defined(OS_NACL) -void PPB_FileRef_Proxy::OnMsgCreate(PP_Instance pp_instance, - PP_Resource file_system, - const std::string& path, - PPB_FileRef_CreateInfo* result) { - thunk::EnterResourceCreation enter(pp_instance); - if (enter.failed()) - return; - - PP_Resource resource = enter.functions()->CreateFileRef( - pp_instance, file_system, path.c_str()); - if (!resource) - return; // CreateInfo default constructor initializes to 0. - SerializeFileRef(resource, result); -} - -void PPB_FileRef_Proxy::OnMsgGetParent(const HostResource& host_resource, - PPB_FileRef_CreateInfo* result) { - EnterHostFromHostResource<PPB_FileRef_API> enter(host_resource); - if (enter.succeeded()) - SerializeFileRef(enter.object()->GetParent(), result); -} - -void PPB_FileRef_Proxy::OnMsgMakeDirectory(const HostResource& host_resource, - PP_Bool make_ancestors, - uint32_t callback_id) { - EnterHostFromHostResourceForceCallback<PPB_FileRef_API> enter( - host_resource, callback_factory_, - &PPB_FileRef_Proxy::OnCallbackCompleteInHost, host_resource, callback_id); - if (enter.succeeded()) { - enter.SetResult(enter.object()->MakeDirectory(make_ancestors, - enter.callback())); - } -} - -void PPB_FileRef_Proxy::OnMsgTouch(const HostResource& host_resource, - PP_Time last_access, - PP_Time last_modified, - uint32_t callback_id) { - EnterHostFromHostResourceForceCallback<PPB_FileRef_API> enter( - host_resource, callback_factory_, - &PPB_FileRef_Proxy::OnCallbackCompleteInHost, host_resource, callback_id); - if (enter.succeeded()) { - enter.SetResult(enter.object()->Touch(last_access, last_modified, - enter.callback())); - } -} - -void PPB_FileRef_Proxy::OnMsgDelete(const HostResource& host_resource, - uint32_t callback_id) { - EnterHostFromHostResourceForceCallback<PPB_FileRef_API> enter( - host_resource, callback_factory_, - &PPB_FileRef_Proxy::OnCallbackCompleteInHost, host_resource, callback_id); - if (enter.succeeded()) - enter.SetResult(enter.object()->Delete(enter.callback())); -} - -void PPB_FileRef_Proxy::OnMsgRename(const HostResource& file_ref, - const HostResource& new_file_ref, - uint32_t callback_id) { - EnterHostFromHostResourceForceCallback<PPB_FileRef_API> enter( - file_ref, callback_factory_, - &PPB_FileRef_Proxy::OnCallbackCompleteInHost, file_ref, callback_id); - if (enter.succeeded()) { - enter.SetResult(enter.object()->Rename(new_file_ref.host_resource(), - enter.callback())); - } -} - -void PPB_FileRef_Proxy::OnMsgQuery(const HostResource& file_ref, - uint32_t callback_id) { - linked_ptr<PP_FileInfo> info(new PP_FileInfo()); - EnterHostFromHostResourceForceCallback<PPB_FileRef_API> enter( - file_ref, callback_factory_, - &PPB_FileRef_Proxy::OnQueryCallbackCompleteInHost, file_ref, - info, callback_id); - if (enter.succeeded()) - enter.SetResult(enter.object()->QueryInHost(info, enter.callback())); -} - -void PPB_FileRef_Proxy::OnMsgGetAbsolutePath(const HostResource& host_resource, - SerializedVarReturnValue result) { - EnterHostFromHostResource<PPB_FileRef_API> enter(host_resource); - if (enter.succeeded()) - result.Return(dispatcher(), enter.object()->GetAbsolutePath()); -} - -void PPB_FileRef_Proxy::OnMsgReadDirectoryEntries(const HostResource& file_ref, - uint32_t callback_id) { - linked_ptr<std::vector<ppapi::PPB_FileRef_CreateInfo> > files( - new std::vector<ppapi::PPB_FileRef_CreateInfo>()); - linked_ptr<std::vector<PP_FileType> > file_types( - new std::vector<PP_FileType>()); - HostCallbackParams params(file_ref, callback_id); - EnterHostFromHostResourceForceCallback<PPB_FileRef_API> enter( - file_ref, callback_factory_, - &PPB_FileRef_Proxy::OnReadDirectoryEntriesCallbackCompleteInHost, - params, files, file_types); - if (enter.succeeded()) { - enter.SetResult(enter.object()->ReadDirectoryEntriesInHost( - files, file_types, enter.callback())); - } -} - -#endif // !defined(OS_NACL) - -void PPB_FileRef_Proxy::OnMsgCallbackComplete( - const HostResource& host_resource, - uint32_t callback_id, - int32_t result) { - // Forward the callback info to the plugin resource. - EnterPluginFromHostResource<PPB_FileRef_API> enter(host_resource); - if (enter.succeeded()) - static_cast<FileRef*>(enter.object())->ExecuteCallback(callback_id, result); -} - -void PPB_FileRef_Proxy::OnMsgQueryCallbackComplete( - const HostResource& host_resource, - const PP_FileInfo& info, - uint32_t callback_id, - int32_t result) { - EnterPluginFromHostResource<PPB_FileRef_API> enter(host_resource); - if (!enter.succeeded()) - return; - - if (result == PP_OK) { - result = static_cast<FileRef*>(enter.object())->SetFileInfo( - callback_id, info); - } - static_cast<FileRef*>(enter.object())->ExecuteCallback(callback_id, result); -} - -void PPB_FileRef_Proxy::OnMsgReadDirectoryEntriesCallbackComplete( - const HostResource& host_resource, - const std::vector<ppapi::PPB_FileRef_CreateInfo>& infos, - const std::vector<PP_FileType>& file_types, - uint32_t callback_id, - int32_t result) { - CHECK_EQ(infos.size(), file_types.size()); - - EnterPluginFromHostResource<PPB_FileRef_API> enter(host_resource); - if (!enter.succeeded()) - return; - - if (result == PP_OK) { - result = - static_cast<FileRef*>(enter.object())->SetReadDirectoryEntriesOutput( - callback_id, infos, file_types); - } - static_cast<FileRef*>(enter.object())->ExecuteCallback( - callback_id, result); -} - -#if !defined(OS_NACL) -void PPB_FileRef_Proxy::OnCallbackCompleteInHost( - int32_t result, - const HostResource& host_resource, - uint32_t callback_id) { - // Execute OnMsgCallbackComplete in the plugin process. - Send(new PpapiMsg_PPBFileRef_CallbackComplete( - API_ID_PPB_FILE_REF, host_resource, callback_id, result)); -} - -void PPB_FileRef_Proxy::OnQueryCallbackCompleteInHost( - int32_t result, - const HostResource& host_resource, - linked_ptr<PP_FileInfo> info, - uint32_t callback_id) { - Send(new PpapiMsg_PPBFileRef_QueryCallbackComplete( - API_ID_PPB_FILE_REF, host_resource, *info, callback_id, result)); -} - -void PPB_FileRef_Proxy::OnReadDirectoryEntriesCallbackCompleteInHost( - int32_t result, - HostCallbackParams params, - linked_ptr<std::vector<ppapi::PPB_FileRef_CreateInfo> > files, - linked_ptr<std::vector<PP_FileType> > file_types) { - Send(new PpapiMsg_PPBFileRef_ReadDirectoryEntriesCallbackComplete( - API_ID_PPB_FILE_REF, params.host_resource, - *files, *file_types, params.callback_id, result)); -} - -#endif // !defined(OS_NACL) - -} // namespace proxy -} // namespace ppapi diff --git a/chromium/ppapi/proxy/ppb_file_ref_proxy.h b/chromium/ppapi/proxy/ppb_file_ref_proxy.h deleted file mode 100644 index cbfadb5b5f4..00000000000 --- a/chromium/ppapi/proxy/ppb_file_ref_proxy.h +++ /dev/null @@ -1,138 +0,0 @@ -// 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_PROXY_PPB_FILE_REF_PROXY_H_ -#define PPAPI_PROXY_PPB_FILE_REF_PROXY_H_ - -#include <string> - -#include "base/basictypes.h" -#include "base/memory/linked_ptr.h" -#include "ppapi/c/pp_file_info.h" -#include "ppapi/c/pp_module.h" -#include "ppapi/c/pp_resource.h" -#include "ppapi/c/pp_time.h" -#include "ppapi/proxy/interface_proxy.h" -#include "ppapi/proxy/ppapi_proxy_export.h" -#include "ppapi/proxy/proxy_completion_callback_factory.h" -#include "ppapi/shared_impl/host_resource.h" -#include "ppapi/utility/completion_callback_factory.h" - -namespace ppapi { - -struct PPB_FileRef_CreateInfo; - -namespace proxy { - -class SerializedVarReturnValue; - -class PPAPI_PROXY_EXPORT PPB_FileRef_Proxy - : public NON_EXPORTED_BASE(InterfaceProxy) { - public: - explicit PPB_FileRef_Proxy(Dispatcher* dispatcher); - virtual ~PPB_FileRef_Proxy(); - - static PP_Resource CreateProxyResource(PP_Instance instance, - PP_Resource file_system, - const char* path); - static PP_Resource CreateProxyResource( - const PPB_FileRef_CreateInfo& serialized); - - // InterfaceProxy implementation. - virtual bool OnMessageReceived(const IPC::Message& msg); - - // Takes a resource in the host and converts it into a serialized file ref - // "create info" for reconstitution in the plugin. This struct contains all - // the necessary information about the file ref. - // - // Various PPAPI functions return file refs from various interfaces, so this - // function is public so anybody can send a file ref. - static void SerializeFileRef(PP_Resource file_ref, - PPB_FileRef_CreateInfo* result); - - // Creates a plugin resource from the given CreateInfo sent from the host. - // The value will be the result of calling SerializeFileRef on the host. - // This represents passing the resource ownership to the plugin. This - // function also checks the validity of the result and returns 0 on failure. - // - // Various PPAPI functions return file refs from various interfaces, so this - // function is public so anybody can receive a file ref. - static PP_Resource DeserializeFileRef( - const PPB_FileRef_CreateInfo& serialized); - - static const ApiID kApiID = API_ID_PPB_FILE_REF; - - private: - // Plugin -> host message handlers. - void OnMsgCreate(PP_Instance instance, - PP_Resource file_system, - const std::string& path, - PPB_FileRef_CreateInfo* result); - void OnMsgGetParent(const HostResource& host_resource, - PPB_FileRef_CreateInfo* result); - void OnMsgMakeDirectory(const HostResource& host_resource, - PP_Bool make_ancestors, - uint32_t callback_id); - void OnMsgTouch(const HostResource& host_resource, - PP_Time last_access, - PP_Time last_modified, - uint32_t callback_id); - void OnMsgDelete(const HostResource& host_resource, - uint32_t callback_id); - void OnMsgRename(const HostResource& file_ref, - const HostResource& new_file_ref, - uint32_t callback_id); - void OnMsgQuery(const HostResource& file_ref, - uint32_t callback_id); - void OnMsgGetAbsolutePath(const HostResource& host_resource, - SerializedVarReturnValue result); - void OnMsgReadDirectoryEntries(const HostResource& file_ref, - uint32_t callback_id); - - // Host -> Plugin message handlers. - void OnMsgCallbackComplete(const HostResource& host_resource, - uint32_t callback_id, - int32_t result); - void OnMsgQueryCallbackComplete(const HostResource& host_resource, - const PP_FileInfo& info, - uint32_t callback_id, - int32_t result); - void OnMsgReadDirectoryEntriesCallbackComplete( - const HostResource& host_resource, - const std::vector<ppapi::PPB_FileRef_CreateInfo>& infos, - const std::vector<PP_FileType>& file_types, - uint32_t callback_id, - int32_t result); - - struct HostCallbackParams { - HostCallbackParams(const HostResource& host_res, uint32_t cb_id) - : host_resource(host_res), callback_id(cb_id) { - } - HostResource host_resource; - uint32_t callback_id; - }; - - void OnCallbackCompleteInHost(int32_t result, - const HostResource& host_resource, - uint32_t callback_id); - void OnQueryCallbackCompleteInHost( - int32_t result, - const HostResource& host_resource, - linked_ptr<PP_FileInfo> info, - uint32_t callback_id); - void OnReadDirectoryEntriesCallbackCompleteInHost( - int32_t result, - HostCallbackParams params, - linked_ptr<std::vector<ppapi::PPB_FileRef_CreateInfo> > files, - linked_ptr<std::vector<PP_FileType> > file_types); - - ProxyCompletionCallbackFactory<PPB_FileRef_Proxy> callback_factory_; - - DISALLOW_COPY_AND_ASSIGN(PPB_FileRef_Proxy); -}; - -} // namespace proxy -} // namespace ppapi - -#endif // PPAPI_PROXY_PPB_FILE_REF_PROXY_H_ diff --git a/chromium/ppapi/proxy/ppb_graphics_3d_proxy.cc b/chromium/ppapi/proxy/ppb_graphics_3d_proxy.cc index 7d18850ea3c..5fb1d1098c8 100644 --- a/chromium/ppapi/proxy/ppb_graphics_3d_proxy.cc +++ b/chromium/ppapi/proxy/ppb_graphics_3d_proxy.cc @@ -62,7 +62,9 @@ gpu::CommandBuffer::State GetErrorState() { // Graphics3D context; this isn't allowed, and will likely either crash or // result in undefined behavior. It is assumed that the thread which creates // the Graphics3D context will be the thread on which subsequent gl rendering -// will be done. +// will be done. This is why it is okay to read need_to_lock_ without the lock; +// it should only ever be read and written on the same thread where the context +// was created. // // TODO(nfullagar): At some point, allow multiple threads to concurrently render // each to its own context. First step is to allow a single thread (either main @@ -258,6 +260,10 @@ int32 Graphics3D::DoSwapBuffers() { void Graphics3D::PushAlreadyLocked() { ppapi::ProxyLock::AssertAcquired(); + if (!locking_command_buffer_) { + NOTREACHED(); + return; + } if (num_already_locked_calls_ == 0) locking_command_buffer_->set_need_to_lock(false); ++num_already_locked_calls_; @@ -268,6 +274,10 @@ void Graphics3D::PopAlreadyLocked() { DCHECK(!locking_command_buffer_->need_to_lock()); DCHECK_GT(num_already_locked_calls_, 0); ppapi::ProxyLock::AssertAcquired(); + if (!locking_command_buffer_) { + NOTREACHED(); + return; + } --num_already_locked_calls_; if (num_already_locked_calls_ == 0) locking_command_buffer_->set_need_to_lock(true); diff --git a/chromium/ppapi/proxy/ppb_instance_proxy.cc b/chromium/ppapi/proxy/ppb_instance_proxy.cc index 20b93649ece..fdaa8c47d25 100644 --- a/chromium/ppapi/proxy/ppb_instance_proxy.cc +++ b/chromium/ppapi/proxy/ppb_instance_proxy.cc @@ -173,8 +173,8 @@ bool PPB_Instance_Proxy::OnMessageReceived(const IPC::Message& msg) { OnHostMsgDocumentCanAccessDocument) IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBInstance_GetPluginInstanceURL, OnHostMsgGetPluginInstanceURL) - IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBInstance_NeedKey, - OnHostMsgNeedKey) + IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBInstance_GetPluginReferrerURL, + OnHostMsgGetPluginReferrerURL) IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBInstance_KeyAdded, OnHostMsgKeyAdded) IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBInstance_KeyMessage, @@ -526,17 +526,15 @@ PP_Var PPB_Instance_Proxy::GetPluginInstanceURL( components); } -void PPB_Instance_Proxy::NeedKey(PP_Instance instance, - PP_Var key_system, - PP_Var session_id, - PP_Var init_data) { - dispatcher()->Send( - new PpapiHostMsg_PPBInstance_NeedKey( - API_ID_PPB_INSTANCE, - instance, - SerializedVarSendInput(dispatcher(), key_system), - SerializedVarSendInput(dispatcher(), session_id), - SerializedVarSendInput(dispatcher(), init_data))); +PP_Var PPB_Instance_Proxy::GetPluginReferrerURL( + PP_Instance instance, + PP_URLComponents_Dev* components) { + ReceiveSerializedVarReturnValue result; + dispatcher()->Send(new PpapiHostMsg_PPBInstance_GetPluginReferrerURL( + API_ID_PPB_INSTANCE, instance, &result)); + return PPB_URLUtil_Shared::ConvertComponentsAndReturnURL( + result.Return(dispatcher()), + components); } void PPB_Instance_Proxy::KeyAdded(PP_Instance instance, @@ -1032,18 +1030,15 @@ void PPB_Instance_Proxy::OnHostMsgGetPluginInstanceURL( } } -void PPB_Instance_Proxy::OnHostMsgNeedKey(PP_Instance instance, - SerializedVarReceiveInput key_system, - SerializedVarReceiveInput session_id, - SerializedVarReceiveInput init_data) { - if (!dispatcher()->permissions().HasPermission(PERMISSION_PRIVATE)) +void PPB_Instance_Proxy::OnHostMsgGetPluginReferrerURL( + PP_Instance instance, + SerializedVarReturnValue result) { + if (!dispatcher()->permissions().HasPermission(PERMISSION_DEV)) return; EnterInstanceNoLock enter(instance); if (enter.succeeded()) { - enter.functions()->NeedKey(instance, - key_system.Get(dispatcher()), - session_id.Get(dispatcher()), - init_data.Get(dispatcher())); + result.Return(dispatcher(), + enter.functions()->GetPluginReferrerURL(instance, NULL)); } } diff --git a/chromium/ppapi/proxy/ppb_instance_proxy.h b/chromium/ppapi/proxy/ppb_instance_proxy.h index 6df4f8d9eab..a6516bc1754 100644 --- a/chromium/ppapi/proxy/ppb_instance_proxy.h +++ b/chromium/ppapi/proxy/ppb_instance_proxy.h @@ -114,10 +114,9 @@ class PPB_Instance_Proxy : public InterfaceProxy, virtual PP_Var GetPluginInstanceURL( PP_Instance instance, PP_URLComponents_Dev* components) OVERRIDE; - virtual void NeedKey(PP_Instance instance, - PP_Var key_system, - PP_Var session_id, - PP_Var init_data) OVERRIDE; + virtual PP_Var GetPluginReferrerURL( + PP_Instance instance, + PP_URLComponents_Dev* components) OVERRIDE; virtual void KeyAdded(PP_Instance instance, PP_Var key_system, PP_Var session_id) OVERRIDE; @@ -218,10 +217,8 @@ class PPB_Instance_Proxy : public InterfaceProxy, PP_Bool* result); void OnHostMsgGetPluginInstanceURL(PP_Instance instance, SerializedVarReturnValue result); - virtual void OnHostMsgNeedKey(PP_Instance instance, - SerializedVarReceiveInput key_system, - SerializedVarReceiveInput session_id, - SerializedVarReceiveInput init_data); + void OnHostMsgGetPluginReferrerURL(PP_Instance instance, + SerializedVarReturnValue result); virtual void OnHostMsgKeyAdded(PP_Instance instance, SerializedVarReceiveInput key_system, SerializedVarReceiveInput session_id); diff --git a/chromium/ppapi/proxy/ppb_network_monitor_private_proxy.cc b/chromium/ppapi/proxy/ppb_network_monitor_private_proxy.cc deleted file mode 100644 index 055ed2e3a7b..00000000000 --- a/chromium/ppapi/proxy/ppb_network_monitor_private_proxy.cc +++ /dev/null @@ -1,156 +0,0 @@ -// Copyright (c) 2012 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#include "ppapi/proxy/ppb_network_monitor_private_proxy.h" - -#include "ppapi/proxy/enter_proxy.h" -#include "ppapi/proxy/ppapi_messages.h" -#include "ppapi/shared_impl/proxy_lock.h" -#include "ppapi/thunk/ppb_network_monitor_private_api.h" - -namespace ppapi { -namespace proxy { - -class PPB_NetworkMonitor_Private_Proxy::NetworkMonitor - : public Resource, - public thunk::PPB_NetworkMonitor_Private_API, - public base::SupportsWeakPtr< - PPB_NetworkMonitor_Private_Proxy::NetworkMonitor> { - public: - NetworkMonitor(PP_Instance instance, - PPB_NetworkMonitor_Private_Proxy* proxy, - PPB_NetworkMonitor_Callback callback, - void* user_data) - : Resource(OBJECT_IS_PROXY, instance), - proxy_(proxy), - callback_(callback), - user_data_(user_data) { - } - - virtual ~NetworkMonitor() { - proxy_->OnNetworkMonitorDeleted(this, pp_instance()); - } - - - // Resource overrides. - virtual ppapi::thunk::PPB_NetworkMonitor_Private_API* - AsPPB_NetworkMonitor_Private_API() OVERRIDE { - return this; - } - - // This is invoked when a network list is received for this monitor (either - // initially or on a change). It acquires the ProxyLock inside because - // ObserverListThreadSafe does not support Bind/Closure, otherwise we would - // wrap the call with a lock using RunWhileLocked. - void OnNetworkListReceivedLocks( - const scoped_refptr<NetworkListStorage>& list) { - ProxyAutoLock lock; - PP_Resource list_resource = - PPB_NetworkList_Private_Shared::Create( - OBJECT_IS_PROXY, pp_instance(), list); - CallWhileUnlocked(callback_, user_data_, list_resource); - } - - private: - PPB_NetworkMonitor_Private_Proxy* proxy_; - PPB_NetworkMonitor_Callback callback_; - void* user_data_; - - DISALLOW_COPY_AND_ASSIGN(NetworkMonitor); -}; - -PPB_NetworkMonitor_Private_Proxy::PPB_NetworkMonitor_Private_Proxy( - Dispatcher* dispatcher) - : InterfaceProxy(dispatcher), - monitors_(new ObserverListThreadSafe<NetworkMonitor>()), - monitors_count_(0) { -} - -PPB_NetworkMonitor_Private_Proxy::~PPB_NetworkMonitor_Private_Proxy() { - monitors_->AssertEmpty(); -} - -// static -PP_Resource PPB_NetworkMonitor_Private_Proxy::CreateProxyResource( - PP_Instance instance, - PPB_NetworkMonitor_Callback callback, - void* user_data) { - // TODO(dmichael): Check that this thread has a valid message loop associated - // with it. - if (!callback) - return 0; - - PluginDispatcher* dispatcher = PluginDispatcher::GetForInstance(instance); - if (!dispatcher) - return 0; - PPB_NetworkMonitor_Private_Proxy* proxy = - static_cast<PPB_NetworkMonitor_Private_Proxy*>( - dispatcher->GetInterfaceProxy(kApiID)); - if (!proxy) - return 0; - - scoped_refptr<NetworkMonitor> result( - new NetworkMonitor(instance, proxy, callback, user_data)); - proxy->monitors_->AddObserver(result.get()); - - proxy->monitors_count_++; - if (proxy->monitors_count_ == 1) { - // If that is the first network monitor then send Start message. - PluginGlobals::Get()->GetBrowserSender()->Send( - new PpapiHostMsg_PPBNetworkMonitor_Start( - dispatcher->plugin_dispatcher_id())); - - // We could have received network list message after sending the - // previous Stop message. This list is stale now, so reset it - // here. - proxy->current_list_ = NULL; - } else if (proxy->current_list_.get()) { - base::MessageLoop::current()->PostTask( - FROM_HERE, - base::Bind(&NetworkMonitor::OnNetworkListReceivedLocks, - result->AsWeakPtr(), - proxy->current_list_)); - } - - return result->GetReference(); -} - -bool PPB_NetworkMonitor_Private_Proxy::OnMessageReceived( - const IPC::Message& msg) { - bool handled = true; - IPC_BEGIN_MESSAGE_MAP(PPB_NetworkMonitor_Private_Proxy, msg) - IPC_MESSAGE_HANDLER(PpapiMsg_PPBNetworkMonitor_NetworkList, - OnPluginMsgNetworkList) - IPC_MESSAGE_UNHANDLED(handled = false) - IPC_END_MESSAGE_MAP() - return handled; -} - -void PPB_NetworkMonitor_Private_Proxy::OnPluginMsgNetworkList( - uint32 plugin_dispatcher_id, - const ppapi::NetworkList& list) { - scoped_refptr<NetworkListStorage> list_storage(new NetworkListStorage(list)); - current_list_ = list_storage; - monitors_->Notify(&NetworkMonitor::OnNetworkListReceivedLocks, list_storage); -} - -void PPB_NetworkMonitor_Private_Proxy::OnNetworkMonitorDeleted( - NetworkMonitor* monitor, - PP_Instance instance) { - monitors_->RemoveObserver(monitor); - monitors_count_--; - if (monitors_count_ == 0) { - // Send Stop message if that was the last NetworkMonitor. - PluginDispatcher* dispatcher = PluginDispatcher::GetForInstance(instance); - if (dispatcher) { - PluginGlobals::Get()->GetBrowserSender()->Send( - new PpapiHostMsg_PPBNetworkMonitor_Stop( - dispatcher->plugin_dispatcher_id())); - } - current_list_ = NULL; - } -} - -} // namespace proxy -} // namespace ppapi diff --git a/chromium/ppapi/proxy/ppb_network_monitor_private_proxy.h b/chromium/ppapi/proxy/ppb_network_monitor_private_proxy.h deleted file mode 100644 index e764b0cb34f..00000000000 --- a/chromium/ppapi/proxy/ppb_network_monitor_private_proxy.h +++ /dev/null @@ -1,63 +0,0 @@ -// Copyright (c) 2012 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#ifndef PPAPI_PROXY_PPB_NETWORK_MONITOR_PRIVATE_PROXY_H_ -#define PPAPI_PROXY_PPB_NETWORK_MONITOR_PRIVATE_PROXY_H_ - -#include <list> - -#include "base/observer_list_threadsafe.h" -#include "ppapi/proxy/interface_proxy.h" -#include "ppapi/shared_impl/ppb_network_list_private_shared.h" -#include "ppapi/shared_impl/scoped_pp_resource.h" -#include "ppapi/thunk/ppb_network_monitor_private_api.h" - -namespace base { -class MessageLoopProxy; -} // namespace base - -namespace ppapi { -namespace proxy { - -class PPB_NetworkMonitor_Private_Proxy : public InterfaceProxy { - public: - explicit PPB_NetworkMonitor_Private_Proxy(Dispatcher* dispatcher); - virtual ~PPB_NetworkMonitor_Private_Proxy(); - - // Creates n NetworkManager object in the plugin process. - static PP_Resource CreateProxyResource(PP_Instance instance, - PPB_NetworkMonitor_Callback callback, - void* user_data); - - // InterfaceProxy implementation. - virtual bool OnMessageReceived(const IPC::Message& msg); - - static const ApiID kApiID = API_ID_PPB_NETWORKMANAGER_PRIVATE; - - private: - class NetworkMonitor; - friend class NetworkMonitor; - - // IPC message handler for the messages received from the browser. - void OnPluginMsgNetworkList(uint32 plugin_dispatcher_id, - const ppapi::NetworkList& list); - - // Called by NetworkMonitor destructor. - void OnNetworkMonitorDeleted(NetworkMonitor* monitor, - PP_Instance instance); - - // We use ObserverListThreadSafe because we want to send notifications to the - // same thread that created the NetworkMonitor. - scoped_refptr<ObserverListThreadSafe<NetworkMonitor> > monitors_; - - int monitors_count_; - scoped_refptr<NetworkListStorage> current_list_; - - DISALLOW_COPY_AND_ASSIGN(PPB_NetworkMonitor_Private_Proxy); -}; - -} // namespace proxy -} // namespace ppapi - -#endif // PPAPI_PROXY_PPB_NETWORK_MONITOR_PRIVATE_PROXY_H_ diff --git a/chromium/ppapi/proxy/ppb_tcp_socket_private_proxy.cc b/chromium/ppapi/proxy/ppb_tcp_socket_private_proxy.cc deleted file mode 100644 index 58199fd140e..00000000000 --- a/chromium/ppapi/proxy/ppb_tcp_socket_private_proxy.cc +++ /dev/null @@ -1,263 +0,0 @@ -// Copyright (c) 2012 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#include "ppapi/proxy/ppb_tcp_socket_private_proxy.h" - -#include <map> - -#include "base/logging.h" -#include "ppapi/proxy/plugin_dispatcher.h" -#include "ppapi/proxy/plugin_globals.h" -#include "ppapi/proxy/plugin_resource_tracker.h" -#include "ppapi/proxy/ppapi_messages.h" -#include "ppapi/shared_impl/private/ppb_x509_certificate_private_shared.h" -#include "ppapi/shared_impl/private/tcp_socket_private_impl.h" -#include "ppapi/shared_impl/resource.h" -#include "ppapi/shared_impl/socket_option_data.h" -#include "ppapi/thunk/thunk.h" - -namespace ppapi { -namespace proxy { - -namespace { - -typedef std::map<uint32, TCPSocketPrivateImpl*> IDToSocketMap; -IDToSocketMap* g_id_to_socket = NULL; - -class TCPSocket : public TCPSocketPrivateImpl { - public: - // C-tor for new sockets. - TCPSocket(const HostResource& resource, uint32 socket_id); - // C-tor for already connected sockets. - TCPSocket(const HostResource& resource, - uint32 socket_id, - const PP_NetAddress_Private& local_addr, - const PP_NetAddress_Private& remote_addr); - virtual ~TCPSocket(); - - virtual void SendConnect(const std::string& host, uint16_t port) OVERRIDE; - virtual void SendConnectWithNetAddress( - const PP_NetAddress_Private& addr) OVERRIDE; - virtual void SendSSLHandshake( - const std::string& server_name, - uint16_t server_port, - const std::vector<std::vector<char> >& trusted_certs, - const std::vector<std::vector<char> >& untrusted_certs) OVERRIDE; - virtual void SendRead(int32_t bytes_to_read) OVERRIDE; - virtual void SendWrite(const std::string& buffer) OVERRIDE; - virtual void SendDisconnect() OVERRIDE; - virtual void SendSetOption(PP_TCPSocket_Option name, - const SocketOptionData& value) OVERRIDE; - - private: - void SendToBrowser(IPC::Message* msg); - - DISALLOW_COPY_AND_ASSIGN(TCPSocket); -}; - -TCPSocket::TCPSocket(const HostResource& resource, uint32 socket_id) - : TCPSocketPrivateImpl(resource, socket_id) { - if (!g_id_to_socket) - g_id_to_socket = new IDToSocketMap(); - DCHECK(g_id_to_socket->find(socket_id) == g_id_to_socket->end()); - (*g_id_to_socket)[socket_id] = this; -} - -TCPSocket::TCPSocket(const HostResource& resource, - uint32 socket_id, - const PP_NetAddress_Private& local_addr, - const PP_NetAddress_Private& remote_addr) - : TCPSocketPrivateImpl(resource, socket_id) { - if (!g_id_to_socket) - g_id_to_socket = new IDToSocketMap(); - DCHECK(g_id_to_socket->find(socket_id) == g_id_to_socket->end()); - - connection_state_ = CONNECTED; - local_addr_ = local_addr; - remote_addr_ = remote_addr; - - (*g_id_to_socket)[socket_id] = this; -} - -TCPSocket::~TCPSocket() { - Disconnect(); -} - -void TCPSocket::SendConnect(const std::string& host, uint16_t port) { - SendToBrowser(new PpapiHostMsg_PPBTCPSocket_Connect( - API_ID_PPB_TCPSOCKET_PRIVATE, socket_id_, host, port)); -} - -void TCPSocket::SendConnectWithNetAddress(const PP_NetAddress_Private& addr) { - SendToBrowser(new PpapiHostMsg_PPBTCPSocket_ConnectWithNetAddress( - API_ID_PPB_TCPSOCKET_PRIVATE, socket_id_, addr)); -} - -void TCPSocket::SendSSLHandshake( - const std::string& server_name, - uint16_t server_port, - const std::vector<std::vector<char> >& trusted_certs, - const std::vector<std::vector<char> >& untrusted_certs) { - SendToBrowser(new PpapiHostMsg_PPBTCPSocket_SSLHandshake( - socket_id_, server_name, server_port, trusted_certs, untrusted_certs)); -} - -void TCPSocket::SendRead(int32_t bytes_to_read) { - SendToBrowser(new PpapiHostMsg_PPBTCPSocket_Read(socket_id_, bytes_to_read)); -} - -void TCPSocket::SendWrite(const std::string& buffer) { - SendToBrowser(new PpapiHostMsg_PPBTCPSocket_Write(socket_id_, buffer)); -} - -void TCPSocket::SendDisconnect() { - // After removed from the mapping, this object won't receive any notifications - // from the proxy. - DCHECK(g_id_to_socket->find(socket_id_) != g_id_to_socket->end()); - g_id_to_socket->erase(socket_id_); - SendToBrowser(new PpapiHostMsg_PPBTCPSocket_Disconnect(socket_id_)); -} - -void TCPSocket::SendSetOption(PP_TCPSocket_Option name, - const SocketOptionData& value) { - SendToBrowser( - new PpapiHostMsg_PPBTCPSocket_SetOption(socket_id_, name, value)); -} - -void TCPSocket::SendToBrowser(IPC::Message* msg) { - PluginGlobals::Get()->GetBrowserSender()->Send(msg); -} - -} // namespace - -//------------------------------------------------------------------------------ - -PPB_TCPSocket_Private_Proxy::PPB_TCPSocket_Private_Proxy(Dispatcher* dispatcher) - : InterfaceProxy(dispatcher) { -} - -PPB_TCPSocket_Private_Proxy::~PPB_TCPSocket_Private_Proxy() { -} - -// static -PP_Resource PPB_TCPSocket_Private_Proxy::CreateProxyResource( - PP_Instance instance) { - PluginDispatcher* dispatcher = PluginDispatcher::GetForInstance(instance); - if (!dispatcher) - return 0; - - uint32 socket_id = 0; - PluginGlobals::Get()->GetBrowserSender()->Send( - new PpapiHostMsg_PPBTCPSocket_CreatePrivate( - API_ID_PPB_TCPSOCKET_PRIVATE, dispatcher->plugin_dispatcher_id(), - &socket_id)); - if (socket_id == 0) - return 0; - return (new TCPSocket(HostResource::MakeInstanceOnly(instance), - socket_id))->GetReference(); -} - -// static -PP_Resource PPB_TCPSocket_Private_Proxy::CreateProxyResourceForConnectedSocket( - PP_Instance instance, - uint32 socket_id, - const PP_NetAddress_Private& local_addr, - const PP_NetAddress_Private& remote_addr) { - return (new TCPSocket(HostResource::MakeInstanceOnly(instance), - socket_id, - local_addr, - remote_addr))->GetReference(); -} - -bool PPB_TCPSocket_Private_Proxy::OnMessageReceived(const IPC::Message& msg) { - bool handled = true; - IPC_BEGIN_MESSAGE_MAP(PPB_TCPSocket_Private_Proxy, msg) - IPC_MESSAGE_HANDLER(PpapiMsg_PPBTCPSocket_ConnectACK, - OnMsgConnectACK) - IPC_MESSAGE_HANDLER(PpapiMsg_PPBTCPSocket_SSLHandshakeACK, - OnMsgSSLHandshakeACK) - IPC_MESSAGE_HANDLER(PpapiMsg_PPBTCPSocket_ReadACK, OnMsgReadACK) - IPC_MESSAGE_HANDLER(PpapiMsg_PPBTCPSocket_WriteACK, OnMsgWriteACK) - IPC_MESSAGE_HANDLER(PpapiMsg_PPBTCPSocket_SetOptionACK, OnMsgSetOptionACK) - IPC_MESSAGE_UNHANDLED(handled = false) - IPC_END_MESSAGE_MAP() - return handled; -} - -void PPB_TCPSocket_Private_Proxy::OnMsgConnectACK( - uint32 /* plugin_dispatcher_id */, - uint32 socket_id, - int32_t result, - const PP_NetAddress_Private& local_addr, - const PP_NetAddress_Private& remote_addr) { - if (!g_id_to_socket) { - NOTREACHED(); - return; - } - IDToSocketMap::iterator iter = g_id_to_socket->find(socket_id); - if (iter == g_id_to_socket->end()) - return; - iter->second->OnConnectCompleted(result, local_addr, remote_addr); -} - -void PPB_TCPSocket_Private_Proxy::OnMsgSSLHandshakeACK( - uint32 /* plugin_dispatcher_id */, - uint32 socket_id, - bool succeeded, - const PPB_X509Certificate_Fields& certificate_fields) { - if (!g_id_to_socket) { - NOTREACHED(); - return; - } - IDToSocketMap::iterator iter = g_id_to_socket->find(socket_id); - if (iter == g_id_to_socket->end()) - return; - iter->second->OnSSLHandshakeCompleted(succeeded, certificate_fields); -} - -void PPB_TCPSocket_Private_Proxy::OnMsgReadACK( - uint32 /* plugin_dispatcher_id */, - uint32 socket_id, - int32_t result, - const std::string& data) { - if (!g_id_to_socket) { - NOTREACHED(); - return; - } - IDToSocketMap::iterator iter = g_id_to_socket->find(socket_id); - if (iter == g_id_to_socket->end()) - return; - iter->second->OnReadCompleted(result, data); -} - -void PPB_TCPSocket_Private_Proxy::OnMsgWriteACK( - uint32 /* plugin_dispatcher_id */, - uint32 socket_id, - int32_t result) { - if (!g_id_to_socket) { - NOTREACHED(); - return; - } - IDToSocketMap::iterator iter = g_id_to_socket->find(socket_id); - if (iter == g_id_to_socket->end()) - return; - iter->second->OnWriteCompleted(result); -} - -void PPB_TCPSocket_Private_Proxy::OnMsgSetOptionACK( - uint32 /* plugin_dispatcher_id */, - uint32 socket_id, - int32_t result) { - if (!g_id_to_socket) { - NOTREACHED(); - return; - } - IDToSocketMap::iterator iter = g_id_to_socket->find(socket_id); - if (iter == g_id_to_socket->end()) - return; - iter->second->OnSetOptionCompleted(result); -} - -} // namespace proxy -} // namespace ppapi diff --git a/chromium/ppapi/proxy/ppb_tcp_socket_private_proxy.h b/chromium/ppapi/proxy/ppb_tcp_socket_private_proxy.h deleted file mode 100644 index 0813531a00e..00000000000 --- a/chromium/ppapi/proxy/ppb_tcp_socket_private_proxy.h +++ /dev/null @@ -1,69 +0,0 @@ -// Copyright (c) 2012 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#ifndef PPAPI_PROXY_PPB_TCP_SOCKET_PRIVATE_PROXY_H_ -#define PPAPI_PROXY_PPB_TCP_SOCKET_PRIVATE_PROXY_H_ - -#include <string> - -#include "base/basictypes.h" -#include "ppapi/c/pp_instance.h" -#include "ppapi/c/pp_resource.h" -#include "ppapi/c/private/ppb_tcp_socket_private.h" -#include "ppapi/proxy/interface_proxy.h" -#include "ppapi/proxy/ppapi_proxy_export.h" - -namespace ppapi { - -class PPB_X509Certificate_Fields; - -namespace proxy { - -class PPB_TCPSocket_Private_Proxy : public InterfaceProxy { - public: - explicit PPB_TCPSocket_Private_Proxy(Dispatcher* dispatcher); - virtual ~PPB_TCPSocket_Private_Proxy(); - - static PP_Resource CreateProxyResource(PP_Instance instance); - static PP_Resource CreateProxyResourceForConnectedSocket( - PP_Instance instance, - uint32 socket_id, - const PP_NetAddress_Private& local_addr, - const PP_NetAddress_Private& remote_addr); - - // InterfaceProxy implementation. - virtual bool OnMessageReceived(const IPC::Message& msg); - - static const ApiID kApiID = API_ID_PPB_TCPSOCKET_PRIVATE; - - private: - // Browser->plugin message handlers. - void OnMsgConnectACK(uint32 plugin_dispatcher_id, - uint32 socket_id, - int32_t result, - const PP_NetAddress_Private& local_addr, - const PP_NetAddress_Private& remote_addr); - void OnMsgSSLHandshakeACK( - uint32 plugin_dispatcher_id, - uint32 socket_id, - bool succeeded, - const PPB_X509Certificate_Fields& certificate_fields); - void OnMsgReadACK(uint32 plugin_dispatcher_id, - uint32 socket_id, - int32_t result, - const std::string& data); - void OnMsgWriteACK(uint32 plugin_dispatcher_id, - uint32 socket_id, - int32_t result); - void OnMsgSetOptionACK(uint32 plugin_dispatcher_id, - uint32 socket_id, - int32_t result); - - DISALLOW_COPY_AND_ASSIGN(PPB_TCPSocket_Private_Proxy); -}; - -} // namespace proxy -} // namespace ppapi - -#endif // PPAPI_PROXY_PPB_TCP_SOCKET_PRIVATE_PROXY_H_ diff --git a/chromium/ppapi/proxy/ppb_tcp_socket_proxy.cc b/chromium/ppapi/proxy/ppb_tcp_socket_proxy.cc deleted file mode 100644 index 2ec16603300..00000000000 --- a/chromium/ppapi/proxy/ppb_tcp_socket_proxy.cc +++ /dev/null @@ -1,299 +0,0 @@ -// Copyright 2013 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/proxy/ppb_tcp_socket_proxy.h" - -#include <map> - -#include "base/logging.h" -#include "ppapi/proxy/plugin_dispatcher.h" -#include "ppapi/proxy/plugin_globals.h" -#include "ppapi/proxy/ppapi_messages.h" -#include "ppapi/shared_impl/resource.h" -#include "ppapi/shared_impl/socket_option_data.h" -#include "ppapi/shared_impl/tcp_socket_shared.h" -#include "ppapi/thunk/enter.h" -#include "ppapi/thunk/ppb_net_address_api.h" -#include "ppapi/thunk/ppb_tcp_socket_api.h" -#include "ppapi/thunk/thunk.h" - -namespace ppapi { -namespace proxy { - -namespace { - -typedef thunk::EnterResourceNoLock<thunk::PPB_NetAddress_API> - EnterNetAddressNoLock; - -typedef std::map<uint32, TCPSocketShared*> IDToSocketMap; -IDToSocketMap* g_id_to_socket = NULL; - -class TCPSocket : public thunk::PPB_TCPSocket_API, - public Resource, - public TCPSocketShared { - public: - TCPSocket(const HostResource& resource, uint32 socket_id); - virtual ~TCPSocket(); - - // Resource overrides. - virtual thunk::PPB_TCPSocket_API* AsPPB_TCPSocket_API() OVERRIDE; - - // thunk::PPB_TCPSocket_API implementation. - virtual int32_t Connect(PP_Resource addr, - scoped_refptr<TrackedCallback> callback) OVERRIDE; - virtual PP_Resource GetLocalAddress() OVERRIDE; - virtual PP_Resource GetRemoteAddress() OVERRIDE; - virtual int32_t Read(char* buffer, - int32_t bytes_to_read, - scoped_refptr<TrackedCallback> callback) OVERRIDE; - virtual int32_t Write(const char* buffer, - int32_t bytes_to_write, - scoped_refptr<TrackedCallback> callback) OVERRIDE; - virtual void Close() OVERRIDE; - virtual int32_t SetOption(PP_TCPSocket_Option name, - const PP_Var& value, - scoped_refptr<TrackedCallback> callback) OVERRIDE; - - // TCPSocketShared implementation. - virtual void SendConnect(const std::string& host, uint16_t port) OVERRIDE; - virtual void SendConnectWithNetAddress( - const PP_NetAddress_Private& addr) OVERRIDE; - virtual void SendSSLHandshake( - const std::string& server_name, - uint16_t server_port, - const std::vector<std::vector<char> >& trusted_certs, - const std::vector<std::vector<char> >& untrusted_certs) OVERRIDE; - virtual void SendRead(int32_t bytes_to_read) OVERRIDE; - virtual void SendWrite(const std::string& buffer) OVERRIDE; - virtual void SendDisconnect() OVERRIDE; - virtual void SendSetOption(PP_TCPSocket_Option name, - const SocketOptionData& value) OVERRIDE; - virtual Resource* GetOwnerResource() OVERRIDE; - - private: - void SendToBrowser(IPC::Message* msg); - - DISALLOW_COPY_AND_ASSIGN(TCPSocket); -}; - -TCPSocket::TCPSocket(const HostResource& resource, uint32 socket_id) - : Resource(OBJECT_IS_PROXY, resource), - TCPSocketShared(OBJECT_IS_PROXY, socket_id) { - if (!g_id_to_socket) - g_id_to_socket = new IDToSocketMap(); - DCHECK(g_id_to_socket->find(socket_id) == g_id_to_socket->end()); - (*g_id_to_socket)[socket_id] = this; -} - -TCPSocket::~TCPSocket() { - DisconnectImpl(); -} - -thunk::PPB_TCPSocket_API* TCPSocket::AsPPB_TCPSocket_API() { - return this; -} - -int32_t TCPSocket::Connect(PP_Resource addr, - scoped_refptr<TrackedCallback> callback) { - EnterNetAddressNoLock enter(addr, true); - if (enter.failed()) - return PP_ERROR_BADARGUMENT; - - return ConnectWithNetAddressImpl(&enter.object()->GetNetAddressPrivate(), - callback); -} - -PP_Resource TCPSocket::GetLocalAddress() { - PP_NetAddress_Private addr_private; - if (!GetLocalAddressImpl(&addr_private)) - return 0; - - thunk::EnterResourceCreationNoLock enter(pp_instance()); - if (enter.failed()) - return 0; - return enter.functions()->CreateNetAddressFromNetAddressPrivate( - pp_instance(), addr_private); -} - -PP_Resource TCPSocket::GetRemoteAddress() { - PP_NetAddress_Private addr_private; - if (!GetRemoteAddressImpl(&addr_private)) - return 0; - - thunk::EnterResourceCreationNoLock enter(pp_instance()); - if (enter.failed()) - return 0; - return enter.functions()->CreateNetAddressFromNetAddressPrivate( - pp_instance(), addr_private); -} - -int32_t TCPSocket::Read(char* buffer, - int32_t bytes_to_read, - scoped_refptr<TrackedCallback> callback) { - return ReadImpl(buffer, bytes_to_read, callback); -} - -int32_t TCPSocket::Write(const char* buffer, - int32_t bytes_to_write, - scoped_refptr<TrackedCallback> callback) { - return WriteImpl(buffer, bytes_to_write, callback); -} - -void TCPSocket::Close() { - DisconnectImpl(); -} - -int32_t TCPSocket::SetOption(PP_TCPSocket_Option name, - const PP_Var& value, - scoped_refptr<TrackedCallback> callback) { - return SetOptionImpl(name, value, callback); -} - -void TCPSocket::SendConnect(const std::string& host, uint16_t port) { - NOTREACHED(); -} - -void TCPSocket::SendConnectWithNetAddress(const PP_NetAddress_Private& addr) { - SendToBrowser(new PpapiHostMsg_PPBTCPSocket_ConnectWithNetAddress( - API_ID_PPB_TCPSOCKET, socket_id_, addr)); -} - -void TCPSocket::SendSSLHandshake( - const std::string& server_name, - uint16_t server_port, - const std::vector<std::vector<char> >& trusted_certs, - const std::vector<std::vector<char> >& untrusted_certs) { - NOTREACHED(); -} - -void TCPSocket::SendRead(int32_t bytes_to_read) { - SendToBrowser(new PpapiHostMsg_PPBTCPSocket_Read(socket_id_, bytes_to_read)); -} - -void TCPSocket::SendWrite(const std::string& buffer) { - SendToBrowser(new PpapiHostMsg_PPBTCPSocket_Write(socket_id_, buffer)); -} - -void TCPSocket::SendDisconnect() { - // After removed from the mapping, this object won't receive any notifications - // from the proxy. - DCHECK(g_id_to_socket->find(socket_id_) != g_id_to_socket->end()); - g_id_to_socket->erase(socket_id_); - SendToBrowser(new PpapiHostMsg_PPBTCPSocket_Disconnect(socket_id_)); -} - -void TCPSocket::SendSetOption(PP_TCPSocket_Option name, - const SocketOptionData& value) { - SendToBrowser( - new PpapiHostMsg_PPBTCPSocket_SetOption(socket_id_, name, value)); -} - -Resource* TCPSocket::GetOwnerResource() { - return this; -} - -void TCPSocket::SendToBrowser(IPC::Message* msg) { - PluginGlobals::Get()->GetBrowserSender()->Send(msg); -} - -} // namespace - -//------------------------------------------------------------------------------ - -PPB_TCPSocket_Proxy::PPB_TCPSocket_Proxy(Dispatcher* dispatcher) - : InterfaceProxy(dispatcher) { -} - -PPB_TCPSocket_Proxy::~PPB_TCPSocket_Proxy() { -} - -// static -PP_Resource PPB_TCPSocket_Proxy::CreateProxyResource(PP_Instance instance) { - PluginDispatcher* dispatcher = PluginDispatcher::GetForInstance(instance); - if (!dispatcher) - return 0; - - uint32 socket_id = 0; - PluginGlobals::Get()->GetBrowserSender()->Send( - new PpapiHostMsg_PPBTCPSocket_Create( - API_ID_PPB_TCPSOCKET, dispatcher->plugin_dispatcher_id(), - &socket_id)); - if (socket_id == 0) - return 0; - return (new TCPSocket(HostResource::MakeInstanceOnly(instance), - socket_id))->GetReference(); -} - -bool PPB_TCPSocket_Proxy::OnMessageReceived(const IPC::Message& msg) { - bool handled = true; - IPC_BEGIN_MESSAGE_MAP(PPB_TCPSocket_Proxy, msg) - IPC_MESSAGE_HANDLER(PpapiMsg_PPBTCPSocket_ConnectACK, - OnMsgConnectACK) - IPC_MESSAGE_HANDLER(PpapiMsg_PPBTCPSocket_ReadACK, OnMsgReadACK) - IPC_MESSAGE_HANDLER(PpapiMsg_PPBTCPSocket_WriteACK, OnMsgWriteACK) - IPC_MESSAGE_HANDLER(PpapiMsg_PPBTCPSocket_SetOptionACK, - OnMsgSetOptionACK) - IPC_MESSAGE_UNHANDLED(handled = false) - IPC_END_MESSAGE_MAP() - return handled; -} - -void PPB_TCPSocket_Proxy::OnMsgConnectACK( - uint32 /* plugin_dispatcher_id */, - uint32 socket_id, - int32_t result, - const PP_NetAddress_Private& local_addr, - const PP_NetAddress_Private& remote_addr) { - if (!g_id_to_socket) { - NOTREACHED(); - return; - } - IDToSocketMap::iterator iter = g_id_to_socket->find(socket_id); - if (iter == g_id_to_socket->end()) - return; - iter->second->OnConnectCompleted(result, local_addr, remote_addr); -} - -void PPB_TCPSocket_Proxy::OnMsgReadACK(uint32 /* plugin_dispatcher_id */, - uint32 socket_id, - int32_t result, - const std::string& data) { - if (!g_id_to_socket) { - NOTREACHED(); - return; - } - IDToSocketMap::iterator iter = g_id_to_socket->find(socket_id); - if (iter == g_id_to_socket->end()) - return; - iter->second->OnReadCompleted(result, data); -} - -void PPB_TCPSocket_Proxy::OnMsgWriteACK(uint32 /* plugin_dispatcher_id */, - uint32 socket_id, - int32_t result) { - if (!g_id_to_socket) { - NOTREACHED(); - return; - } - IDToSocketMap::iterator iter = g_id_to_socket->find(socket_id); - if (iter == g_id_to_socket->end()) - return; - iter->second->OnWriteCompleted(result); -} - -void PPB_TCPSocket_Proxy::OnMsgSetOptionACK(uint32 /* plugin_dispatcher_id */, - uint32 socket_id, - int32_t result) { - if (!g_id_to_socket) { - NOTREACHED(); - return; - } - IDToSocketMap::iterator iter = g_id_to_socket->find(socket_id); - if (iter == g_id_to_socket->end()) - return; - iter->second->OnSetOptionCompleted(result); -} - -} // namespace proxy -} // namespace ppapi diff --git a/chromium/ppapi/proxy/ppb_tcp_socket_proxy.h b/chromium/ppapi/proxy/ppb_tcp_socket_proxy.h deleted file mode 100644 index c5a3de8c721..00000000000 --- a/chromium/ppapi/proxy/ppb_tcp_socket_proxy.h +++ /dev/null @@ -1,57 +0,0 @@ -// Copyright 2013 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_PROXY_PPB_TCP_SOCKET_PROXY_H_ -#define PPAPI_PROXY_PPB_TCP_SOCKET_PROXY_H_ - -#include <string> - -#include "base/basictypes.h" -#include "ppapi/c/pp_instance.h" -#include "ppapi/c/pp_resource.h" -#include "ppapi/proxy/interface_proxy.h" -#include "ppapi/proxy/ppapi_proxy_export.h" - -struct PP_NetAddress_Private; - -namespace ppapi { -namespace proxy { - -class PPB_TCPSocket_Proxy : public InterfaceProxy { - public: - explicit PPB_TCPSocket_Proxy(Dispatcher* dispatcher); - virtual ~PPB_TCPSocket_Proxy(); - - static PP_Resource CreateProxyResource(PP_Instance instance); - - // InterfaceProxy implementation. - virtual bool OnMessageReceived(const IPC::Message& msg); - - static const ApiID kApiID = API_ID_PPB_TCPSOCKET; - - private: - // Browser->plugin message handlers. - void OnMsgConnectACK(uint32 plugin_dispatcher_id, - uint32 socket_id, - int32_t result, - const PP_NetAddress_Private& local_addr, - const PP_NetAddress_Private& remote_addr); - void OnMsgReadACK(uint32 plugin_dispatcher_id, - uint32 socket_id, - int32_t result, - const std::string& data); - void OnMsgWriteACK(uint32 plugin_dispatcher_id, - uint32 socket_id, - int32_t result); - void OnMsgSetOptionACK(uint32 plugin_dispatcher_id, - uint32 socket_id, - int32_t result); - - DISALLOW_COPY_AND_ASSIGN(PPB_TCPSocket_Proxy); -}; - -} // namespace proxy -} // namespace ppapi - -#endif // PPAPI_PROXY_PPB_TCP_SOCKET_PROXY_H_ diff --git a/chromium/ppapi/proxy/ppp_content_decryptor_private_proxy.cc b/chromium/ppapi/proxy/ppp_content_decryptor_private_proxy.cc index f986e7f8d72..d32e6320094 100644 --- a/chromium/ppapi/proxy/ppp_content_decryptor_private_proxy.cc +++ b/chromium/ppapi/proxy/ppp_content_decryptor_private_proxy.cc @@ -109,8 +109,24 @@ bool InitializePppDecryptorBuffer(PP_Instance instance, return true; } +void Initialize(PP_Instance instance, + PP_Var key_system, + PP_Bool can_challenge_platform) { + HostDispatcher* dispatcher = HostDispatcher::GetForInstance(instance); + if (!dispatcher) { + NOTREACHED(); + return; + } + + dispatcher->Send( + new PpapiMsg_PPPContentDecryptor_Initialize( + API_ID_PPP_CONTENT_DECRYPTOR_PRIVATE, + instance, + SerializedVarSendInput(dispatcher, key_system), + PP_ToBool(can_challenge_platform))); +} + void GenerateKeyRequest(PP_Instance instance, - PP_Var key_system, PP_Var type, PP_Var init_data) { HostDispatcher* dispatcher = HostDispatcher::GetForInstance(instance); @@ -123,7 +139,6 @@ void GenerateKeyRequest(PP_Instance instance, new PpapiMsg_PPPContentDecryptor_GenerateKeyRequest( API_ID_PPP_CONTENT_DECRYPTOR_PRIVATE, instance, - SerializedVarSendInput(dispatcher, key_system), SerializedVarSendInput(dispatcher, type), SerializedVarSendInput(dispatcher, init_data))); } @@ -349,6 +364,7 @@ void DecryptAndDecode(PP_Instance instance, } static const PPP_ContentDecryptor_Private content_decryptor_interface = { + &Initialize, &GenerateKeyRequest, &AddKey, &CancelKeyRequest, @@ -390,6 +406,8 @@ bool PPP_ContentDecryptor_Private_Proxy::OnMessageReceived( bool handled = true; IPC_BEGIN_MESSAGE_MAP(PPP_ContentDecryptor_Private_Proxy, msg) + IPC_MESSAGE_HANDLER(PpapiMsg_PPPContentDecryptor_Initialize, + OnMsgInitialize) IPC_MESSAGE_HANDLER(PpapiMsg_PPPContentDecryptor_GenerateKeyRequest, OnMsgGenerateKeyRequest) IPC_MESSAGE_HANDLER(PpapiMsg_PPPContentDecryptor_AddKey, @@ -414,15 +432,26 @@ bool PPP_ContentDecryptor_Private_Proxy::OnMessageReceived( return handled; } -void PPP_ContentDecryptor_Private_Proxy::OnMsgGenerateKeyRequest( +void PPP_ContentDecryptor_Private_Proxy::OnMsgInitialize( PP_Instance instance, SerializedVarReceiveInput key_system, + bool can_challenge_platform) { + if (ppp_decryptor_impl_) { + CallWhileUnlocked( + ppp_decryptor_impl_->Initialize, + instance, + ExtractReceivedVarAndAddRef(dispatcher(), &key_system), + PP_FromBool(can_challenge_platform)); + } +} + +void PPP_ContentDecryptor_Private_Proxy::OnMsgGenerateKeyRequest( + PP_Instance instance, SerializedVarReceiveInput type, SerializedVarReceiveInput init_data) { if (ppp_decryptor_impl_) { CallWhileUnlocked(ppp_decryptor_impl_->GenerateKeyRequest, instance, - ExtractReceivedVarAndAddRef(dispatcher(), &key_system), ExtractReceivedVarAndAddRef(dispatcher(), &type), ExtractReceivedVarAndAddRef(dispatcher(), &init_data)); } diff --git a/chromium/ppapi/proxy/ppp_content_decryptor_private_proxy.h b/chromium/ppapi/proxy/ppp_content_decryptor_private_proxy.h index 5e7ecc85dba..2e4ad8548a9 100644 --- a/chromium/ppapi/proxy/ppp_content_decryptor_private_proxy.h +++ b/chromium/ppapi/proxy/ppp_content_decryptor_private_proxy.h @@ -30,8 +30,10 @@ class PPP_ContentDecryptor_Private_Proxy : public InterfaceProxy { virtual bool OnMessageReceived(const IPC::Message& msg); // Message handlers. + void OnMsgInitialize(PP_Instance instance, + SerializedVarReceiveInput key_system, + bool can_challenge_platform); void OnMsgGenerateKeyRequest(PP_Instance instance, - SerializedVarReceiveInput key_system, SerializedVarReceiveInput type, SerializedVarReceiveInput init_data); void OnMsgAddKey(PP_Instance instance, diff --git a/chromium/ppapi/proxy/ppp_messaging_proxy_perftest.cc b/chromium/ppapi/proxy/ppp_messaging_proxy_perftest.cc index c52ea116687..666609a51b3 100644 --- a/chromium/ppapi/proxy/ppp_messaging_proxy_perftest.cc +++ b/chromium/ppapi/proxy/ppp_messaging_proxy_perftest.cc @@ -3,8 +3,8 @@ // found in the LICENSE file. #include "base/command_line.h" -#include "base/perftimer.h" #include "base/strings/string_number_conversions.h" +#include "base/test/perf_time_logger.h" #include "ppapi/c/ppp_messaging.h" #include "ppapi/proxy/ppapi_proxy_test.h" #include "ppapi/proxy/serialized_var.h" @@ -73,7 +73,7 @@ TEST_F(PppMessagingPerfTest, StringPerformance) { } } srand(seed); - PerfTimeLogger logger("PppMessagingPerfTest.StringPerformance"); + base::PerfTimeLogger logger("PppMessagingPerfTest.StringPerformance"); for (int i = 0; i < string_count; ++i) { const std::string test_string(rand() % max_string_size, 'a'); PP_Var host_string = StringVar::StringToPPVar(test_string); diff --git a/chromium/ppapi/proxy/raw_var_data.cc b/chromium/ppapi/proxy/raw_var_data.cc index a550c3fca05..b41304849ba 100644 --- a/chromium/ppapi/proxy/raw_var_data.cc +++ b/chromium/ppapi/proxy/raw_var_data.cc @@ -240,6 +240,11 @@ RawVarData* RawVarData::Create(PP_VarType type) { return new ArrayRawVarData(); case PP_VARTYPE_DICTIONARY: return new DictionaryRawVarData(); + case PP_VARTYPE_RESOURCE: + // TODO(mgiuca): Add ResourceRawVarData. (http://crbug.com/177017) + // This path will be reached if a NaCl module attempts to pass a + // PP_VARTYPE_RESOURCE in a message. + break; } NOTREACHED(); return NULL; diff --git a/chromium/ppapi/proxy/raw_var_data_unittest.cc b/chromium/ppapi/proxy/raw_var_data_unittest.cc index 2ee69144f61..c45ca9d6967 100644 --- a/chromium/ppapi/proxy/raw_var_data_unittest.cc +++ b/chromium/ppapi/proxy/raw_var_data_unittest.cc @@ -37,6 +37,7 @@ class RawVarDataTest : public testing::Test { // testing::Test implementation. virtual void SetUp() { + ProxyLock::EnableLockingOnThreadForTest(); ProxyLock::Acquire(); } virtual void TearDown() { diff --git a/chromium/ppapi/proxy/resource_creation_proxy.cc b/chromium/ppapi/proxy/resource_creation_proxy.cc index 53cade1e91a..d1b99ecb014 100644 --- a/chromium/ppapi/proxy/resource_creation_proxy.cc +++ b/chromium/ppapi/proxy/resource_creation_proxy.cc @@ -11,6 +11,7 @@ #include "ppapi/proxy/ext_crx_file_system_private_resource.h" #include "ppapi/proxy/file_chooser_resource.h" #include "ppapi/proxy/file_io_resource.h" +#include "ppapi/proxy/file_ref_resource.h" #include "ppapi/proxy/file_system_resource.h" #include "ppapi/proxy/flash_drm_resource.h" #include "ppapi/proxy/flash_font_file_resource.h" @@ -19,6 +20,8 @@ #include "ppapi/proxy/host_resolver_private_resource.h" #include "ppapi/proxy/host_resolver_resource.h" #include "ppapi/proxy/net_address_resource.h" +#include "ppapi/proxy/network_monitor_resource.h" +#include "ppapi/proxy/platform_verification_private_resource.h" #include "ppapi/proxy/plugin_dispatcher.h" #include "ppapi/proxy/plugin_globals.h" #include "ppapi/proxy/plugin_resource_tracker.h" @@ -26,18 +29,16 @@ #include "ppapi/proxy/ppb_audio_proxy.h" #include "ppapi/proxy/ppb_broker_proxy.h" #include "ppapi/proxy/ppb_buffer_proxy.h" -#include "ppapi/proxy/ppb_file_ref_proxy.h" #include "ppapi/proxy/ppb_flash_message_loop_proxy.h" #include "ppapi/proxy/ppb_graphics_3d_proxy.h" #include "ppapi/proxy/ppb_image_data_proxy.h" -#include "ppapi/proxy/ppb_network_monitor_private_proxy.h" -#include "ppapi/proxy/ppb_tcp_socket_private_proxy.h" -#include "ppapi/proxy/ppb_tcp_socket_proxy.h" #include "ppapi/proxy/ppb_video_decoder_proxy.h" #include "ppapi/proxy/ppb_x509_certificate_private_proxy.h" #include "ppapi/proxy/printing_resource.h" #include "ppapi/proxy/talk_resource.h" #include "ppapi/proxy/tcp_server_socket_private_resource.h" +#include "ppapi/proxy/tcp_socket_private_resource.h" +#include "ppapi/proxy/tcp_socket_resource.h" #include "ppapi/proxy/truetype_font_resource.h" #include "ppapi/proxy/udp_socket_private_resource.h" #include "ppapi/proxy/udp_socket_resource.h" @@ -51,6 +52,7 @@ #include "ppapi/shared_impl/api_id.h" #include "ppapi/shared_impl/host_resource.h" #include "ppapi/shared_impl/ppb_audio_config_shared.h" +#include "ppapi/shared_impl/ppb_audio_shared.h" #include "ppapi/shared_impl/ppb_input_event_shared.h" #include "ppapi/shared_impl/ppb_resource_array_shared.h" #include "ppapi/shared_impl/var.h" @@ -78,15 +80,10 @@ PP_Resource ResourceCreationProxy::CreateFileIO(PP_Instance instance) { return (new FileIOResource(GetConnection(), instance))->GetReference(); } -PP_Resource ResourceCreationProxy::CreateFileRef(PP_Instance instance, - PP_Resource file_system, - const char* path) { - return PPB_FileRef_Proxy::CreateProxyResource(instance, file_system, path); -} - PP_Resource ResourceCreationProxy::CreateFileRef( - const PPB_FileRef_CreateInfo& create_info) { - return PPB_FileRef_Proxy::DeserializeFileRef(create_info); + PP_Instance instance, + const FileRefCreateInfo& create_info) { + return FileRefResource::CreateFileRef(GetConnection(), instance, create_info); } PP_Resource ResourceCreationProxy::CreateFileSystem( @@ -96,15 +93,6 @@ PP_Resource ResourceCreationProxy::CreateFileSystem( type))->GetReference(); } -PP_Resource ResourceCreationProxy::CreateIsolatedFileSystem( - PP_Instance instance, - const char* fsid) { - FileSystemResource* fs = new FileSystemResource( - GetConnection(), instance, PP_FILESYSTEMTYPE_ISOLATED); - fs->InitIsolatedFileSystem(fsid); - return fs->GetReference(); -} - PP_Resource ResourceCreationProxy::CreateIMEInputEvent( PP_Instance instance, PP_InputEvent_Type type, @@ -194,13 +182,22 @@ PP_Resource ResourceCreationProxy::CreateWheelInputEvent( wheel_delta, wheel_ticks, scroll_by_page); } +PP_Resource ResourceCreationProxy::CreateAudio1_0( + PP_Instance instance, + PP_Resource config_id, + PPB_Audio_Callback_1_0 audio_callback, + void* user_data) { + return PPB_Audio_Proxy::CreateProxyResource( + instance, config_id, AudioCallbackCombined(audio_callback), user_data); +} + PP_Resource ResourceCreationProxy::CreateAudio( PP_Instance instance, PP_Resource config_id, PPB_Audio_Callback audio_callback, void* user_data) { - return PPB_Audio_Proxy::CreateProxyResource(instance, config_id, - audio_callback, user_data); + return PPB_Audio_Proxy::CreateProxyResource( + instance, config_id, AudioCallbackCombined(audio_callback), user_data); } PP_Resource ResourceCreationProxy::CreateAudioTrusted(PP_Instance instance) { @@ -311,11 +308,9 @@ PP_Resource ResourceCreationProxy::CreateNetAddressFromNetAddressPrivate( } PP_Resource ResourceCreationProxy::CreateNetworkMonitor( - PP_Instance instance, - PPB_NetworkMonitor_Callback callback, - void* user_data) { - return PPB_NetworkMonitor_Private_Proxy::CreateProxyResource( - instance, callback, user_data); + PP_Instance instance) { + return (new NetworkMonitorResource(GetConnection(), instance))-> + GetReference(); } PP_Resource ResourceCreationProxy::CreatePrinting(PP_Instance instance) { @@ -328,14 +323,23 @@ PP_Resource ResourceCreationProxy::CreateTCPServerSocketPrivate( GetReference(); } +PP_Resource ResourceCreationProxy::CreateTCPSocket1_0( + PP_Instance instance) { + return (new TCPSocketResource(GetConnection(), instance, + TCP_SOCKET_VERSION_1_0))->GetReference(); +} + PP_Resource ResourceCreationProxy::CreateTCPSocket( PP_Instance instance) { - return PPB_TCPSocket_Proxy::CreateProxyResource(instance); + return (new TCPSocketResource( + GetConnection(), instance, TCP_SOCKET_VERSION_1_1_OR_ABOVE))-> + GetReference(); } PP_Resource ResourceCreationProxy::CreateTCPSocketPrivate( PP_Instance instance) { - return PPB_TCPSocket_Private_Proxy::CreateProxyResource(instance); + return (new TCPSocketPrivateResource(GetConnection(), instance))-> + GetReference(); } PP_Resource ResourceCreationProxy::CreateUDPSocket(PP_Instance instance) { @@ -420,6 +424,12 @@ PP_Resource ResourceCreationProxy::CreateFlashMessageLoop( return PPB_Flash_MessageLoop_Proxy::CreateProxyResource(instance); } +PP_Resource ResourceCreationProxy::CreatePlatformVerificationPrivate( + PP_Instance instance) { + return (new PlatformVerificationPrivateResource(GetConnection(), instance))-> + GetReference(); +} + PP_Resource ResourceCreationProxy::CreateScrollbar(PP_Instance instance, PP_Bool vertical) { NOTIMPLEMENTED(); // Not proxied yet. diff --git a/chromium/ppapi/proxy/resource_creation_proxy.h b/chromium/ppapi/proxy/resource_creation_proxy.h index 47b40a83927..1507dc8c6c5 100644 --- a/chromium/ppapi/proxy/resource_creation_proxy.h +++ b/chromium/ppapi/proxy/resource_creation_proxy.h @@ -38,16 +38,11 @@ class ResourceCreationProxy : public InterfaceProxy, // ResourceCreationAPI (called in plugin). virtual PP_Resource CreateFileIO(PP_Instance instance) OVERRIDE; - virtual PP_Resource CreateFileRef(PP_Instance instance, - PP_Resource file_system, - const char* path) OVERRIDE; virtual PP_Resource CreateFileRef( - const PPB_FileRef_CreateInfo& create_info) OVERRIDE; + PP_Instance instance, + const FileRefCreateInfo& create_info) OVERRIDE; virtual PP_Resource CreateFileSystem(PP_Instance instance, PP_FileSystemType type) OVERRIDE; - virtual PP_Resource CreateIsolatedFileSystem( - PP_Instance instance, - const char* fsid) OVERRIDE; virtual PP_Resource CreateIMEInputEvent(PP_Instance instance, PP_InputEvent_Type type, PP_TimeTicks time_stamp, @@ -94,7 +89,10 @@ class ResourceCreationProxy : public InterfaceProxy, const PP_FloatPoint* wheel_delta, const PP_FloatPoint* wheel_ticks, PP_Bool scroll_by_page) OVERRIDE; - + virtual PP_Resource CreateAudio1_0(PP_Instance instance, + PP_Resource config_id, + PPB_Audio_Callback_1_0 audio_callback, + void* user_data) OVERRIDE; virtual PP_Resource CreateAudio(PP_Instance instance, PP_Resource config_id, PPB_Audio_Callback audio_callback, @@ -135,13 +133,11 @@ class ResourceCreationProxy : public InterfaceProxy, virtual PP_Resource CreateNetAddressFromNetAddressPrivate( PP_Instance instance, const PP_NetAddress_Private& private_addr) OVERRIDE; - virtual PP_Resource CreateNetworkMonitor( - PP_Instance instance, - PPB_NetworkMonitor_Callback callback, - void* user_data) OVERRIDE; + virtual PP_Resource CreateNetworkMonitor(PP_Instance instance) OVERRIDE; virtual PP_Resource CreatePrinting(PP_Instance) OVERRIDE; virtual PP_Resource CreateTCPServerSocketPrivate( PP_Instance instance) OVERRIDE; + virtual PP_Resource CreateTCPSocket1_0(PP_Instance instance) OVERRIDE; virtual PP_Resource CreateTCPSocket(PP_Instance instance) OVERRIDE; virtual PP_Resource CreateTCPSocketPrivate(PP_Instance instance) OVERRIDE; virtual PP_Resource CreateUDPSocket(PP_Instance instance) OVERRIDE; @@ -167,6 +163,8 @@ class ResourceCreationProxy : public InterfaceProxy, virtual PP_Resource CreateFlashMenu(PP_Instance instance, const PP_Flash_Menu* menu_data) OVERRIDE; virtual PP_Resource CreateFlashMessageLoop(PP_Instance instance) OVERRIDE; + virtual PP_Resource CreatePlatformVerificationPrivate( + PP_Instance instance) OVERRIDE; virtual PP_Resource CreateScrollbar(PP_Instance instance, PP_Bool vertical) OVERRIDE; virtual PP_Resource CreateTalk(PP_Instance instance) OVERRIDE; diff --git a/chromium/ppapi/proxy/run_all_unittests.cc b/chromium/ppapi/proxy/run_all_unittests.cc deleted file mode 100644 index 7fd6ef2e80e..00000000000 --- a/chromium/ppapi/proxy/run_all_unittests.cc +++ /dev/null @@ -1,9 +0,0 @@ -// 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 "base/test/test_suite.h" - -int main(int argc, char** argv) { - return base::TestSuite(argc, argv).Run(); -} diff --git a/chromium/ppapi/proxy/serialized_structs.cc b/chromium/ppapi/proxy/serialized_structs.cc index 8c984d55dba..255865a65dc 100644 --- a/chromium/ppapi/proxy/serialized_structs.cc +++ b/chromium/ppapi/proxy/serialized_structs.cc @@ -80,6 +80,14 @@ void SerializedFontDescription::SetToPPBrowserFontDescription( desc->word_spacing = word_spacing; } +SerializedNetworkInfo::SerializedNetworkInfo() + : type(PP_NETWORKLIST_TYPE_UNKNOWN), + state(PP_NETWORKLIST_STATE_DOWN), + mtu(0) { +} + +SerializedNetworkInfo::~SerializedNetworkInfo() {} + SerializedTrueTypeFontDesc::SerializedTrueTypeFontDesc() : family(), generic_family(), diff --git a/chromium/ppapi/proxy/serialized_structs.h b/chromium/ppapi/proxy/serialized_structs.h index 1f89ae2047c..fb93dd16d03 100644 --- a/chromium/ppapi/proxy/serialized_structs.h +++ b/chromium/ppapi/proxy/serialized_structs.h @@ -16,6 +16,8 @@ #include "ppapi/c/pp_instance.h" #include "ppapi/c/pp_point.h" #include "ppapi/c/pp_rect.h" +#include "ppapi/c/ppb_network_list.h" +#include "ppapi/c/private/ppb_net_address_private.h" #include "ppapi/proxy/ppapi_proxy_export.h" #include "ppapi/shared_impl/host_resource.h" @@ -57,6 +59,19 @@ struct PPAPI_PROXY_EXPORT SerializedFontDescription { int32_t word_spacing; }; +struct PPAPI_PROXY_EXPORT SerializedNetworkInfo { + SerializedNetworkInfo(); + ~SerializedNetworkInfo(); + + std::string name; + PP_NetworkList_Type type; + PP_NetworkList_State state; + std::vector<PP_NetAddress_Private> addresses; + std::string display_name; + int mtu; +}; +typedef std::vector<SerializedNetworkInfo> SerializedNetworkList; + struct PPAPI_PROXY_EXPORT SerializedTrueTypeFontDesc { SerializedTrueTypeFontDesc(); ~SerializedTrueTypeFontDesc(); diff --git a/chromium/ppapi/proxy/tcp_server_socket_private_resource.cc b/chromium/ppapi/proxy/tcp_server_socket_private_resource.cc index 6bbf4667ee7..745ed622fa2 100644 --- a/chromium/ppapi/proxy/tcp_server_socket_private_resource.cc +++ b/chromium/ppapi/proxy/tcp_server_socket_private_resource.cc @@ -4,9 +4,8 @@ #include "ppapi/proxy/tcp_server_socket_private_resource.h" -#include "ppapi/proxy/plugin_dispatcher.h" #include "ppapi/proxy/ppapi_messages.h" -#include "ppapi/proxy/ppb_tcp_socket_private_proxy.h" +#include "ppapi/proxy/tcp_socket_private_resource.h" namespace ppapi { namespace proxy { @@ -16,15 +15,8 @@ TCPServerSocketPrivateResource::TCPServerSocketPrivateResource( PP_Instance instance) : PluginResource(connection, instance), state_(STATE_BEFORE_LISTENING), - local_addr_(), - plugin_dispatcher_id_(0) { + local_addr_() { SendCreate(BROWSER, PpapiHostMsg_TCPServerSocket_CreatePrivate()); - - PluginDispatcher* dispatcher = PluginDispatcher::GetForInstance(instance); - if (dispatcher) - plugin_dispatcher_id_ = dispatcher->plugin_dispatcher_id(); - else - NOTREACHED(); } TCPServerSocketPrivateResource::~TCPServerSocketPrivateResource() { @@ -71,7 +63,7 @@ int32_t TCPServerSocketPrivateResource::Accept( Call<PpapiPluginMsg_TCPServerSocket_AcceptReply>( BROWSER, - PpapiHostMsg_TCPServerSocket_Accept(plugin_dispatcher_id_), + PpapiHostMsg_TCPServerSocket_Accept(), base::Bind(&TCPServerSocketPrivateResource::OnPluginMsgAcceptReply, base::Unretained(this), tcp_socket)); return PP_OK_COMPLETIONPENDING; @@ -115,7 +107,7 @@ void TCPServerSocketPrivateResource::OnPluginMsgListenReply( void TCPServerSocketPrivateResource::OnPluginMsgAcceptReply( PP_Resource* tcp_socket, const ResourceMessageReplyParams& params, - uint32 accepted_socket_id, + int pending_resource_id, const PP_NetAddress_Private& local_addr, const PP_NetAddress_Private& remote_addr) { DCHECK(tcp_socket); @@ -124,12 +116,10 @@ void TCPServerSocketPrivateResource::OnPluginMsgAcceptReply( return; } if (params.result() == PP_OK) { - *tcp_socket = - PPB_TCPSocket_Private_Proxy::CreateProxyResourceForConnectedSocket( - pp_instance(), - accepted_socket_id, - local_addr, - remote_addr); + *tcp_socket = (new TCPSocketPrivateResource(connection(), pp_instance(), + pending_resource_id, + local_addr, + remote_addr))->GetReference(); } accept_callback_->Run(params.result()); } diff --git a/chromium/ppapi/proxy/tcp_server_socket_private_resource.h b/chromium/ppapi/proxy/tcp_server_socket_private_resource.h index 95febde92cd..21e190a6278 100644 --- a/chromium/ppapi/proxy/tcp_server_socket_private_resource.h +++ b/chromium/ppapi/proxy/tcp_server_socket_private_resource.h @@ -48,15 +48,13 @@ class PPAPI_PROXY_EXPORT TCPServerSocketPrivateResource const PP_NetAddress_Private& local_addr); void OnPluginMsgAcceptReply(PP_Resource* tcp_socket, const ResourceMessageReplyParams& params, - uint32 accepted_socket_id, + int pending_resource_id, const PP_NetAddress_Private& local_addr, const PP_NetAddress_Private& remote_addr); State state_; PP_NetAddress_Private local_addr_; - uint32 plugin_dispatcher_id_; - scoped_refptr<TrackedCallback> listen_callback_; scoped_refptr<TrackedCallback> accept_callback_; diff --git a/chromium/ppapi/proxy/tcp_socket_private_resource.cc b/chromium/ppapi/proxy/tcp_socket_private_resource.cc new file mode 100644 index 00000000000..76ed4b9e1e2 --- /dev/null +++ b/chromium/ppapi/proxy/tcp_socket_private_resource.cc @@ -0,0 +1,120 @@ +// Copyright 2013 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/proxy/tcp_socket_private_resource.h" + +#include "ppapi/proxy/ppapi_messages.h" +#include "ppapi/shared_impl/ppb_tcp_socket_shared.h" + +namespace ppapi { +namespace proxy { + +TCPSocketPrivateResource::TCPSocketPrivateResource(Connection connection, + PP_Instance instance) + : TCPSocketResourceBase(connection, instance, TCP_SOCKET_VERSION_PRIVATE) { + SendCreate(BROWSER, PpapiHostMsg_TCPSocket_CreatePrivate()); +} + +TCPSocketPrivateResource::TCPSocketPrivateResource( + Connection connection, + PP_Instance instance, + int pending_resource_id, + const PP_NetAddress_Private& local_addr, + const PP_NetAddress_Private& remote_addr) + : TCPSocketResourceBase(connection, instance, TCP_SOCKET_VERSION_PRIVATE, + local_addr, remote_addr) { + AttachToPendingHost(BROWSER, pending_resource_id); +} + +TCPSocketPrivateResource::~TCPSocketPrivateResource() { +} + +thunk::PPB_TCPSocket_Private_API* +TCPSocketPrivateResource::AsPPB_TCPSocket_Private_API() { + return this; +} + +int32_t TCPSocketPrivateResource::Connect( + const char* host, + uint16_t port, + scoped_refptr<TrackedCallback> callback) { + return ConnectImpl(host, port, callback); +} + +int32_t TCPSocketPrivateResource::ConnectWithNetAddress( + const PP_NetAddress_Private* addr, + scoped_refptr<TrackedCallback> callback) { + return ConnectWithNetAddressImpl(addr, callback); +} + +PP_Bool TCPSocketPrivateResource::GetLocalAddress( + PP_NetAddress_Private* local_addr) { + return GetLocalAddressImpl(local_addr); +} + +PP_Bool TCPSocketPrivateResource::GetRemoteAddress( + PP_NetAddress_Private* remote_addr) { + return GetRemoteAddressImpl(remote_addr); +} + +int32_t TCPSocketPrivateResource::SSLHandshake( + const char* server_name, + uint16_t server_port, + scoped_refptr<TrackedCallback> callback) { + return SSLHandshakeImpl(server_name, server_port, callback); +} + +PP_Resource TCPSocketPrivateResource::GetServerCertificate() { + return GetServerCertificateImpl(); +} + +PP_Bool TCPSocketPrivateResource::AddChainBuildingCertificate( + PP_Resource certificate, + PP_Bool trusted) { + return AddChainBuildingCertificateImpl(certificate, trusted); +} + +int32_t TCPSocketPrivateResource::Read( + char* buffer, + int32_t bytes_to_read, + scoped_refptr<TrackedCallback> callback) { + return ReadImpl(buffer, bytes_to_read, callback); +} + +int32_t TCPSocketPrivateResource::Write( + const char* buffer, + int32_t bytes_to_write, + scoped_refptr<TrackedCallback> callback) { + return WriteImpl(buffer, bytes_to_write, callback); +} + +void TCPSocketPrivateResource::Disconnect() { + CloseImpl(); +} + +int32_t TCPSocketPrivateResource::SetOption( + PP_TCPSocketOption_Private name, + const PP_Var& value, + scoped_refptr<TrackedCallback> callback) { + switch (name) { + case PP_TCPSOCKETOPTION_PRIVATE_INVALID: + return PP_ERROR_BADARGUMENT; + case PP_TCPSOCKETOPTION_PRIVATE_NO_DELAY: + return SetOptionImpl(PP_TCPSOCKET_OPTION_NO_DELAY, value, callback); + default: + NOTREACHED(); + return PP_ERROR_BADARGUMENT; + } +} + +PP_Resource TCPSocketPrivateResource::CreateAcceptedSocket( + int /* pending_host_id */, + const PP_NetAddress_Private& /* local_addr */, + const PP_NetAddress_Private& /* remote_addr */) { + NOTREACHED(); + return 0; +} + +} // namespace proxy +} // namespace ppapi diff --git a/chromium/ppapi/shared_impl/private/tcp_socket_private_impl.h b/chromium/ppapi/proxy/tcp_socket_private_resource.h index 36303fa7691..9ae9bb2d939 100644 --- a/chromium/ppapi/shared_impl/private/tcp_socket_private_impl.h +++ b/chromium/ppapi/proxy/tcp_socket_private_resource.h @@ -1,35 +1,35 @@ -// Copyright (c) 2012 The Chromium Authors. All rights reserved. +// Copyright 2013 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_SHARED_IMPL_PRIVATE_TCP_SOCKET_PRIVATE_IMPL_H_ -#define PPAPI_SHARED_IMPL_PRIVATE_TCP_SOCKET_PRIVATE_IMPL_H_ +#ifndef PPAPI_PROXY_TCP_SOCKET_PRIVATE_RESOURCE_H_ +#define PPAPI_PROXY_TCP_SOCKET_PRIVATE_RESOURCE_H_ #include "base/basictypes.h" #include "base/compiler_specific.h" -#include "ppapi/shared_impl/resource.h" -#include "ppapi/shared_impl/tcp_socket_shared.h" +#include "ppapi/proxy/tcp_socket_resource_base.h" #include "ppapi/thunk/ppb_tcp_socket_private_api.h" namespace ppapi { +namespace proxy { -// This class provides the shared implementation of a -// PPB_TCPSocket_Private. The functions that actually send messages -// to browser are implemented differently for the proxied and -// non-proxied derived classes. -class PPAPI_SHARED_EXPORT TCPSocketPrivateImpl +class PPAPI_PROXY_EXPORT TCPSocketPrivateResource : public thunk::PPB_TCPSocket_Private_API, - public Resource, - public TCPSocketShared { + public TCPSocketResourceBase { public: - // C-tor used in Impl case. - TCPSocketPrivateImpl(PP_Instance instance, uint32 socket_id); - // C-tor used in Proxy case. - TCPSocketPrivateImpl(const HostResource& resource, uint32 socket_id); + // C-tor used for new sockets. + TCPSocketPrivateResource(Connection connection, PP_Instance instance); - virtual ~TCPSocketPrivateImpl(); + // C-tor used for already accepted sockets. + TCPSocketPrivateResource(Connection connection, + PP_Instance instance, + int pending_resource_id, + const PP_NetAddress_Private& local_addr, + const PP_NetAddress_Private& remote_addr); - // Resource overrides. + virtual ~TCPSocketPrivateResource(); + + // PluginResource overrides. virtual PPB_TCPSocket_Private_API* AsPPB_TCPSocket_Private_API() OVERRIDE; // PPB_TCPSocket_Private_API implementation. @@ -59,16 +59,17 @@ class PPAPI_SHARED_EXPORT TCPSocketPrivateImpl const PP_Var& value, scoped_refptr<TrackedCallback> callback) OVERRIDE; - // TCPSocketShared implementation. - virtual Resource* GetOwnerResource() OVERRIDE; - - // TCPSocketShared overrides. - virtual int32_t OverridePPError(int32_t pp_error) OVERRIDE; + // TCPSocketResourceBase implementation. + virtual PP_Resource CreateAcceptedSocket( + int pending_host_id, + const PP_NetAddress_Private& local_addr, + const PP_NetAddress_Private& remote_addr) OVERRIDE; private: - DISALLOW_COPY_AND_ASSIGN(TCPSocketPrivateImpl); + DISALLOW_COPY_AND_ASSIGN(TCPSocketPrivateResource); }; +} // namespace proxy } // namespace ppapi -#endif // PPAPI_SHARED_IMPL_PRIVATE_TCP_SOCKET_PRIVATE_IMPL_H_ +#endif // PPAPI_PROXY_TCP_SOCKET_PRIVATE_RESOURCE_H_ diff --git a/chromium/ppapi/proxy/tcp_socket_resource.cc b/chromium/ppapi/proxy/tcp_socket_resource.cc new file mode 100644 index 00000000000..f8f8f68f261 --- /dev/null +++ b/chromium/ppapi/proxy/tcp_socket_resource.cc @@ -0,0 +1,133 @@ +// Copyright 2013 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/proxy/tcp_socket_resource.h" + +#include "base/logging.h" +#include "ppapi/proxy/ppapi_messages.h" +#include "ppapi/shared_impl/ppb_tcp_socket_shared.h" +#include "ppapi/thunk/enter.h" +#include "ppapi/thunk/ppb_net_address_api.h" + +namespace ppapi { +namespace proxy { + +namespace { + +typedef thunk::EnterResourceNoLock<thunk::PPB_NetAddress_API> + EnterNetAddressNoLock; + +} // namespace + +TCPSocketResource::TCPSocketResource(Connection connection, + PP_Instance instance, + TCPSocketVersion version) + : TCPSocketResourceBase(connection, instance, version) { + DCHECK_NE(version, TCP_SOCKET_VERSION_PRIVATE); + SendCreate(BROWSER, PpapiHostMsg_TCPSocket_Create(version)); +} + +TCPSocketResource::TCPSocketResource(Connection connection, + PP_Instance instance, + int pending_host_id, + const PP_NetAddress_Private& local_addr, + const PP_NetAddress_Private& remote_addr) + : TCPSocketResourceBase(connection, instance, + TCP_SOCKET_VERSION_1_1_OR_ABOVE, local_addr, + remote_addr) { + AttachToPendingHost(BROWSER, pending_host_id); +} + +TCPSocketResource::~TCPSocketResource() { +} + +thunk::PPB_TCPSocket_API* TCPSocketResource::AsPPB_TCPSocket_API() { + return this; +} + +int32_t TCPSocketResource::Bind(PP_Resource addr, + scoped_refptr<TrackedCallback> callback) { + EnterNetAddressNoLock enter(addr, true); + if (enter.failed()) + return PP_ERROR_BADARGUMENT; + + return BindImpl(&enter.object()->GetNetAddressPrivate(), callback); +} + +int32_t TCPSocketResource::Connect(PP_Resource addr, + scoped_refptr<TrackedCallback> callback) { + EnterNetAddressNoLock enter(addr, true); + if (enter.failed()) + return PP_ERROR_BADARGUMENT; + + return ConnectWithNetAddressImpl(&enter.object()->GetNetAddressPrivate(), + callback); +} + +PP_Resource TCPSocketResource::GetLocalAddress() { + PP_NetAddress_Private addr_private; + if (!GetLocalAddressImpl(&addr_private)) + return 0; + + thunk::EnterResourceCreationNoLock enter(pp_instance()); + if (enter.failed()) + return 0; + return enter.functions()->CreateNetAddressFromNetAddressPrivate( + pp_instance(), addr_private); +} + +PP_Resource TCPSocketResource::GetRemoteAddress() { + PP_NetAddress_Private addr_private; + if (!GetRemoteAddressImpl(&addr_private)) + return 0; + + thunk::EnterResourceCreationNoLock enter(pp_instance()); + if (enter.failed()) + return 0; + return enter.functions()->CreateNetAddressFromNetAddressPrivate( + pp_instance(), addr_private); +} + +int32_t TCPSocketResource::Read(char* buffer, + int32_t bytes_to_read, + scoped_refptr<TrackedCallback> callback) { + return ReadImpl(buffer, bytes_to_read, callback); +} + +int32_t TCPSocketResource::Write(const char* buffer, + int32_t bytes_to_write, + scoped_refptr<TrackedCallback> callback) { + return WriteImpl(buffer, bytes_to_write, callback); +} + +int32_t TCPSocketResource::Listen(int32_t backlog, + scoped_refptr<TrackedCallback> callback) { + return ListenImpl(backlog, callback); +} + +int32_t TCPSocketResource::Accept(PP_Resource* accepted_tcp_socket, + scoped_refptr<TrackedCallback> callback) { + return AcceptImpl(accepted_tcp_socket, callback); +} + +void TCPSocketResource::Close() { + CloseImpl(); +} + +int32_t TCPSocketResource::SetOption(PP_TCPSocket_Option name, + const PP_Var& value, + scoped_refptr<TrackedCallback> callback) { + return SetOptionImpl(name, value, callback); +} + +PP_Resource TCPSocketResource::CreateAcceptedSocket( + int pending_host_id, + const PP_NetAddress_Private& local_addr, + const PP_NetAddress_Private& remote_addr) { + return (new TCPSocketResource(connection(), pp_instance(), pending_host_id, + local_addr, remote_addr))->GetReference(); +} + +} // namespace proxy +} // namespace ppapi diff --git a/chromium/ppapi/proxy/tcp_socket_resource.h b/chromium/ppapi/proxy/tcp_socket_resource.h new file mode 100644 index 00000000000..5dbfdd54a57 --- /dev/null +++ b/chromium/ppapi/proxy/tcp_socket_resource.h @@ -0,0 +1,74 @@ +// Copyright 2013 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_PROXY_TCP_SOCKET_RESOURCE_H_ +#define PPAPI_PROXY_TCP_SOCKET_RESOURCE_H_ + +#include "base/basictypes.h" +#include "base/compiler_specific.h" +#include "ppapi/proxy/tcp_socket_resource_base.h" +#include "ppapi/thunk/ppb_tcp_socket_api.h" + +namespace ppapi { + +enum TCPSocketVersion; + +namespace proxy { + +class PPAPI_PROXY_EXPORT TCPSocketResource : public thunk::PPB_TCPSocket_API, + public TCPSocketResourceBase { + public: + // C-tor used for new sockets created. + TCPSocketResource(Connection connection, + PP_Instance instance, + TCPSocketVersion version); + + virtual ~TCPSocketResource(); + + // PluginResource overrides. + virtual thunk::PPB_TCPSocket_API* AsPPB_TCPSocket_API() OVERRIDE; + + // thunk::PPB_TCPSocket_API implementation. + virtual int32_t Bind(PP_Resource addr, + scoped_refptr<TrackedCallback> callback) OVERRIDE; + virtual int32_t Connect(PP_Resource addr, + scoped_refptr<TrackedCallback> callback) OVERRIDE; + virtual PP_Resource GetLocalAddress() OVERRIDE; + virtual PP_Resource GetRemoteAddress() OVERRIDE; + virtual int32_t Read(char* buffer, + int32_t bytes_to_read, + scoped_refptr<TrackedCallback> callback) OVERRIDE; + virtual int32_t Write(const char* buffer, + int32_t bytes_to_write, + scoped_refptr<TrackedCallback> callback) OVERRIDE; + virtual int32_t Listen(int32_t backlog, + scoped_refptr<TrackedCallback> callback) OVERRIDE; + virtual int32_t Accept(PP_Resource* accepted_tcp_socket, + scoped_refptr<TrackedCallback> callback) OVERRIDE; + virtual void Close() OVERRIDE; + virtual int32_t SetOption(PP_TCPSocket_Option name, + const PP_Var& value, + scoped_refptr<TrackedCallback> callback) OVERRIDE; + + // TCPSocketResourceBase implementation. + virtual PP_Resource CreateAcceptedSocket( + int pending_host_id, + const PP_NetAddress_Private& local_addr, + const PP_NetAddress_Private& remote_addr) OVERRIDE; + + private: + // C-tor used for accepted sockets. + TCPSocketResource(Connection connection, + PP_Instance instance, + int pending_host_id, + const PP_NetAddress_Private& local_addr, + const PP_NetAddress_Private& remote_addr); + + DISALLOW_COPY_AND_ASSIGN(TCPSocketResource); +}; + +} // namespace proxy +} // namespace ppapi + +#endif // PPAPI_PROXY_TCP_SOCKET_RESOURCE_H_ diff --git a/chromium/ppapi/proxy/tcp_socket_resource_base.cc b/chromium/ppapi/proxy/tcp_socket_resource_base.cc new file mode 100644 index 00000000000..6cb9d0b7b51 --- /dev/null +++ b/chromium/ppapi/proxy/tcp_socket_resource_base.cc @@ -0,0 +1,521 @@ +// Copyright 2013 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/proxy/tcp_socket_resource_base.h" + +#include <cstring> + +#include "base/bind.h" +#include "base/logging.h" +#include "ppapi/c/pp_bool.h" +#include "ppapi/c/pp_errors.h" +#include "ppapi/proxy/error_conversion.h" +#include "ppapi/proxy/ppapi_messages.h" +#include "ppapi/shared_impl/ppapi_globals.h" +#include "ppapi/shared_impl/private/ppb_x509_certificate_private_shared.h" +#include "ppapi/shared_impl/socket_option_data.h" +#include "ppapi/shared_impl/var.h" +#include "ppapi/shared_impl/var_tracker.h" +#include "ppapi/thunk/enter.h" +#include "ppapi/thunk/ppb_x509_certificate_private_api.h" + +namespace ppapi { +namespace proxy { + +const int32_t TCPSocketResourceBase::kMaxReadSize = 1024 * 1024; +const int32_t TCPSocketResourceBase::kMaxWriteSize = 1024 * 1024; +const int32_t TCPSocketResourceBase::kMaxSendBufferSize = + 1024 * TCPSocketResourceBase::kMaxWriteSize; +const int32_t TCPSocketResourceBase::kMaxReceiveBufferSize = + 1024 * TCPSocketResourceBase::kMaxReadSize; + +TCPSocketResourceBase::TCPSocketResourceBase(Connection connection, + PP_Instance instance, + TCPSocketVersion version) + : PluginResource(connection, instance), + state_(TCPSocketState::INITIAL), + read_buffer_(NULL), + bytes_to_read_(-1), + accepted_tcp_socket_(NULL), + version_(version) { + local_addr_.size = 0; + memset(local_addr_.data, 0, + arraysize(local_addr_.data) * sizeof(*local_addr_.data)); + remote_addr_.size = 0; + memset(remote_addr_.data, 0, + arraysize(remote_addr_.data) * sizeof(*remote_addr_.data)); +} + +TCPSocketResourceBase::TCPSocketResourceBase( + Connection connection, + PP_Instance instance, + TCPSocketVersion version, + const PP_NetAddress_Private& local_addr, + const PP_NetAddress_Private& remote_addr) + : PluginResource(connection, instance), + state_(TCPSocketState::CONNECTED), + read_buffer_(NULL), + bytes_to_read_(-1), + local_addr_(local_addr), + remote_addr_(remote_addr), + accepted_tcp_socket_(NULL), + version_(version) { +} + +TCPSocketResourceBase::~TCPSocketResourceBase() { + CloseImpl(); +} + +int32_t TCPSocketResourceBase::BindImpl( + const PP_NetAddress_Private* addr, + scoped_refptr<TrackedCallback> callback) { + if (!addr) + return PP_ERROR_BADARGUMENT; + if (state_.IsPending(TCPSocketState::BIND)) + return PP_ERROR_INPROGRESS; + if (!state_.IsValidTransition(TCPSocketState::BIND)) + return PP_ERROR_FAILED; + + bind_callback_ = callback; + state_.SetPendingTransition(TCPSocketState::BIND); + + Call<PpapiPluginMsg_TCPSocket_BindReply>( + BROWSER, + PpapiHostMsg_TCPSocket_Bind(*addr), + base::Bind(&TCPSocketResourceBase::OnPluginMsgBindReply, + base::Unretained(this))); + return PP_OK_COMPLETIONPENDING; +} + +int32_t TCPSocketResourceBase::ConnectImpl( + const char* host, + uint16_t port, + scoped_refptr<TrackedCallback> callback) { + if (!host) + return PP_ERROR_BADARGUMENT; + if (state_.IsPending(TCPSocketState::CONNECT)) + return PP_ERROR_INPROGRESS; + if (!state_.IsValidTransition(TCPSocketState::CONNECT)) + return PP_ERROR_FAILED; + + connect_callback_ = callback; + state_.SetPendingTransition(TCPSocketState::CONNECT); + + Call<PpapiPluginMsg_TCPSocket_ConnectReply>( + BROWSER, + PpapiHostMsg_TCPSocket_Connect(host, port), + base::Bind(&TCPSocketResourceBase::OnPluginMsgConnectReply, + base::Unretained(this))); + return PP_OK_COMPLETIONPENDING; +} + +int32_t TCPSocketResourceBase::ConnectWithNetAddressImpl( + const PP_NetAddress_Private* addr, + scoped_refptr<TrackedCallback> callback) { + if (!addr) + return PP_ERROR_BADARGUMENT; + if (state_.IsPending(TCPSocketState::CONNECT)) + return PP_ERROR_INPROGRESS; + if (!state_.IsValidTransition(TCPSocketState::CONNECT)) + return PP_ERROR_FAILED; + + connect_callback_ = callback; + state_.SetPendingTransition(TCPSocketState::CONNECT); + + Call<PpapiPluginMsg_TCPSocket_ConnectReply>( + BROWSER, + PpapiHostMsg_TCPSocket_ConnectWithNetAddress(*addr), + base::Bind(&TCPSocketResourceBase::OnPluginMsgConnectReply, + base::Unretained(this))); + return PP_OK_COMPLETIONPENDING; +} + +PP_Bool TCPSocketResourceBase::GetLocalAddressImpl( + PP_NetAddress_Private* local_addr) { + if (!state_.IsBound() || !local_addr) + return PP_FALSE; + *local_addr = local_addr_; + return PP_TRUE; +} + +PP_Bool TCPSocketResourceBase::GetRemoteAddressImpl( + PP_NetAddress_Private* remote_addr) { + if (!state_.IsConnected() || !remote_addr) + return PP_FALSE; + *remote_addr = remote_addr_; + return PP_TRUE; +} + +int32_t TCPSocketResourceBase::SSLHandshakeImpl( + const char* server_name, + uint16_t server_port, + scoped_refptr<TrackedCallback> callback) { + if (!server_name) + return PP_ERROR_BADARGUMENT; + + if (state_.IsPending(TCPSocketState::SSL_CONNECT) || + TrackedCallback::IsPending(read_callback_) || + TrackedCallback::IsPending(write_callback_)) { + return PP_ERROR_INPROGRESS; + } + if (!state_.IsValidTransition(TCPSocketState::SSL_CONNECT)) + return PP_ERROR_FAILED; + + ssl_handshake_callback_ = callback; + state_.SetPendingTransition(TCPSocketState::SSL_CONNECT); + + Call<PpapiPluginMsg_TCPSocket_SSLHandshakeReply>( + BROWSER, + PpapiHostMsg_TCPSocket_SSLHandshake(server_name, + server_port, + trusted_certificates_, + untrusted_certificates_), + base::Bind(&TCPSocketResourceBase::OnPluginMsgSSLHandshakeReply, + base::Unretained(this))); + return PP_OK_COMPLETIONPENDING; +} + +PP_Resource TCPSocketResourceBase::GetServerCertificateImpl() { + if (!server_certificate_.get()) + return 0; + return server_certificate_->GetReference(); +} + +PP_Bool TCPSocketResourceBase::AddChainBuildingCertificateImpl( + PP_Resource certificate, + PP_Bool trusted) { + // TODO(raymes): The plumbing for this functionality is implemented but the + // certificates aren't yet used for the connection, so just return false for + // now. + return PP_FALSE; + + thunk::EnterResourceNoLock<thunk::PPB_X509Certificate_Private_API> + enter_cert(certificate, true); + if (enter_cert.failed()) + return PP_FALSE; + + PP_Var der_var = enter_cert.object()->GetField( + PP_X509CERTIFICATE_PRIVATE_RAW); + ArrayBufferVar* der_array_buffer = ArrayBufferVar::FromPPVar(der_var); + PP_Bool success = PP_FALSE; + if (der_array_buffer) { + const char* der_bytes = static_cast<const char*>(der_array_buffer->Map()); + uint32_t der_length = der_array_buffer->ByteLength(); + std::vector<char> der(der_bytes, der_bytes + der_length); + if (PP_ToBool(trusted)) + trusted_certificates_.push_back(der); + else + untrusted_certificates_.push_back(der); + success = PP_TRUE; + } + PpapiGlobals::Get()->GetVarTracker()->ReleaseVar(der_var); + return success; +} + +int32_t TCPSocketResourceBase::ReadImpl( + char* buffer, + int32_t bytes_to_read, + scoped_refptr<TrackedCallback> callback) { + if (!buffer || bytes_to_read <= 0) + return PP_ERROR_BADARGUMENT; + + if (!state_.IsConnected()) + return PP_ERROR_FAILED; + if (TrackedCallback::IsPending(read_callback_) || + state_.IsPending(TCPSocketState::SSL_CONNECT)) + return PP_ERROR_INPROGRESS; + read_buffer_ = buffer; + bytes_to_read_ = std::min(bytes_to_read, kMaxReadSize); + read_callback_ = callback; + + Call<PpapiPluginMsg_TCPSocket_ReadReply>( + BROWSER, + PpapiHostMsg_TCPSocket_Read(bytes_to_read_), + base::Bind(&TCPSocketResourceBase::OnPluginMsgReadReply, + base::Unretained(this))); + return PP_OK_COMPLETIONPENDING; +} + +int32_t TCPSocketResourceBase::WriteImpl( + const char* buffer, + int32_t bytes_to_write, + scoped_refptr<TrackedCallback> callback) { + if (!buffer || bytes_to_write <= 0) + return PP_ERROR_BADARGUMENT; + + if (!state_.IsConnected()) + return PP_ERROR_FAILED; + if (TrackedCallback::IsPending(write_callback_) || + state_.IsPending(TCPSocketState::SSL_CONNECT)) + return PP_ERROR_INPROGRESS; + + if (bytes_to_write > kMaxWriteSize) + bytes_to_write = kMaxWriteSize; + + write_callback_ = callback; + + Call<PpapiPluginMsg_TCPSocket_WriteReply>( + BROWSER, + PpapiHostMsg_TCPSocket_Write(std::string(buffer, bytes_to_write)), + base::Bind(&TCPSocketResourceBase::OnPluginMsgWriteReply, + base::Unretained(this))); + return PP_OK_COMPLETIONPENDING; +} + +int32_t TCPSocketResourceBase::ListenImpl( + int32_t backlog, + scoped_refptr<TrackedCallback> callback) { + if (backlog <= 0) + return PP_ERROR_BADARGUMENT; + if (state_.IsPending(TCPSocketState::LISTEN)) + return PP_ERROR_INPROGRESS; + if (!state_.IsValidTransition(TCPSocketState::LISTEN)) + return PP_ERROR_FAILED; + + listen_callback_ = callback; + state_.SetPendingTransition(TCPSocketState::LISTEN); + + Call<PpapiPluginMsg_TCPSocket_ListenReply>( + BROWSER, + PpapiHostMsg_TCPSocket_Listen(backlog), + base::Bind(&TCPSocketResourceBase::OnPluginMsgListenReply, + base::Unretained(this))); + return PP_OK_COMPLETIONPENDING; +} + +int32_t TCPSocketResourceBase::AcceptImpl( + PP_Resource* accepted_tcp_socket, + scoped_refptr<TrackedCallback> callback) { + if (!accepted_tcp_socket) + return PP_ERROR_BADARGUMENT; + if (TrackedCallback::IsPending(accept_callback_)) + return PP_ERROR_INPROGRESS; + if (state_.state() != TCPSocketState::LISTENING) + return PP_ERROR_FAILED; + + accept_callback_ = callback; + accepted_tcp_socket_ = accepted_tcp_socket; + + Call<PpapiPluginMsg_TCPSocket_AcceptReply>( + BROWSER, + PpapiHostMsg_TCPSocket_Accept(), + base::Bind(&TCPSocketResourceBase::OnPluginMsgAcceptReply, + base::Unretained(this))); + return PP_OK_COMPLETIONPENDING; +} + +void TCPSocketResourceBase::CloseImpl() { + if (state_.state() == TCPSocketState::CLOSED) + return; + + state_.DoTransition(TCPSocketState::CLOSE, true); + + Post(BROWSER, PpapiHostMsg_TCPSocket_Close()); + + PostAbortIfNecessary(&bind_callback_); + PostAbortIfNecessary(&connect_callback_); + PostAbortIfNecessary(&ssl_handshake_callback_); + PostAbortIfNecessary(&read_callback_); + PostAbortIfNecessary(&write_callback_); + PostAbortIfNecessary(&listen_callback_); + PostAbortIfNecessary(&accept_callback_); + read_buffer_ = NULL; + bytes_to_read_ = -1; + server_certificate_ = NULL; + accepted_tcp_socket_ = NULL; +} + +int32_t TCPSocketResourceBase::SetOptionImpl( + PP_TCPSocket_Option name, + const PP_Var& value, + scoped_refptr<TrackedCallback> callback) { + SocketOptionData option_data; + switch (name) { + case PP_TCPSOCKET_OPTION_NO_DELAY: { + if (!state_.IsConnected()) + return PP_ERROR_FAILED; + + if (value.type != PP_VARTYPE_BOOL) + return PP_ERROR_BADARGUMENT; + option_data.SetBool(PP_ToBool(value.value.as_bool)); + break; + } + case PP_TCPSOCKET_OPTION_SEND_BUFFER_SIZE: + case PP_TCPSOCKET_OPTION_RECV_BUFFER_SIZE: { + if (!state_.IsConnected()) + return PP_ERROR_FAILED; + + if (value.type != PP_VARTYPE_INT32) + return PP_ERROR_BADARGUMENT; + option_data.SetInt32(value.value.as_int); + break; + } + default: { + NOTREACHED(); + return PP_ERROR_BADARGUMENT; + } + } + + set_option_callbacks_.push(callback); + + Call<PpapiPluginMsg_TCPSocket_SetOptionReply>( + BROWSER, + PpapiHostMsg_TCPSocket_SetOption(name, option_data), + base::Bind(&TCPSocketResourceBase::OnPluginMsgSetOptionReply, + base::Unretained(this))); + return PP_OK_COMPLETIONPENDING; +} + +void TCPSocketResourceBase::PostAbortIfNecessary( + scoped_refptr<TrackedCallback>* callback) { + if (TrackedCallback::IsPending(*callback)) + (*callback)->PostAbort(); +} + +void TCPSocketResourceBase::OnPluginMsgBindReply( + const ResourceMessageReplyParams& params, + const PP_NetAddress_Private& local_addr) { + // It is possible that CloseImpl() has been called. We don't want to update + // class members in this case. + if (!state_.IsPending(TCPSocketState::BIND)) + return; + + DCHECK(TrackedCallback::IsPending(bind_callback_)); + if (params.result() == PP_OK) { + local_addr_ = local_addr; + state_.CompletePendingTransition(true); + } else { + state_.CompletePendingTransition(false); + } + RunCallback(bind_callback_, params.result()); +} + +void TCPSocketResourceBase::OnPluginMsgConnectReply( + const ResourceMessageReplyParams& params, + const PP_NetAddress_Private& local_addr, + const PP_NetAddress_Private& remote_addr) { + // It is possible that CloseImpl() has been called. We don't want to update + // class members in this case. + if (!state_.IsPending(TCPSocketState::CONNECT)) + return; + + DCHECK(TrackedCallback::IsPending(connect_callback_)); + if (params.result() == PP_OK) { + local_addr_ = local_addr; + remote_addr_ = remote_addr; + state_.CompletePendingTransition(true); + } else { + if (version_ == TCP_SOCKET_VERSION_1_1_OR_ABOVE) { + state_.CompletePendingTransition(false); + } else { + // In order to maintain backward compatibility, allow to connect the + // socket again. + state_ = TCPSocketState(TCPSocketState::INITIAL); + } + } + RunCallback(connect_callback_, params.result()); +} + +void TCPSocketResourceBase::OnPluginMsgSSLHandshakeReply( + const ResourceMessageReplyParams& params, + const PPB_X509Certificate_Fields& certificate_fields) { + // It is possible that CloseImpl() has been called. We don't want to + // update class members in this case. + if (!state_.IsPending(TCPSocketState::SSL_CONNECT)) + return; + + DCHECK(TrackedCallback::IsPending(ssl_handshake_callback_)); + if (params.result() == PP_OK) { + state_.CompletePendingTransition(true); + server_certificate_ = new PPB_X509Certificate_Private_Shared( + OBJECT_IS_PROXY, + pp_instance(), + certificate_fields); + } else { + state_.CompletePendingTransition(false); + } + RunCallback(ssl_handshake_callback_, params.result()); +} + +void TCPSocketResourceBase::OnPluginMsgReadReply( + const ResourceMessageReplyParams& params, + const std::string& data) { + // It is possible that CloseImpl() has been called. We shouldn't access the + // buffer in that case. The user may have released it. + if (!state_.IsConnected() || !TrackedCallback::IsPending(read_callback_) || + !read_buffer_) { + return; + } + + const bool succeeded = params.result() == PP_OK; + if (succeeded) { + CHECK_LE(static_cast<int32_t>(data.size()), bytes_to_read_); + if (!data.empty()) + memmove(read_buffer_, data.c_str(), data.size()); + } + read_buffer_ = NULL; + bytes_to_read_ = -1; + + RunCallback(read_callback_, + succeeded ? static_cast<int32_t>(data.size()) : params.result()); +} + +void TCPSocketResourceBase::OnPluginMsgWriteReply( + const ResourceMessageReplyParams& params) { + if (!state_.IsConnected() || !TrackedCallback::IsPending(write_callback_)) + return; + RunCallback(write_callback_, params.result()); +} + +void TCPSocketResourceBase::OnPluginMsgListenReply( + const ResourceMessageReplyParams& params) { + if (!state_.IsPending(TCPSocketState::LISTEN)) + return; + + DCHECK(TrackedCallback::IsPending(listen_callback_)); + state_.CompletePendingTransition(params.result() == PP_OK); + + RunCallback(listen_callback_, params.result()); +} + +void TCPSocketResourceBase::OnPluginMsgAcceptReply( + const ResourceMessageReplyParams& params, + int pending_host_id, + const PP_NetAddress_Private& local_addr, + const PP_NetAddress_Private& remote_addr) { + // It is possible that CloseImpl() has been called. We shouldn't access the + // output parameter in that case. The user may have released it. + if (state_.state() != TCPSocketState::LISTENING || + !TrackedCallback::IsPending(accept_callback_) || !accepted_tcp_socket_) { + return; + } + + if (params.result() == PP_OK) { + *accepted_tcp_socket_ = CreateAcceptedSocket(pending_host_id, local_addr, + remote_addr); + } + accepted_tcp_socket_ = NULL; + RunCallback(accept_callback_, params.result()); +} + +void TCPSocketResourceBase::OnPluginMsgSetOptionReply( + const ResourceMessageReplyParams& params) { + if (set_option_callbacks_.empty()) { + NOTREACHED(); + return; + } + scoped_refptr<TrackedCallback> callback = set_option_callbacks_.front(); + set_option_callbacks_.pop(); + if (TrackedCallback::IsPending(callback)) + RunCallback(callback, params.result()); +} + +void TCPSocketResourceBase::RunCallback(scoped_refptr<TrackedCallback> callback, + int32_t pp_result) { + callback->Run(ConvertNetworkAPIErrorForCompatibility( + pp_result, version_ == TCP_SOCKET_VERSION_PRIVATE)); +} + +} // namespace ppapi +} // namespace proxy diff --git a/chromium/ppapi/shared_impl/tcp_socket_shared.h b/chromium/ppapi/proxy/tcp_socket_resource_base.h index 20e8e515139..8835ab974b1 100644 --- a/chromium/ppapi/shared_impl/tcp_socket_shared.h +++ b/chromium/ppapi/proxy/tcp_socket_resource_base.h @@ -2,17 +2,20 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#ifndef PPAPI_SHARED_IMPL_TCP_SOCKET_SHARED_H_ -#define PPAPI_SHARED_IMPL_TCP_SOCKET_SHARED_H_ +#ifndef PPAPI_PROXY_TCP_SOCKET_RESOURCE_BASE_H_ +#define PPAPI_PROXY_TCP_SOCKET_RESOURCE_BASE_H_ #include <queue> #include <string> #include <vector> -#include "base/compiler_specific.h" +#include "base/basictypes.h" +#include "base/memory/ref_counted.h" #include "ppapi/c/ppb_tcp_socket.h" #include "ppapi/c/private/ppb_net_address_private.h" -#include "ppapi/shared_impl/resource.h" +#include "ppapi/proxy/plugin_resource.h" +#include "ppapi/proxy/ppapi_proxy_export.h" +#include "ppapi/shared_impl/ppb_tcp_socket_shared.h" #include "ppapi/shared_impl/tracked_callback.h" namespace ppapi { @@ -21,10 +24,11 @@ class PPB_X509Certificate_Fields; class PPB_X509Certificate_Private_Shared; class SocketOptionData; -// This class provides the shared implementation for both PPB_TCPSocket and -// PPB_TCPSocket_Private. -class PPAPI_SHARED_EXPORT TCPSocketShared { +namespace proxy { + +class PPAPI_PROXY_EXPORT TCPSocketResourceBase : public PluginResource { public: + // TODO(yzshen): Move these constants to ppb_tcp_socket_shared. // The maximum number of bytes that each PpapiHostMsg_PPBTCPSocket_Read // message is allowed to request. static const int32_t kMaxReadSize; @@ -43,54 +47,29 @@ class PPAPI_SHARED_EXPORT TCPSocketShared { // such a buffer size. static const int32_t kMaxReceiveBufferSize; - // Notifications on operations completion. - void OnConnectCompleted(int32_t result, - const PP_NetAddress_Private& local_addr, - const PP_NetAddress_Private& remote_addr); - void OnSSLHandshakeCompleted( - bool succeeded, - const PPB_X509Certificate_Fields& certificate_fields); - void OnReadCompleted(int32_t result, const std::string& data); - void OnWriteCompleted(int32_t result); - void OnSetOptionCompleted(int32_t result); - - // Send functions that need to be implemented differently for the - // proxied and non-proxied derived classes. - virtual void SendConnect(const std::string& host, uint16_t port) = 0; - virtual void SendConnectWithNetAddress(const PP_NetAddress_Private& addr) = 0; - virtual void SendSSLHandshake( - const std::string& server_name, - uint16_t server_port, - const std::vector<std::vector<char> >& trusted_certs, - const std::vector<std::vector<char> >& untrusted_certs) = 0; - virtual void SendRead(int32_t bytes_to_read) = 0; - virtual void SendWrite(const std::string& buffer) = 0; - virtual void SendDisconnect() = 0; - virtual void SendSetOption(PP_TCPSocket_Option name, - const SocketOptionData& value) = 0; - - virtual Resource* GetOwnerResource() = 0; - - // Used to override PP_Error codes received from the browser side. - virtual int32_t OverridePPError(int32_t pp_error); - protected: - enum ConnectionState { - // Before a connection is successfully established (including a connect - // request is pending or a previous connect request failed). - BEFORE_CONNECT, - // A connection has been successfully established (including a request of - // initiating SSL is pending). - CONNECTED, - // An SSL connection has been successfully established. - SSL_CONNECTED, - // The connection has been ended. - DISCONNECTED - }; - - TCPSocketShared(ResourceObjectType resource_type, uint32 socket_id); - virtual ~TCPSocketShared(); - + // C-tor used for new sockets. + TCPSocketResourceBase(Connection connection, + PP_Instance instance, + TCPSocketVersion version); + + // C-tor used for already accepted sockets. + TCPSocketResourceBase(Connection connection, + PP_Instance instance, + TCPSocketVersion version, + const PP_NetAddress_Private& local_addr, + const PP_NetAddress_Private& remote_addr); + + virtual ~TCPSocketResourceBase(); + + // Implemented by subclasses to create resources for accepted sockets. + virtual PP_Resource CreateAcceptedSocket( + int pending_host_id, + const PP_NetAddress_Private& local_addr, + const PP_NetAddress_Private& remote_addr) = 0; + + int32_t BindImpl(const PP_NetAddress_Private* addr, + scoped_refptr<TrackedCallback> callback); int32_t ConnectImpl(const char* host, uint16_t port, scoped_refptr<TrackedCallback> callback); @@ -110,26 +89,45 @@ class PPAPI_SHARED_EXPORT TCPSocketShared { int32_t WriteImpl(const char* buffer, int32_t bytes_to_write, scoped_refptr<TrackedCallback> callback); - void DisconnectImpl(); + int32_t ListenImpl(int32_t backlog, scoped_refptr<TrackedCallback> callback); + int32_t AcceptImpl(PP_Resource* accepted_tcp_socket, + scoped_refptr<TrackedCallback> callback); + void CloseImpl(); int32_t SetOptionImpl(PP_TCPSocket_Option name, const PP_Var& value, scoped_refptr<TrackedCallback> callback); - void Init(uint32 socket_id); - bool IsConnected() const; void PostAbortIfNecessary(scoped_refptr<TrackedCallback>* callback); - ResourceObjectType resource_type_; - - uint32 socket_id_; - ConnectionState connection_state_; - + // IPC message handlers. + void OnPluginMsgBindReply(const ResourceMessageReplyParams& params, + const PP_NetAddress_Private& local_addr); + void OnPluginMsgConnectReply(const ResourceMessageReplyParams& params, + const PP_NetAddress_Private& local_addr, + const PP_NetAddress_Private& remote_addr); + void OnPluginMsgSSLHandshakeReply( + const ResourceMessageReplyParams& params, + const PPB_X509Certificate_Fields& certificate_fields); + void OnPluginMsgReadReply(const ResourceMessageReplyParams& params, + const std::string& data); + void OnPluginMsgWriteReply(const ResourceMessageReplyParams& params); + void OnPluginMsgListenReply(const ResourceMessageReplyParams& params); + void OnPluginMsgAcceptReply(const ResourceMessageReplyParams& params, + int pending_host_id, + const PP_NetAddress_Private& local_addr, + const PP_NetAddress_Private& remote_addr); + void OnPluginMsgSetOptionReply(const ResourceMessageReplyParams& params); + + scoped_refptr<TrackedCallback> bind_callback_; scoped_refptr<TrackedCallback> connect_callback_; scoped_refptr<TrackedCallback> ssl_handshake_callback_; scoped_refptr<TrackedCallback> read_callback_; scoped_refptr<TrackedCallback> write_callback_; + scoped_refptr<TrackedCallback> listen_callback_; + scoped_refptr<TrackedCallback> accept_callback_; std::queue<scoped_refptr<TrackedCallback> > set_option_callbacks_; + TCPSocketState state_; char* read_buffer_; int32_t bytes_to_read_; @@ -141,10 +139,17 @@ class PPAPI_SHARED_EXPORT TCPSocketShared { std::vector<std::vector<char> > trusted_certificates_; std::vector<std::vector<char> > untrusted_certificates_; + PP_Resource* accepted_tcp_socket_; + private: - DISALLOW_COPY_AND_ASSIGN(TCPSocketShared); + void RunCallback(scoped_refptr<TrackedCallback> callback, int32_t pp_result); + + TCPSocketVersion version_; + + DISALLOW_COPY_AND_ASSIGN(TCPSocketResourceBase); }; +} // namespace proxy } // namespace ppapi -#endif // PPAPI_SHARED_IMPL_TCP_SOCKET_SHARED_H_ +#endif // PPAPI_PROXY_TCP_SOCKET_RESOURCE_BASE_H_ diff --git a/chromium/ppapi/proxy/udp_socket_resource_base.cc b/chromium/ppapi/proxy/udp_socket_resource_base.cc index 166f2e30856..8ef3835feca 100644 --- a/chromium/ppapi/proxy/udp_socket_resource_base.cc +++ b/chromium/ppapi/proxy/udp_socket_resource_base.cc @@ -11,6 +11,7 @@ #include "ppapi/c/pp_bool.h" #include "ppapi/c/pp_completion_callback.h" #include "ppapi/c/pp_errors.h" +#include "ppapi/proxy/error_conversion.h" #include "ppapi/proxy/ppapi_messages.h" #include "ppapi/shared_impl/socket_option_data.h" #include "ppapi/thunk/enter.h" @@ -19,23 +20,6 @@ namespace ppapi { namespace proxy { -namespace { - -int32_t ConvertPPError(int32_t pp_error, bool private_api) { - // The private API doesn't return network-specific error codes or - // PP_ERROR_NOACCESS. In order to preserve the behavior, we convert those to - // PP_ERROR_FAILED. - if (private_api && - (pp_error <= PP_ERROR_CONNECTION_CLOSED || - pp_error == PP_ERROR_NOACCESS)) { - return PP_ERROR_FAILED; - } - - return pp_error; -} - -} // namespace - const int32_t UDPSocketResourceBase::kMaxReadSize = 1024 * 1024; const int32_t UDPSocketResourceBase::kMaxWriteSize = 1024 * 1024; const int32_t UDPSocketResourceBase::kMaxSendBufferSize = @@ -227,7 +211,7 @@ void UDPSocketResourceBase::OnPluginMsgSetOptionReply( scoped_refptr<TrackedCallback> callback, const ResourceMessageReplyParams& params) { if (TrackedCallback::IsPending(callback)) - callback->Run(ConvertPPError(params.result(), private_api_)); + RunCallback(callback, params.result()); } void UDPSocketResourceBase::OnPluginMsgBindReply( @@ -243,7 +227,7 @@ void UDPSocketResourceBase::OnPluginMsgBindReply( if (params.result() == PP_OK) bound_ = true; bound_addr_ = bound_addr; - bind_callback_->Run(ConvertPPError(params.result(), private_api_)); + RunCallback(bind_callback_, params.result()); } void UDPSocketResourceBase::OnPluginMsgRecvFromReply( @@ -280,9 +264,9 @@ void UDPSocketResourceBase::OnPluginMsgRecvFromReply( recvfrom_addr_ = addr; if (result == PP_OK) - recvfrom_callback_->Run(static_cast<int32_t>(data.size())); + RunCallback(recvfrom_callback_, static_cast<int32_t>(data.size())); else - recvfrom_callback_->Run(ConvertPPError(result, private_api_)); + RunCallback(recvfrom_callback_, result); } void UDPSocketResourceBase::OnPluginMsgSendToReply( @@ -292,9 +276,15 @@ void UDPSocketResourceBase::OnPluginMsgSendToReply( return; if (params.result() == PP_OK) - sendto_callback_->Run(bytes_written); + RunCallback(sendto_callback_, bytes_written); else - sendto_callback_->Run(ConvertPPError(params.result(), private_api_)); + RunCallback(sendto_callback_, params.result()); +} + +void UDPSocketResourceBase::RunCallback(scoped_refptr<TrackedCallback> callback, + int32_t pp_result) { + callback->Run(ConvertNetworkAPIErrorForCompatibility(pp_result, + private_api_)); } } // namespace proxy diff --git a/chromium/ppapi/proxy/udp_socket_resource_base.h b/chromium/ppapi/proxy/udp_socket_resource_base.h index 925475e0e1a..978e774d404 100644 --- a/chromium/ppapi/proxy/udp_socket_resource_base.h +++ b/chromium/ppapi/proxy/udp_socket_resource_base.h @@ -80,6 +80,8 @@ class PPAPI_PROXY_EXPORT UDPSocketResourceBase: public PluginResource { void OnPluginMsgSendToReply(const ResourceMessageReplyParams& params, int32_t bytes_written); + void RunCallback(scoped_refptr<TrackedCallback> callback, int32_t pp_result); + bool private_api_; bool bound_; bool closed_; diff --git a/chromium/ppapi/proxy/url_loader_resource.cc b/chromium/ppapi/proxy/url_loader_resource.cc index 5bbc9372ff2..1ff0a5e1a98 100644 --- a/chromium/ppapi/proxy/url_loader_resource.cc +++ b/chromium/ppapi/proxy/url_loader_resource.cc @@ -9,8 +9,8 @@ #include "ppapi/c/pp_errors.h" #include "ppapi/c/ppb_url_loader.h" #include "ppapi/proxy/dispatch_reply_message.h" +#include "ppapi/proxy/file_ref_resource.h" #include "ppapi/proxy/ppapi_messages.h" -#include "ppapi/proxy/ppb_file_ref_proxy.h" #include "ppapi/proxy/url_request_info_resource.h" #include "ppapi/proxy/url_response_info_resource.h" #include "ppapi/shared_impl/ppapi_globals.h" @@ -158,9 +158,14 @@ int32_t URLLoaderResource::ReadResponseBody( int32_t rv = ValidateCallback(callback); if (rv != PP_OK) return rv; - if (!response_info_.get() || - !response_info_->data().body_as_file_ref.resource.is_null()) + if (!response_info_.get()) return PP_ERROR_FAILED; + + // Fail if we have a valid file ref. + // ReadResponseBody() is for reading to a user-provided buffer. + if (response_info_->data().body_as_file_ref.IsValid()) + return PP_ERROR_FAILED; + if (bytes_to_read <= 0 || !buffer) return PP_ERROR_BADARGUMENT; @@ -186,8 +191,11 @@ int32_t URLLoaderResource::FinishStreamingToFile( int32_t rv = ValidateCallback(callback); if (rv != PP_OK) return rv; - if (!response_info_.get() || - response_info_->data().body_as_file_ref.resource.is_null()) + if (!response_info_.get()) + return PP_ERROR_FAILED; + + // Fail if we do not have a valid file ref. + if (!response_info_->data().body_as_file_ref.IsValid()) return PP_ERROR_FAILED; // We may have already reached EOF. @@ -357,10 +365,10 @@ void URLLoaderResource::RunCallback(int32_t result) { void URLLoaderResource::SaveResponseInfo(const URLResponseInfoData& data) { // Create a proxy resource for the the file ref host resource if needed. PP_Resource body_as_file_ref = 0; - if (!data.body_as_file_ref.resource.is_null()) { - thunk::EnterResourceCreationNoLock enter(pp_instance()); - body_as_file_ref = - enter.functions()->CreateFileRef(data.body_as_file_ref); + if (data.body_as_file_ref.IsValid()) { + body_as_file_ref = FileRefResource::CreateFileRef(connection(), + pp_instance(), + data.body_as_file_ref); } response_info_ = new URLResponseInfoResource( connection(), pp_instance(), data, body_as_file_ref); @@ -389,4 +397,4 @@ size_t URLLoaderResource::FillUserBuffer() { } } // namespace proxy -} // namespace ppapi
\ No newline at end of file +} // namespace ppapi diff --git a/chromium/ppapi/proxy/url_loader_resource.h b/chromium/ppapi/proxy/url_loader_resource.h index 685ccfe1243..f4a80dacd9f 100644 --- a/chromium/ppapi/proxy/url_loader_resource.h +++ b/chromium/ppapi/proxy/url_loader_resource.h @@ -143,4 +143,4 @@ class PPAPI_PROXY_EXPORT URLLoaderResource } // namespace proxy } // namespace ppapi -#endif // PPAPI_PROXY_URL_LOADER_RESOURCE_H_
\ No newline at end of file +#endif // PPAPI_PROXY_URL_LOADER_RESOURCE_H_ diff --git a/chromium/ppapi/proxy/url_response_info_resource.cc b/chromium/ppapi/proxy/url_response_info_resource.cc index 85dae9a1aef..315b4a109d3 100644 --- a/chromium/ppapi/proxy/url_response_info_resource.cc +++ b/chromium/ppapi/proxy/url_response_info_resource.cc @@ -4,7 +4,7 @@ #include "ppapi/proxy/url_response_info_resource.h" -#include "ppapi/proxy/ppb_file_ref_proxy.h" +#include "ppapi/proxy/file_ref_resource.h" #include "ppapi/shared_impl/var.h" #include "ppapi/thunk/enter.h" #include "ppapi/thunk/resource_creation_api.h" diff --git a/chromium/ppapi/shared_impl/DEPS b/chromium/ppapi/shared_impl/DEPS index ca43b897693..30cc66e9a58 100644 --- a/chromium/ppapi/shared_impl/DEPS +++ b/chromium/ppapi/shared_impl/DEPS @@ -9,10 +9,6 @@ include_rules = [ # The untrusted build references the NaCl integrated runtime (IRT). "+native_client/src/untrusted/irt", - # Since this is used by the implementation in /webkit, we don't want it to - # depend on IPC. - "-ipc", - "-ppapi/cpp", "-ppapi/proxy", diff --git a/chromium/ppapi/shared_impl/api_id.h b/chromium/ppapi/shared_impl/api_id.h index 3707719fc6c..c482a029a38 100644 --- a/chromium/ppapi/shared_impl/api_id.h +++ b/chromium/ppapi/shared_impl/api_id.h @@ -35,12 +35,9 @@ enum ApiID { API_ID_PPB_IMAGE_DATA, API_ID_PPB_INSTANCE, API_ID_PPB_INSTANCE_PRIVATE, - API_ID_PPB_NETWORKMANAGER_PRIVATE, API_ID_PPB_OPENGLES2, API_ID_PPB_PDF, API_ID_PPB_SURFACE_3D, - API_ID_PPB_TCPSOCKET, - API_ID_PPB_TCPSOCKET_PRIVATE, API_ID_PPB_TALK, API_ID_PPB_TESTING, API_ID_PPB_TEXT_INPUT, diff --git a/chromium/ppapi/shared_impl/file_ref_create_info.cc b/chromium/ppapi/shared_impl/file_ref_create_info.cc new file mode 100644 index 00000000000..2fd3e13acd9 --- /dev/null +++ b/chromium/ppapi/shared_impl/file_ref_create_info.cc @@ -0,0 +1,50 @@ +// Copyright 2013 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/shared_impl/file_ref_create_info.h" + +#include "base/logging.h" +#include "base/strings/utf_string_conversions.h" +#include "ppapi/c/pp_file_info.h" + +namespace ppapi { + +namespace { + +std::string GetNameForExternalFilePath(const base::FilePath& in_path) { + const base::FilePath::StringType& path = in_path.value(); + size_t pos = path.rfind(base::FilePath::kSeparators[0]); + CHECK(pos != base::FilePath::StringType::npos); +#if defined(OS_WIN) + return base::WideToUTF8(path.substr(pos + 1)); +#elif defined(OS_POSIX) + return path.substr(pos + 1); +#else +#error "Unsupported platform." +#endif +} + +} // namespace + +bool FileRefCreateInfo::IsValid() const { + return file_system_type != PP_FILESYSTEMTYPE_INVALID; +} + +FileRefCreateInfo +MakeExternalFileRefCreateInfo(const base::FilePath& external_path, + const std::string& display_name, + int browser_pending_host_resource_id, + int renderer_pending_host_resource_id) { + FileRefCreateInfo info; + info.file_system_type = PP_FILESYSTEMTYPE_EXTERNAL; + if (!display_name.empty()) + info.display_name = display_name; + else + info.display_name = GetNameForExternalFilePath(external_path); + info.browser_pending_host_resource_id = browser_pending_host_resource_id; + info.renderer_pending_host_resource_id = renderer_pending_host_resource_id; + return info; +} + +} // namespace ppapi diff --git a/chromium/ppapi/shared_impl/file_ref_create_info.h b/chromium/ppapi/shared_impl/file_ref_create_info.h index a3599f7183e..02fc8cc11f7 100644 --- a/chromium/ppapi/shared_impl/file_ref_create_info.h +++ b/chromium/ppapi/shared_impl/file_ref_create_info.h @@ -10,24 +10,42 @@ #include "base/files/file_path.h" #include "ppapi/c/pp_file_info.h" #include "ppapi/c/pp_resource.h" +#include "ppapi/shared_impl/ppapi_shared_export.h" namespace ppapi { // FileRefs are created in a number of places and they include a number of // return values. This struct encapsulates everything in one place. -struct FileRef_CreateInfo { +struct FileRefCreateInfo { + FileRefCreateInfo() : file_system_type(PP_FILESYSTEMTYPE_INVALID), + browser_pending_host_resource_id(0), + renderer_pending_host_resource_id(0), + file_system_plugin_resource(0) { } + + PPAPI_SHARED_EXPORT bool IsValid() const; + PP_FileSystemType file_system_type; std::string internal_path; std::string display_name; // Used when a FileRef is created in the Renderer. - int pending_host_resource_id; + int browser_pending_host_resource_id; + int renderer_pending_host_resource_id; // Since FileRef needs to hold a FileSystem reference, we need to pass the - // resource in this CreateInfo. + // resource in this CreateInfo. This struct doesn't hold any refrence on the + // file_system_plugin_resource. PP_Resource file_system_plugin_resource; }; +// Used in the renderer when sending a FileRefCreateInfo to a plugin for a +// FileRef on an external filesystem. +PPAPI_SHARED_EXPORT FileRefCreateInfo +MakeExternalFileRefCreateInfo(const base::FilePath& external_path, + const std::string& display_name, + int browser_pending_host_resource_id, + int renderer_pending_host_resource_id); + } // namespace ppapi #endif // PPAPI_SHARED_IMPL_FILE_REF_CREATE_INFO_H diff --git a/chromium/ppapi/shared_impl/id_assignment.h b/chromium/ppapi/shared_impl/id_assignment.h index 039e7fed4ca..3bacac3829f 100644 --- a/chromium/ppapi/shared_impl/id_assignment.h +++ b/chromium/ppapi/shared_impl/id_assignment.h @@ -26,7 +26,7 @@ PPAPI_SHARED_EXPORT extern const unsigned int kPPIdTypeBits; extern const int32 kMaxPPId; -// The most significant bits are the type, the rest are the value. +// The least significant bits are the type, the rest are the value. template <typename T> inline T MakeTypedId(T value, PPIdType type) { return (value << kPPIdTypeBits) | static_cast<T>(type); } diff --git a/chromium/ppapi/shared_impl/ppapi_globals.h b/chromium/ppapi/shared_impl/ppapi_globals.h index 66275e50a79..fdc939a2880 100644 --- a/chromium/ppapi/shared_impl/ppapi_globals.h +++ b/chromium/ppapi/shared_impl/ppapi_globals.h @@ -17,7 +17,6 @@ #include "ppapi/shared_impl/ppapi_shared_export.h" namespace base { -class Lock; class MessageLoopProxy; class TaskRunner; } @@ -69,8 +68,6 @@ class PPAPI_SHARED_EXPORT PpapiGlobals { virtual CallbackTracker* GetCallbackTrackerForInstance( PP_Instance instance) = 0; - virtual base::Lock* GetProxyLock() = 0; - // Logs the given string to the JS console. If "source" is empty, the name of // the current module will be used, if it can be determined. virtual void LogWithSource(PP_Instance instance, diff --git a/chromium/ppapi/shared_impl/ppb_audio_config_shared.cc b/chromium/ppapi/shared_impl/ppb_audio_config_shared.cc index 8af3c992154..e727d170ac7 100644 --- a/chromium/ppapi/shared_impl/ppb_audio_config_shared.cc +++ b/chromium/ppapi/shared_impl/ppb_audio_config_shared.cc @@ -2,6 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. +#include "build/build_config.h" #include "ppapi/shared_impl/ppb_audio_config_shared.h" #include "ppapi/thunk/enter.h" #include "ppapi/thunk/ppb_instance_api.h" @@ -81,21 +82,31 @@ uint32_t PPB_AudioConfig_Shared::RecommendSampleFrameCount_1_1( // care when modifying these values as they impact a large number of users. // TODO(dalecurtis): Land jitter test and add documentation for updating this. + // Should track the value reported by XP and ALSA backends. + const uint32_t kHighLatencySampleFrameCount = 2048; +#if defined(OS_CHROMEOS) && defined(ARCH_CPU_ARM_FAMILY) + // TODO(ihf): Remove this once ARM Chromebooks support low latency audio. For + // now we classify them as high latency. See crbug.com/289770. Note that + // Adobe Flash is affected but not HTML5, WebRTC and WebAudio (they are using + // real time threads). + const bool kHighLatencyDevice = true; +#else + const bool kHighLatencyDevice = false; +#endif + // If client is using same sample rate as audio hardware, then recommend a // multiple of the audio hardware's sample frame count. - if (hardware_sample_rate == sample_rate) { + if (!kHighLatencyDevice && hardware_sample_rate == sample_rate) { return CalculateMultipleOfSampleFrameCount( hardware_sample_frame_count, sample_frame_count); } - // Should track the value reported by XP and ALSA backends. - const uint32_t kHighLatencySampleFrameCount = 2048; - // If the hardware requires a high latency buffer or we're at a low sample // rate w/ a buffer that's larger than 10ms, choose the nearest multiple of // the high latency sample frame count. An example of too low and too large // is 16kHz and a sample frame count greater than 160 frames. - if (hardware_sample_frame_count >= kHighLatencySampleFrameCount || + if (kHighLatencyDevice || + hardware_sample_frame_count >= kHighLatencySampleFrameCount || (hardware_sample_rate < 44100 && hardware_sample_frame_count > hardware_sample_rate / 100u)) { return CalculateMultipleOfSampleFrameCount( diff --git a/chromium/ppapi/shared_impl/ppb_audio_config_shared.h b/chromium/ppapi/shared_impl/ppb_audio_config_shared.h index b77a1124804..edc84baeae5 100644 --- a/chromium/ppapi/shared_impl/ppb_audio_config_shared.h +++ b/chromium/ppapi/shared_impl/ppb_audio_config_shared.h @@ -15,6 +15,8 @@ namespace ppapi { const int kBitsPerAudioInputSample = 16; const int kAudioInputChannels = 1; +// TODO(dalecurtis, yzshen): PPAPI shouldn't hard code these values for all +// clients. const int kBitsPerAudioOutputSample = 16; const int kAudioOutputChannels = 2; diff --git a/chromium/ppapi/shared_impl/ppb_audio_shared.cc b/chromium/ppapi/shared_impl/ppb_audio_shared.cc index c52ea555848..25d9011696c 100644 --- a/chromium/ppapi/shared_impl/ppb_audio_shared.cc +++ b/chromium/ppapi/shared_impl/ppb_audio_shared.cc @@ -7,12 +7,9 @@ #include "base/logging.h" #include "media/audio/shared_memory_util.h" #include "ppapi/shared_impl/ppapi_globals.h" +#include "ppapi/shared_impl/ppb_audio_config_shared.h" #include "ppapi/shared_impl/proxy_lock.h" -// Hard coded values from PepperPlatformAudioOutputImpl. -// TODO(dalecurtis): PPAPI shouldn't hard code these values for all clients. -enum { kChannels = 2, kBytesPerSample = 2 }; - namespace ppapi { #if defined(OS_NACL) @@ -22,6 +19,41 @@ PP_ThreadFunctions thread_functions; } #endif // defined(OS_NACL) +AudioCallbackCombined::AudioCallbackCombined() : callback_1_0_(NULL), + callback_(NULL) { +} + +AudioCallbackCombined::AudioCallbackCombined( + PPB_Audio_Callback_1_0 callback_1_0) + : callback_1_0_(callback_1_0), + callback_(NULL) { +} + +AudioCallbackCombined::AudioCallbackCombined(PPB_Audio_Callback callback) + : callback_1_0_(NULL), + callback_(callback) { +} + +AudioCallbackCombined::~AudioCallbackCombined() { +} + +bool AudioCallbackCombined::IsValid() const { + return callback_1_0_ || callback_; +} + +void AudioCallbackCombined::Run(void* sample_buffer, + uint32_t buffer_size_in_bytes, + PP_TimeDelta latency, + void* user_data) const { + if (callback_) { + callback_(sample_buffer, buffer_size_in_bytes, latency, user_data); + } else if (callback_1_0_) { + callback_1_0_(sample_buffer, buffer_size_in_bytes, user_data); + } else { + NOTREACHED(); + } +} + PPB_Audio_Shared::PPB_Audio_Shared() : playing_(false), shared_memory_size_(0), @@ -29,9 +61,9 @@ PPB_Audio_Shared::PPB_Audio_Shared() thread_id_(0), thread_active_(false), #endif - callback_(NULL), user_data_(NULL), - client_buffer_size_bytes_(0) { + client_buffer_size_bytes_(0), + bytes_per_second_(0) { } PPB_Audio_Shared::~PPB_Audio_Shared() { @@ -41,7 +73,7 @@ PPB_Audio_Shared::~PPB_Audio_Shared() { StopThread(); } -void PPB_Audio_Shared::SetCallback(PPB_Audio_Callback callback, +void PPB_Audio_Shared::SetCallback(const AudioCallbackCombined& callback, void* user_data) { callback_ = callback; user_data_ = user_data; @@ -74,10 +106,13 @@ void PPB_Audio_Shared::SetStreamInfo( base::SharedMemoryHandle shared_memory_handle, size_t shared_memory_size, base::SyncSocket::Handle socket_handle, + PP_AudioSampleRate sample_rate, int sample_frame_count) { socket_.reset(new base::CancelableSyncSocket(socket_handle)); shared_memory_.reset(new base::SharedMemory(shared_memory_handle, false)); shared_memory_size_ = shared_memory_size; + bytes_per_second_ = kAudioOutputChannels * (kBitsPerAudioOutputSample / 8) * + sample_rate; if (!shared_memory_->Map( media::TotalSharedMemorySizeInBytes(shared_memory_size_))) { @@ -88,10 +123,11 @@ void PPB_Audio_Shared::SetStreamInfo( "Failed to map shared memory for PPB_Audio_Shared."); } else { audio_bus_ = media::AudioBus::WrapMemory( - kChannels, sample_frame_count, shared_memory_->memory()); + kAudioOutputChannels, sample_frame_count, shared_memory_->memory()); // Setup integer audio buffer for user audio data. client_buffer_size_bytes_ = - audio_bus_->frames() * audio_bus_->channels() * kBytesPerSample; + audio_bus_->frames() * audio_bus_->channels() * + kBitsPerAudioOutputSample / 8; client_buffer_.reset(new uint8_t[client_buffer_size_bytes_]); } @@ -100,8 +136,9 @@ void PPB_Audio_Shared::SetStreamInfo( void PPB_Audio_Shared::StartThread() { // Don't start the thread unless all our state is set up correctly. - if (!playing_ || !callback_ || !socket_.get() || !shared_memory_->memory() || - !audio_bus_.get() || !client_buffer_.get()) + if (!playing_ || !callback_.IsValid() || !socket_.get() || + !shared_memory_->memory() || !audio_bus_.get() || !client_buffer_.get() || + bytes_per_second_ == 0) return; // Clear contents of shm buffer before starting audio thread. This will // prevent a burst of static if for some reason the audio thread doesn't @@ -173,11 +210,15 @@ void PPB_Audio_Shared::Run() { while (sizeof(pending_data) == socket_->Receive(&pending_data, sizeof(pending_data)) && pending_data != media::kPauseMark) { - callback_(client_buffer_.get(), client_buffer_size_bytes_, user_data_); + PP_TimeDelta latency = + static_cast<double>(pending_data) / bytes_per_second_; + callback_.Run(client_buffer_.get(), client_buffer_size_bytes_, latency, + user_data_); // Deinterleave the audio data into the shared memory as float. audio_bus_->FromInterleaved( - client_buffer_.get(), audio_bus_->frames(), kBytesPerSample); + client_buffer_.get(), audio_bus_->frames(), + kBitsPerAudioOutputSample / 8); // Let the host know we are done. // TODO(dalecurtis): Technically this is not the exact size. Due to channel diff --git a/chromium/ppapi/shared_impl/ppb_audio_shared.h b/chromium/ppapi/shared_impl/ppb_audio_shared.h index cccfbfacd23..d7faa5b5b28 100644 --- a/chromium/ppapi/shared_impl/ppb_audio_shared.h +++ b/chromium/ppapi/shared_impl/ppb_audio_shared.h @@ -11,6 +11,7 @@ #include "base/threading/simple_thread.h" #include "media/base/audio_bus.h" #include "ppapi/c/ppb_audio.h" +#include "ppapi/c/ppb_audio_config.h" #include "ppapi/shared_impl/resource.h" #include "ppapi/thunk/ppb_audio_api.h" @@ -20,6 +21,26 @@ namespace ppapi { +class PPAPI_SHARED_EXPORT AudioCallbackCombined { + public: + AudioCallbackCombined(); + explicit AudioCallbackCombined(PPB_Audio_Callback_1_0 callback_1_0); + explicit AudioCallbackCombined(PPB_Audio_Callback callback); + + ~AudioCallbackCombined(); + + bool IsValid() const; + + void Run(void* sample_buffer, + uint32_t buffer_size_in_bytes, + PP_TimeDelta latency, + void* user_data) const; + + private: + PPB_Audio_Callback_1_0 callback_1_0_; + PPB_Audio_Callback callback_; +}; + // Implements the logic to map shared memory and run the audio thread signaled // from the sync socket. Both the proxy and the renderer implementation use // this code. @@ -36,7 +57,7 @@ class PPAPI_SHARED_EXPORT PPB_Audio_Shared // is optional. Without a callback, the thread will not be run. This // non-callback mode is used in the renderer with the proxy, since the proxy // handles the callback entirely within the plugin process. - void SetCallback(PPB_Audio_Callback callback, void* user_data); + void SetCallback(const AudioCallbackCombined& callback, void* user_data); // Configures the current state to be playing or not. The caller is // responsible for ensuring the new state is the opposite of the current one. @@ -55,6 +76,7 @@ class PPAPI_SHARED_EXPORT PPB_Audio_Shared base::SharedMemoryHandle shared_memory_handle, size_t shared_memory_size, base::SyncSocket::Handle socket_handle, + PP_AudioSampleRate sample_rate, int sample_frame_count); #if defined(OS_NACL) @@ -99,7 +121,7 @@ class PPAPI_SHARED_EXPORT PPB_Audio_Shared #endif // Callback to call when audio is ready to accept new samples. - PPB_Audio_Callback callback_; + AudioCallbackCombined callback_; // User data pointer passed verbatim to the callback function. void* user_data_; @@ -111,6 +133,9 @@ class PPAPI_SHARED_EXPORT PPB_Audio_Shared int client_buffer_size_bytes_; scoped_ptr<uint8_t[]> client_buffer_; + // The size (in bytes) of one second of audio data. Used to calculate latency. + size_t bytes_per_second_; + DISALLOW_COPY_AND_ASSIGN(PPB_Audio_Shared); }; diff --git a/chromium/ppapi/shared_impl/ppb_file_ref_shared.cc b/chromium/ppapi/shared_impl/ppb_file_ref_shared.cc deleted file mode 100644 index a47cdb8b9d8..00000000000 --- a/chromium/ppapi/shared_impl/ppb_file_ref_shared.cc +++ /dev/null @@ -1,54 +0,0 @@ -// Copyright (c) 2012 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#include "ppapi/shared_impl/ppb_file_ref_shared.h" - -#include "base/logging.h" -#include "ppapi/shared_impl/var.h" - -namespace ppapi { - -PPB_FileRef_Shared::PPB_FileRef_Shared(ResourceObjectType type, - const PPB_FileRef_CreateInfo& info) - : Resource(type, info.resource), - create_info_(info) { - if (type == OBJECT_IS_IMPL) { - // Resource's constructor assigned a PP_Resource, so we can fill out our - // host resource now. - create_info_.resource = host_resource(); - } -} - -PPB_FileRef_Shared::~PPB_FileRef_Shared() { -} - -thunk::PPB_FileRef_API* PPB_FileRef_Shared::AsPPB_FileRef_API() { - return this; -} - -PP_FileSystemType PPB_FileRef_Shared::GetFileSystemType() const { - return static_cast<PP_FileSystemType>(create_info_.file_system_type); -} - -PP_Var PPB_FileRef_Shared::GetName() const { - if (!name_var_.get()) { - name_var_ = new StringVar(create_info_.name); - } - return name_var_->GetPPVar(); -} - -PP_Var PPB_FileRef_Shared::GetPath() const { - if (create_info_.file_system_type == PP_FILESYSTEMTYPE_EXTERNAL) - return PP_MakeUndefined(); - if (!path_var_.get()) { - path_var_ = new StringVar(create_info_.path); - } - return path_var_->GetPPVar(); -} - -const PPB_FileRef_CreateInfo& PPB_FileRef_Shared::GetCreateInfo() const { - return create_info_; -} - -} // namespace ppapi diff --git a/chromium/ppapi/shared_impl/ppb_file_ref_shared.h b/chromium/ppapi/shared_impl/ppb_file_ref_shared.h deleted file mode 100644 index 5025eb31b7b..00000000000 --- a/chromium/ppapi/shared_impl/ppb_file_ref_shared.h +++ /dev/null @@ -1,70 +0,0 @@ -// Copyright (c) 2012 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#ifndef PPAPI_SHARED_IMPL_PPB_FILE_REF_SHARED_H_ -#define PPAPI_SHARED_IMPL_PPB_FILE_REF_SHARED_H_ - -#include <string> - -#include "base/compiler_specific.h" -#include "ppapi/shared_impl/resource.h" -#include "ppapi/thunk/ppb_file_ref_api.h" - -namespace ppapi { - -class StringVar; - -// FileRefs are created in a number of places and they include a number of -// return values. This struct encapsulates everything in one place. -struct PPB_FileRef_CreateInfo { - PPB_FileRef_CreateInfo() - : file_system_type(PP_FILESYSTEMTYPE_EXTERNAL), - file_system_plugin_resource(0) {} - - ppapi::HostResource resource; - int file_system_type; // One of PP_FileSystemType values. - std::string path; - std::string name; - - // Since FileRef needs to hold a FileSystem reference, we need to pass the - // resource in this CreateInfo. Note that this is a plugin resource as - // FileSystem is already in new design. - PP_Resource file_system_plugin_resource; -}; - -// This class provides the shared implementation of a FileRef. The functions -// that actually "do stuff" like Touch and MakeDirectory are implemented -// differently for the proxied and non-proxied derived classes. -class PPAPI_SHARED_EXPORT PPB_FileRef_Shared - : public Resource, - public thunk::PPB_FileRef_API { - public: - PPB_FileRef_Shared(ResourceObjectType type, - const PPB_FileRef_CreateInfo& info); - virtual ~PPB_FileRef_Shared(); - - // Resource overrides. - virtual thunk::PPB_FileRef_API* AsPPB_FileRef_API() OVERRIDE; - - // PPB_FileRef_API implementation (partial). - virtual PP_FileSystemType GetFileSystemType() const OVERRIDE; - virtual PP_Var GetName() const OVERRIDE; - virtual PP_Var GetPath() const OVERRIDE; - virtual const PPB_FileRef_CreateInfo& GetCreateInfo() const OVERRIDE; - virtual PP_Var GetAbsolutePath() = 0; - - private: - PPB_FileRef_CreateInfo create_info_; - - // Lazily initialized vars created from the create_info_. This is so we can - // return the identical string object every time they're requested. - mutable scoped_refptr<StringVar> name_var_; - mutable scoped_refptr<StringVar> path_var_; - - DISALLOW_IMPLICIT_CONSTRUCTORS(PPB_FileRef_Shared); -}; - -} // namespace ppapi - -#endif // PPAPI_SHARED_IMPL_PPB_FILE_REF_SHARED_H_ diff --git a/chromium/ppapi/shared_impl/ppb_graphics_3d_shared.cc b/chromium/ppapi/shared_impl/ppb_graphics_3d_shared.cc index 948905dfeed..e24a13c4617 100644 --- a/chromium/ppapi/shared_impl/ppb_graphics_3d_shared.cc +++ b/chromium/ppapi/shared_impl/ppb_graphics_3d_shared.cc @@ -135,7 +135,8 @@ bool PPB_Graphics3D_Shared::CreateGLES2Impl( if (!gles2_impl_->Initialize( transfer_buffer_size, kMinTransferBufferSize, - std::max(kMaxTransferBufferSize, transfer_buffer_size))) { + std::max(kMaxTransferBufferSize, transfer_buffer_size), + gpu::gles2::GLES2Implementation::kNoLimit)) { return false; } diff --git a/chromium/ppapi/shared_impl/ppb_image_data_shared.cc b/chromium/ppapi/shared_impl/ppb_image_data_shared.cc index 4001d6f7582..50751a03829 100644 --- a/chromium/ppapi/shared_impl/ppb_image_data_shared.cc +++ b/chromium/ppapi/shared_impl/ppb_image_data_shared.cc @@ -26,12 +26,7 @@ PP_ImageDataFormat PPB_ImageData_Shared::GetNativeImageDataFormat() { NOTIMPLEMENTED(); return PP_IMAGEDATAFORMAT_BGRA_PREMUL; #else - return PP_IMAGEDATAFORMAT_BGRA_PREMUL; if (SK_B32_SHIFT == 0) - return PP_IMAGEDATAFORMAT_BGRA_PREMUL; - else if (SK_R32_SHIFT == 0) - return PP_IMAGEDATAFORMAT_RGBA_PREMUL; - else - return PP_IMAGEDATAFORMAT_BGRA_PREMUL; // Default to something on failure. + return PP_IMAGEDATAFORMAT_BGRA_PREMUL; #endif } diff --git a/chromium/ppapi/shared_impl/ppb_input_event_shared.cc b/chromium/ppapi/shared_impl/ppb_input_event_shared.cc index 4cd918d1618..c837e5aefca 100644 --- a/chromium/ppapi/shared_impl/ppb_input_event_shared.cc +++ b/chromium/ppapi/shared_impl/ppb_input_event_shared.cc @@ -24,6 +24,7 @@ InputEventData::InputEventData() wheel_scroll_by_page(false), key_code(0), usb_key_code(0), + code(), character_text(), composition_target_segment(-1), composition_selection_start(0), @@ -108,6 +109,10 @@ uint32_t PPB_InputEvent_Shared::GetUsbKeyCode() { return data_.usb_key_code; } +PP_Var PPB_InputEvent_Shared::GetCode() { + return StringVar::StringToPPVar(data_.code); +} + uint32_t PPB_InputEvent_Shared::GetIMESegmentNumber() { if (data_.composition_segment_offsets.empty()) return 0; diff --git a/chromium/ppapi/shared_impl/ppb_input_event_shared.h b/chromium/ppapi/shared_impl/ppb_input_event_shared.h index f6bdea6b2c8..623d997ba59 100644 --- a/chromium/ppapi/shared_impl/ppb_input_event_shared.h +++ b/chromium/ppapi/shared_impl/ppb_input_event_shared.h @@ -43,6 +43,10 @@ struct PPAPI_SHARED_EXPORT InputEventData { uint32_t key_code; uint32_t usb_key_code; + // The key event's |code| attribute as defined in: + // http://www.w3.org/TR/uievents/ + std::string code; + std::string character_text; std::vector<uint32_t> composition_segment_offsets; @@ -84,6 +88,7 @@ class PPAPI_SHARED_EXPORT PPB_InputEvent_Shared virtual PP_Var GetCharacterText() OVERRIDE; virtual PP_Bool SetUsbKeyCode(uint32_t usb_key_code) OVERRIDE; virtual uint32_t GetUsbKeyCode() OVERRIDE; + virtual PP_Var GetCode() OVERRIDE; virtual uint32_t GetIMESegmentNumber() OVERRIDE; virtual uint32_t GetIMESegmentOffset(uint32_t index) OVERRIDE; virtual int32_t GetIMETargetSegment() OVERRIDE; diff --git a/chromium/ppapi/shared_impl/ppb_network_list_private_shared.cc b/chromium/ppapi/shared_impl/ppb_network_list_private_shared.cc deleted file mode 100644 index 29874b36cfc..00000000000 --- a/chromium/ppapi/shared_impl/ppb_network_list_private_shared.cc +++ /dev/null @@ -1,109 +0,0 @@ -// Copyright (c) 2012 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#include <algorithm> - -#include "base/logging.h" -#include "ppapi/c/pp_errors.h" -#include "ppapi/shared_impl/ppb_network_list_private_shared.h" -#include "ppapi/shared_impl/var.h" - -namespace ppapi { - -NetworkInfo::NetworkInfo() - : type(PP_NETWORKLIST_UNKNOWN), - state(PP_NETWORKLIST_DOWN), - mtu(0) { -} - -NetworkInfo::~NetworkInfo() { -} - -NetworkListStorage::NetworkListStorage(const NetworkList& list) - : list_(list) { -} - -NetworkListStorage::~NetworkListStorage() { -} - -PPB_NetworkList_Private_Shared::PPB_NetworkList_Private_Shared( - ResourceObjectType type, - PP_Instance instance, - const scoped_refptr<NetworkListStorage>& list) - : Resource(type, instance), - list_(list) { -} - -PPB_NetworkList_Private_Shared::~PPB_NetworkList_Private_Shared() { -} - -// static -PP_Resource PPB_NetworkList_Private_Shared::Create( - ResourceObjectType type, - PP_Instance instance, - const scoped_refptr<NetworkListStorage>& list) { - scoped_refptr<PPB_NetworkList_Private_Shared> object( - new PPB_NetworkList_Private_Shared(type, instance, list)); - return object->GetReference(); -} - -::ppapi::thunk::PPB_NetworkList_API* -PPB_NetworkList_Private_Shared::AsPPB_NetworkList_API() { - return this; -} - -const NetworkList& PPB_NetworkList_Private_Shared::GetNetworkListData() const { - return list_->list(); -} - -uint32_t PPB_NetworkList_Private_Shared::GetCount() { - return static_cast<uint32_t>(list_->list().size()); -} - -PP_Var PPB_NetworkList_Private_Shared::GetName(uint32_t index) { - if (index >= list_->list().size()) - return PP_MakeUndefined(); - return StringVar::StringToPPVar(list_->list().at(index).name); -} - -PP_NetworkListType_Private PPB_NetworkList_Private_Shared::GetType( - uint32_t index) { - if (index >= list_->list().size()) - return PP_NETWORKLIST_UNKNOWN; - return list_->list().at(index).type; -} - -PP_NetworkListState_Private PPB_NetworkList_Private_Shared::GetState( - uint32_t index) { - if (index >= list_->list().size()) - return PP_NETWORKLIST_DOWN; - return list_->list().at(index).state; -} - -int32_t PPB_NetworkList_Private_Shared::GetIpAddresses( - uint32_t index, - struct PP_NetAddress_Private addresses[], - uint32_t count) { - if (index >= list_->list().size()) - return PP_ERROR_FAILED; - count = std::min( - count, static_cast<uint32_t>(list_->list().at(index).addresses.size())); - memcpy(addresses, &(list_->list().at(index).addresses[0]), - sizeof(PP_NetAddress_Private) * count); - return static_cast<int32_t>(list_->list().at(index).addresses.size()); -} - -PP_Var PPB_NetworkList_Private_Shared::GetDisplayName(uint32_t index) { - if (index >= list_->list().size()) - return PP_MakeUndefined(); - return StringVar::StringToPPVar(list_->list().at(index).display_name); -} - -uint32_t PPB_NetworkList_Private_Shared::GetMTU(uint32_t index) { - if (index >= list_->list().size()) - return 0; - return list_->list().at(index).mtu; -} - -} // namespace thunk diff --git a/chromium/ppapi/shared_impl/ppb_network_list_private_shared.h b/chromium/ppapi/shared_impl/ppb_network_list_private_shared.h deleted file mode 100644 index 916cc129d7a..00000000000 --- a/chromium/ppapi/shared_impl/ppb_network_list_private_shared.h +++ /dev/null @@ -1,88 +0,0 @@ -// Copyright (c) 2012 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#ifndef PPAPI_SHARED_IMPL_PPB_NETWORK_LIST_PRIVATE_SHARED_H_ -#define PPAPI_SHARED_IMPL_PPB_NETWORK_LIST_PRIVATE_SHARED_H_ - -#include <string> -#include <vector> - -#include "base/basictypes.h" -#include "base/memory/ref_counted.h" -#include "ppapi/shared_impl/resource.h" -#include "ppapi/thunk/ppb_network_list_api.h" - -namespace ppapi { - -struct PPAPI_SHARED_EXPORT NetworkInfo { - NetworkInfo(); - ~NetworkInfo(); - - std::string name; - PP_NetworkListType_Private type; - PP_NetworkListState_Private state; - std::vector<PP_NetAddress_Private> addresses; - std::string display_name; - int mtu; -}; -typedef std::vector<NetworkInfo> NetworkList; - -// NetworkListStorage is refcounted container for NetworkList. It -// allows sharing of one NetworkList object between multiple -// NetworkList resources. -class PPAPI_SHARED_EXPORT NetworkListStorage - : public base::RefCountedThreadSafe<NetworkListStorage> { - public: - explicit NetworkListStorage(const NetworkList& list); - - const NetworkList& list() { return list_; } - - private: - friend class base::RefCountedThreadSafe<NetworkListStorage>; - ~NetworkListStorage(); - - NetworkList list_; - - DISALLOW_COPY_AND_ASSIGN(NetworkListStorage); -}; - -class PPAPI_SHARED_EXPORT PPB_NetworkList_Private_Shared - : public ::ppapi::Resource, - public ::ppapi::thunk::PPB_NetworkList_API { - public: - static PP_Resource Create(ResourceObjectType type, - PP_Instance instance, - const scoped_refptr<NetworkListStorage>& list); - - virtual ~PPB_NetworkList_Private_Shared(); - - // Resource override. - virtual ::ppapi::thunk::PPB_NetworkList_API* - AsPPB_NetworkList_API() OVERRIDE; - - // PPB_NetworkList_API implementation. - virtual const NetworkList& GetNetworkListData() const OVERRIDE; - virtual uint32_t GetCount() OVERRIDE; - virtual PP_Var GetName(uint32_t index) OVERRIDE; - virtual PP_NetworkListType_Private GetType(uint32_t index) OVERRIDE; - virtual PP_NetworkListState_Private GetState(uint32_t index) OVERRIDE; - virtual int32_t GetIpAddresses(uint32_t index, - PP_NetAddress_Private addresses[], - uint32_t count) OVERRIDE; - virtual PP_Var GetDisplayName(uint32_t index) OVERRIDE; - virtual uint32_t GetMTU(uint32_t index) OVERRIDE; - - private: - PPB_NetworkList_Private_Shared(ResourceObjectType type, - PP_Instance instance, - const scoped_refptr<NetworkListStorage>& list); - - scoped_refptr<NetworkListStorage> list_; - - DISALLOW_COPY_AND_ASSIGN(PPB_NetworkList_Private_Shared); -}; - -} // namespace ppapi - -#endif // PPAPI_SHARED_IMPL_PPB_NETWORK_LIST_PRIVATE_SHARED_H_ diff --git a/chromium/ppapi/shared_impl/ppb_tcp_socket_shared.cc b/chromium/ppapi/shared_impl/ppb_tcp_socket_shared.cc new file mode 100644 index 00000000000..934c573d16d --- /dev/null +++ b/chromium/ppapi/shared_impl/ppb_tcp_socket_shared.cc @@ -0,0 +1,90 @@ +// Copyright 2013 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/shared_impl/ppb_tcp_socket_shared.h" + +#include "base/logging.h" + +namespace ppapi { + +TCPSocketState::TCPSocketState(StateType state) + : state_(state), + pending_transition_(NONE) { + DCHECK(state_ == INITIAL || state_ == CONNECTED); +} + +TCPSocketState::~TCPSocketState() { +} + +void TCPSocketState::SetPendingTransition(TransitionType pending_transition) { + DCHECK(IsValidTransition(pending_transition)); + pending_transition_ = pending_transition; +} + +void TCPSocketState::CompletePendingTransition(bool success) { + switch (pending_transition_) { + case NONE: + NOTREACHED(); + break; + case BIND: + if (success) + state_ = BOUND; + break; + case CONNECT: + state_ = success ? CONNECTED : CLOSED; + break; + case SSL_CONNECT: + state_ = success ? SSL_CONNECTED : CLOSED; + break; + case LISTEN: + if (success) + state_ = LISTENING; + break; + case CLOSE: + state_ = CLOSED; + break; + } + pending_transition_ = NONE; +} + +void TCPSocketState::DoTransition(TransitionType transition, bool success) { + SetPendingTransition(transition); + CompletePendingTransition(success); +} + +bool TCPSocketState::IsValidTransition(TransitionType transition) const { + if (pending_transition_ != NONE && transition != CLOSE) + return false; + + switch (transition) { + case NONE: + return false; + case BIND: + return state_ == INITIAL; + case CONNECT: + return state_ == INITIAL || state_ == BOUND; + case SSL_CONNECT: + return state_ == CONNECTED; + case LISTEN: + return state_ == BOUND; + case CLOSE: + return true; + } + NOTREACHED(); + return false; +} + +bool TCPSocketState::IsPending(TransitionType transition) const { + return pending_transition_ == transition; +} + +bool TCPSocketState::IsConnected() const { + return state_ == CONNECTED || state_ == SSL_CONNECTED; +} + +bool TCPSocketState::IsBound() const { + return state_ != INITIAL && state_ != CLOSED; +} + +} // namespace ppapi diff --git a/chromium/ppapi/shared_impl/ppb_tcp_socket_shared.h b/chromium/ppapi/shared_impl/ppb_tcp_socket_shared.h new file mode 100644 index 00000000000..c723bdc6e18 --- /dev/null +++ b/chromium/ppapi/shared_impl/ppb_tcp_socket_shared.h @@ -0,0 +1,74 @@ +// Copyright 2013 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_SHARED_IMPL_PPB_TCP_SOCKET_SHARED_H_ +#define PPAPI_SHARED_IMPL_PPB_TCP_SOCKET_SHARED_H_ + +#include "ppapi/shared_impl/ppapi_shared_export.h" + +namespace ppapi { + +class PPAPI_SHARED_EXPORT TCPSocketState { + public: + enum StateType { + // The socket hasn't been bound or connected. + INITIAL, + // The socket has been bound. + BOUND, + // A connection has been established. + CONNECTED, + // An SSL connection has been established. + SSL_CONNECTED, + // The socket is listening. + LISTENING, + // The socket has been closed. + CLOSED + }; + + // Transitions that will change the socket state. Please note that + // read/write/accept are not included because they don't change the socket + // state. + enum TransitionType { + NONE, + BIND, + CONNECT, + SSL_CONNECT, + LISTEN, + CLOSE + }; + + explicit TCPSocketState(StateType state); + ~TCPSocketState(); + + StateType state() const { return state_; } + + void SetPendingTransition(TransitionType pending_transition); + void CompletePendingTransition(bool success); + + void DoTransition(TransitionType transition, bool success); + + bool IsValidTransition(TransitionType transition) const; + bool IsPending(TransitionType transition) const; + + bool IsConnected() const; + bool IsBound() const; + + private: + StateType state_; + TransitionType pending_transition_; +}; + +// TCP socket API versions. +enum PPAPI_SHARED_EXPORT TCPSocketVersion { + // PPB_TCPSocket_Private. + TCP_SOCKET_VERSION_PRIVATE, + // PPB_TCPSocket v1.0. + TCP_SOCKET_VERSION_1_0, + // PPB_TCPSocket v1.1 or above. + TCP_SOCKET_VERSION_1_1_OR_ABOVE +}; + +} // namespace ppapi + +#endif // PPAPI_SHARED_IMPL_PPB_TCP_SOCKET_SHARED_H_ diff --git a/chromium/ppapi/shared_impl/private/tcp_socket_private_impl.cc b/chromium/ppapi/shared_impl/private/tcp_socket_private_impl.cc deleted file mode 100644 index 56a3585bd9d..00000000000 --- a/chromium/ppapi/shared_impl/private/tcp_socket_private_impl.cc +++ /dev/null @@ -1,115 +0,0 @@ -// Copyright (c) 2012 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#include "ppapi/shared_impl/private/tcp_socket_private_impl.h" - -#include "base/logging.h" -#include "ppapi/c/pp_errors.h" - -namespace ppapi { - -TCPSocketPrivateImpl::TCPSocketPrivateImpl(PP_Instance instance, - uint32 socket_id) - : Resource(OBJECT_IS_IMPL, instance), - TCPSocketShared(OBJECT_IS_IMPL, socket_id) { -} - -TCPSocketPrivateImpl::TCPSocketPrivateImpl(const HostResource& resource, - uint32 socket_id) - : Resource(OBJECT_IS_PROXY, resource), - TCPSocketShared(OBJECT_IS_PROXY, socket_id) { -} - -TCPSocketPrivateImpl::~TCPSocketPrivateImpl() { -} - -thunk::PPB_TCPSocket_Private_API* -TCPSocketPrivateImpl::AsPPB_TCPSocket_Private_API() { - return this; -} - -int32_t TCPSocketPrivateImpl::Connect(const char* host, - uint16_t port, - scoped_refptr<TrackedCallback> callback) { - return ConnectImpl(host, port, callback); -} - -int32_t TCPSocketPrivateImpl::ConnectWithNetAddress( - const PP_NetAddress_Private* addr, - scoped_refptr<TrackedCallback> callback) { - return ConnectWithNetAddressImpl(addr, callback); -} - -PP_Bool TCPSocketPrivateImpl::GetLocalAddress( - PP_NetAddress_Private* local_addr) { - return GetLocalAddressImpl(local_addr); -} - -PP_Bool TCPSocketPrivateImpl::GetRemoteAddress( - PP_NetAddress_Private* remote_addr) { - return GetRemoteAddressImpl(remote_addr); -} - -int32_t TCPSocketPrivateImpl::SSLHandshake( - const char* server_name, - uint16_t server_port, - scoped_refptr<TrackedCallback> callback) { - return SSLHandshakeImpl(server_name, server_port, callback); -} - -PP_Resource TCPSocketPrivateImpl::GetServerCertificate() { - return GetServerCertificateImpl(); -} - -PP_Bool TCPSocketPrivateImpl::AddChainBuildingCertificate( - PP_Resource certificate, - PP_Bool trusted) { - return AddChainBuildingCertificateImpl(certificate, trusted); -} - -int32_t TCPSocketPrivateImpl::Read(char* buffer, - int32_t bytes_to_read, - scoped_refptr<TrackedCallback> callback) { - return ReadImpl(buffer, bytes_to_read, callback); -} - -int32_t TCPSocketPrivateImpl::Write(const char* buffer, - int32_t bytes_to_write, - scoped_refptr<TrackedCallback> callback) { - return WriteImpl(buffer, bytes_to_write, callback); -} - -void TCPSocketPrivateImpl::Disconnect() { - DisconnectImpl(); -} - -int32_t TCPSocketPrivateImpl::SetOption( - PP_TCPSocketOption_Private name, - const PP_Var& value, - scoped_refptr<TrackedCallback> callback) { - switch (name) { - case PP_TCPSOCKETOPTION_PRIVATE_INVALID: - return PP_ERROR_BADARGUMENT; - case PP_TCPSOCKETOPTION_PRIVATE_NO_DELAY: - return SetOptionImpl(PP_TCPSOCKET_OPTION_NO_DELAY, value, callback); - default: - NOTREACHED(); - return PP_ERROR_BADARGUMENT; - } -} - -Resource* TCPSocketPrivateImpl::GetOwnerResource() { - return this; -} - -int32_t TCPSocketPrivateImpl::OverridePPError(int32_t pp_error) { - // PPB_TCPSocket_Private treats all errors from the browser process as - // PP_ERROR_FAILED. - if (pp_error < 0) - return PP_ERROR_FAILED; - - return pp_error; -} - -} // namespace ppapi diff --git a/chromium/ppapi/shared_impl/proxy_lock.cc b/chromium/ppapi/shared_impl/proxy_lock.cc index 7b9bc9137c1..3c1c3473ae4 100644 --- a/chromium/ppapi/shared_impl/proxy_lock.cc +++ b/chromium/ppapi/shared_impl/proxy_lock.cc @@ -11,14 +11,33 @@ namespace ppapi { +base::LazyInstance<base::Lock>::Leaky + g_proxy_lock = LAZY_INSTANCE_INITIALIZER; + +bool g_disable_locking = false; +base::LazyInstance<base::ThreadLocalBoolean>::Leaky + g_disable_locking_for_thread = LAZY_INSTANCE_INITIALIZER; + // Simple single-thread deadlock detector for the proxy lock. // |true| when the current thread has the lock. base::LazyInstance<base::ThreadLocalBoolean>::Leaky g_proxy_locked_on_thread = LAZY_INSTANCE_INITIALIZER; // static +base::Lock* ProxyLock::Get() { + if (g_disable_locking || g_disable_locking_for_thread.Get().Get()) + return NULL; + return &g_proxy_lock.Get(); +} + +// Functions below should only access the lock via Get to ensure that they don't +// try to use the lock on the host side of the proxy, where locking is +// unnecessary and wrong (because we haven't coded the host side to account for +// locking). + +// static void ProxyLock::Acquire() { - base::Lock* lock(PpapiGlobals::Get()->GetProxyLock()); + base::Lock* lock = Get(); if (lock) { // This thread does not already hold the lock. const bool deadlock = g_proxy_locked_on_thread.Get().Get(); @@ -31,7 +50,7 @@ void ProxyLock::Acquire() { // static void ProxyLock::Release() { - base::Lock* lock(PpapiGlobals::Get()->GetProxyLock()); + base::Lock* lock = Get(); if (lock) { // This thread currently holds the lock. const bool locked = g_proxy_locked_on_thread.Get().Get(); @@ -44,7 +63,7 @@ void ProxyLock::Release() { // static void ProxyLock::AssertAcquired() { - base::Lock* lock(PpapiGlobals::Get()->GetProxyLock()); + base::Lock* lock = Get(); if (lock) { // This thread currently holds the lock. const bool locked = g_proxy_locked_on_thread.Get().Get(); @@ -54,6 +73,25 @@ void ProxyLock::AssertAcquired() { } } +// static +void ProxyLock::DisableLocking() { + // Note, we don't DCHECK that this flag isn't already set, because multiple + // unit tests may run in succession and all set it. + g_disable_locking = true; +} + +// static +void ProxyLock::DisableLockingOnThreadForTest() { + // Note, we don't DCHECK that this flag isn't already set, because multiple + // unit tests may run in succession and all set it. + g_disable_locking_for_thread.Get().Set(true); +} + +// static +void ProxyLock::EnableLockingOnThreadForTest() { + g_disable_locking_for_thread.Get().Set(false); +} + void CallWhileUnlocked(const base::Closure& closure) { ProxyAutoUnlock lock; closure.Run(); diff --git a/chromium/ppapi/shared_impl/proxy_lock.h b/chromium/ppapi/shared_impl/proxy_lock.h index 93524718981..9a81a13baa1 100644 --- a/chromium/ppapi/shared_impl/proxy_lock.h +++ b/chromium/ppapi/shared_impl/proxy_lock.h @@ -16,6 +16,10 @@ namespace base { class Lock; } +namespace content { +class HostGlobals; +} + namespace ppapi { // This is the one lock to rule them all for the ppapi proxy. All PPB interface @@ -28,6 +32,12 @@ namespace ppapi { // tracker, etc. class PPAPI_SHARED_EXPORT ProxyLock { public: + // Return the global ProxyLock. Normally, you should not access this + // directly but instead use ProxyAutoLock or ProxyAutoUnlock. But sometimes + // you need access to the ProxyLock, for example to create a condition + // variable. + static base::Lock* Get(); + // Acquire the proxy lock. If it is currently held by another thread, block // until it is available. If the lock has not been set using the 'Set' method, // this operation does nothing. That is the normal case for the host side; @@ -41,7 +51,23 @@ class PPAPI_SHARED_EXPORT ProxyLock { // process). Does nothing when running in-process (or in the host process). static void AssertAcquired(); + // We have some unit tests where one thread pretends to be the host and one + // pretends to be the plugin. This allows the lock to do nothing on only one + // thread to support these tests. See TwoWayTest for more information. + static void DisableLockingOnThreadForTest(); + + // Enables locking on the current thread. Although locking is enabled by + // default, unit tests that rely on the lock being enabled should *still* + // call this, since a previous test may have disabled locking. + static void EnableLockingOnThreadForTest(); + private: + friend class content::HostGlobals; + // On the host side, we do not lock. This must be called at most once at + // startup, before other threads that may access the ProxyLock have had a + // chance to run. + static void DisableLocking(); + DISALLOW_IMPLICIT_CONSTRUCTORS(ProxyLock); }; @@ -164,6 +190,35 @@ class RunWhileLockedHelper<void ()> { } } + ~RunWhileLockedHelper() { + // Check that the Callback is destroyed on the same thread as where + // CallWhileLocked happened (if CallWhileLocked happened). + DCHECK(thread_checker_.CalledOnValidThread()); + // Here we read callback_ without the lock. This is why the callback must be + // destroyed on the same thread where it runs. There are 2 cases where + // callback_ will be NULL: + // 1) This is the original RunWhileLockedHelper that RunWhileLocked + // created. When it was copied somewhere else (e.g., to a MessageLoop + // queue), callback_ was passed to the new copy, and the original + // RunWhileLockedHelper's callback_ was set to NULL (since scoped_ptrs + // only ever have 1 owner). In this case, we don't want to acquire the + // lock, because we already have it. + // 2) callback_ has already been run via CallWhileLocked. In this case, + // there's no need to acquire the lock, because we don't touch any + // shared data. + if (callback_) { + // If the callback was not run, we still need to have the lock when we + // destroy the callback in case it had a Resource bound to it. This + // ensures that the Resource's destructor is invoked only with the lock + // held. + // + // Also: Resource and Var inherit RefCounted (not ThreadSafeRefCounted), + // and these callbacks need to be usable on any thread. So we need to lock + // when releasing the callback to avoid ref counting races. + ProxyAutoLock lock; + callback_.reset(); + } + } private: scoped_ptr<CallbackType> callback_; @@ -188,7 +243,13 @@ class RunWhileLockedHelper<void (P1)> { temp_callback->Run(p1); } } - + ~RunWhileLockedHelper() { + DCHECK(thread_checker_.CalledOnValidThread()); + if (callback_) { + ProxyAutoLock lock; + callback_.reset(); + } + } private: scoped_ptr<CallbackType> callback_; base::ThreadChecker thread_checker_; @@ -211,7 +272,13 @@ class RunWhileLockedHelper<void (P1, P2)> { temp_callback->Run(p1, p2); } } - + ~RunWhileLockedHelper() { + DCHECK(thread_checker_.CalledOnValidThread()); + if (callback_) { + ProxyAutoLock lock; + callback_.reset(); + } + } private: scoped_ptr<CallbackType> callback_; base::ThreadChecker thread_checker_; @@ -234,7 +301,13 @@ class RunWhileLockedHelper<void (P1, P2, P3)> { temp_callback->Run(p1, p2, p3); } } - + ~RunWhileLockedHelper() { + DCHECK(thread_checker_.CalledOnValidThread()); + if (callback_) { + ProxyAutoLock lock; + callback_.reset(); + } + } private: scoped_ptr<CallbackType> callback_; base::ThreadChecker thread_checker_; @@ -270,8 +343,6 @@ class RunWhileLockedHelper<void (P1, P2, P3)> { // and run there). The callback must be destroyed on the same thread where it // was run (but can be destroyed with or without the proxy lock acquired). Or // (3) destroyed without the proxy lock acquired. -// TODO(dmichael): This won't actually fail until -// https://codereview.chromium.org/19492014/ lands. template <class FunctionType> inline base::Callback<FunctionType> RunWhileLocked(const base::Callback<FunctionType>& callback) { diff --git a/chromium/ppapi/shared_impl/resource.cc b/chromium/ppapi/shared_impl/resource.cc index 4fb9a47be90..2c409618c00 100644 --- a/chromium/ppapi/shared_impl/resource.cc +++ b/chromium/ppapi/shared_impl/resource.cc @@ -75,7 +75,6 @@ void Resource::OnReplyReceived(const proxy::ResourceMessageReplyParams& params, } void Resource::Log(PP_LogLevel level, const std::string& message) { -printf("Log:%s\n", message.c_str()); PpapiGlobals::Get()->LogWithSource(pp_instance(), level, std::string(), message); } diff --git a/chromium/ppapi/shared_impl/resource.h b/chromium/ppapi/shared_impl/resource.h index 3fb09315c7d..15ce142c139 100644 --- a/chromium/ppapi/shared_impl/resource.h +++ b/chromium/ppapi/shared_impl/resource.h @@ -55,9 +55,10 @@ F(PPB_MessageLoop_API) \ F(PPB_NetAddress_API) \ F(PPB_NetworkList_API) \ - F(PPB_NetworkMonitor_Private_API) \ + F(PPB_NetworkMonitor_API) \ F(PPB_NetworkProxy_API) \ F(PPB_PDF_API) \ + F(PPB_PlatformVerification_API) \ F(PPB_Printing_API) \ F(PPB_ResourceArray_API) \ F(PPB_Scrollbar_API) \ diff --git a/chromium/ppapi/shared_impl/resource_tracker.cc b/chromium/ppapi/shared_impl/resource_tracker.cc index 5d7d01ad7ab..36aa2e142dc 100644 --- a/chromium/ppapi/shared_impl/resource_tracker.cc +++ b/chromium/ppapi/shared_impl/resource_tracker.cc @@ -44,6 +44,9 @@ void ResourceTracker::AddRefResource(PP_Resource res) { CheckThreadingPreconditions(); DLOG_IF(ERROR, !CheckIdType(res, PP_ID_TYPE_RESOURCE)) << res << " is not a PP_Resource."; + + DCHECK(CanOperateOnResource(res)); + ResourceMap::iterator i = live_resources_.find(res); if (i == live_resources_.end()) return; @@ -66,6 +69,9 @@ void ResourceTracker::ReleaseResource(PP_Resource res) { CheckThreadingPreconditions(); DLOG_IF(ERROR, !CheckIdType(res, PP_ID_TYPE_RESOURCE)) << res << " is not a PP_Resource."; + + DCHECK(CanOperateOnResource(res)); + ResourceMap::iterator i = live_resources_.find(res); if (i == live_resources_.end()) return; @@ -166,15 +172,23 @@ int ResourceTracker::GetLiveObjectsForInstance(PP_Instance instance) const { return static_cast<int>(found->second->resources.size()); } +void ResourceTracker::UseOddResourceValueInDebugMode() { +#if !defined(NDEBUG) + DCHECK_EQ(0, last_resource_value_); + + ++last_resource_value_; +#endif +} + PP_Resource ResourceTracker::AddResource(Resource* object) { CheckThreadingPreconditions(); // If the plugin manages to create too many resources, don't do crazy stuff. - if (last_resource_value_ == kMaxPPId) + if (last_resource_value_ >= kMaxPPId) return 0; // Allocate an ID. Note there's a rare error condition below that means we // could end up not using |new_id|, but that's harmless. - PP_Resource new_id = MakeTypedId(++last_resource_value_, PP_ID_TYPE_RESOURCE); + PP_Resource new_id = MakeTypedId(GetNextResourceValue(), PP_ID_TYPE_RESOURCE); // Some objects have a 0 instance, meaning they aren't associated with any // instance, so they won't be in |instance_map_|. This is (as of this writing) @@ -229,4 +243,31 @@ void ResourceTracker::LastPluginRefWasDeleted(Resource* object) { object->NotifyLastPluginRefWasDeleted(); } +int32 ResourceTracker::GetNextResourceValue() { +#if defined(NDEBUG) + return ++last_resource_value_; +#else + // In debug mode, the least significant bit indicates which side (renderer + // or plugin process) created the resource. Increment by 2 so it's always the + // same. + last_resource_value_ += 2; + return last_resource_value_; +#endif +} + +bool ResourceTracker::CanOperateOnResource(PP_Resource res) { +#if defined(NDEBUG) + return true; +#else + // The invalid PP_Resource value could appear at both sides. + if (res == 0) + return true; + + // Skipping the type bits, the least significant bit of |res| should be the + // same as that of |last_resource_value_|. + return ((res >> kPPIdTypeBits) & 1) == (last_resource_value_ & 1); +#endif + +} + } // namespace ppapi diff --git a/chromium/ppapi/shared_impl/resource_tracker.h b/chromium/ppapi/shared_impl/resource_tracker.h index 2ba43b8bb5a..ee93376b4ca 100644 --- a/chromium/ppapi/shared_impl/resource_tracker.h +++ b/chromium/ppapi/shared_impl/resource_tracker.h @@ -36,7 +36,14 @@ class PPAPI_SHARED_EXPORT ResourceTracker { // count of the resource is unaffected. Resource* GetResource(PP_Resource res) const; + // Takes a reference on the given resource. + // Do not call this method on on the host side for resources backed by a + // ResourceHost. void AddRefResource(PP_Resource res); + + // Releases a reference on the given resource. + // Do not call this method on on the host side for resources backed by a + // ResourceHost. void ReleaseResource(PP_Resource res); // Releases a reference on the given resource once the message loop returns. @@ -63,6 +70,14 @@ class PPAPI_SHARED_EXPORT ResourceTracker { // plugin side, make sure we have the proxy lock. void CheckThreadingPreconditions() const; + // This method is called by PluginResourceTracker's constructor so that in + // debug mode PP_Resources from the plugin process always have odd values + // (ignoring the type bits), while PP_Resources from the renderer process have + // even values. + // This allows us to check that resource refs aren't added or released on the + // wrong side. + void UseOddResourceValueInDebugMode(); + // Adds the given resource to the tracker, associating it with the instance // stored in the resource object. The new resource ID is returned, and the // resource will have 0 plugin refcount. This is called by the resource @@ -80,6 +95,11 @@ class PPAPI_SHARED_EXPORT ResourceTracker { // cancels pending callbacks for the resource. void LastPluginRefWasDeleted(Resource* object); + int32 GetNextResourceValue(); + + // In debug mode, checks whether |res| comes from the same resource tracker. + bool CanOperateOnResource(PP_Resource res); + typedef std::set<PP_Resource> ResourceSet; struct InstanceData { diff --git a/chromium/ppapi/shared_impl/resource_tracker_unittest.cc b/chromium/ppapi/shared_impl/resource_tracker_unittest.cc index fb00d761d6c..3c7f90167cc 100644 --- a/chromium/ppapi/shared_impl/resource_tracker_unittest.cc +++ b/chromium/ppapi/shared_impl/resource_tracker_unittest.cc @@ -5,6 +5,7 @@ #include "testing/gtest/include/gtest/gtest.h" #include "base/compiler_specific.h" +#include "ppapi/shared_impl/proxy_lock.h" #include "ppapi/shared_impl/resource.h" #include "ppapi/shared_impl/resource_tracker.h" #include "ppapi/shared_impl/test_globals.h" @@ -59,6 +60,7 @@ class ResourceTrackerTest : public testing::Test { // deleted but the object lives on. TEST_F(ResourceTrackerTest, LastPluginRef) { PP_Instance instance = 0x1234567; + ProxyAutoLock lock; resource_tracker().DidCreateInstance(instance); scoped_refptr<MyMockResource> resource(new MyMockResource(instance)); @@ -81,6 +83,7 @@ TEST_F(ResourceTrackerTest, LastPluginRef) { TEST_F(ResourceTrackerTest, InstanceDeletedWithPluginRef) { // Make a resource with one ref held by the plugin, and delete the instance. PP_Instance instance = 0x2345678; + ProxyAutoLock lock; resource_tracker().DidCreateInstance(instance); MyMockResource* resource = new MyMockResource(instance); resource->GetReference(); @@ -99,6 +102,7 @@ TEST_F(ResourceTrackerTest, InstanceDeletedWithPluginRef) { TEST_F(ResourceTrackerTest, InstanceDeletedWithBothRefed) { // Create a new instance. PP_Instance instance = 0x3456789; + ProxyAutoLock lock; // Make a resource with one ref held by the plugin and one ref held by us // (outlives the plugin), and delete the instance. diff --git a/chromium/ppapi/shared_impl/resource_var.cc b/chromium/ppapi/shared_impl/resource_var.cc new file mode 100644 index 00000000000..3e34c381f70 --- /dev/null +++ b/chromium/ppapi/shared_impl/resource_var.cc @@ -0,0 +1,39 @@ +// Copyright 2013 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/shared_impl/resource_var.h" + +#include "ppapi/shared_impl/ppapi_globals.h" +#include "ppapi/shared_impl/var_tracker.h" + +namespace ppapi { + +const IPC::Message* ResourceVar::GetCreationMessage() const { + return NULL; +} + +ResourceVar* ResourceVar::AsResourceVar() { + return this; +} + +PP_VarType ResourceVar::GetType() const { + return PP_VARTYPE_RESOURCE; +} + +// static +ResourceVar* ResourceVar::FromPPVar(PP_Var var) { + if (var.type != PP_VARTYPE_RESOURCE) + return NULL; + scoped_refptr<Var> var_object( + PpapiGlobals::Get()->GetVarTracker()->GetVar(var)); + if (!var_object.get()) + return NULL; + return var_object->AsResourceVar(); +} + +ResourceVar::ResourceVar() {} + +ResourceVar::~ResourceVar() {} + +} // namespace ppapi diff --git a/chromium/ppapi/shared_impl/resource_var.h b/chromium/ppapi/shared_impl/resource_var.h new file mode 100644 index 00000000000..0b8bab2354c --- /dev/null +++ b/chromium/ppapi/shared_impl/resource_var.h @@ -0,0 +1,56 @@ +// Copyright 2013 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_SHARED_IMPL_RESOURCE_VAR_H_ +#define PPAPI_SHARED_IMPL_RESOURCE_VAR_H_ + +#include "ppapi/c/pp_resource.h" +#include "ppapi/c/pp_var.h" +#include "ppapi/shared_impl/ppapi_shared_export.h" +#include "ppapi/shared_impl/var.h" + +namespace IPC { +class Message; +} + +namespace ppapi { + +// Represents a resource Var. +class PPAPI_SHARED_EXPORT ResourceVar : public Var { + public: + // Gets the resource ID associated with this var. + // This is 0 if a resource is still pending (only possible on the host side). + // NOTE: This can return a PP_Resource with a reference count of 0 on the + // plugin side. It should be AddRef'd if the resource is passed to the user. + virtual PP_Resource GetPPResource() const = 0; + + // Gets the message for creating a plugin-side resource. Returns NULL if the + // message is empty (which is always true on the plugin side). + virtual const IPC::Message* GetCreationMessage() const; + + // Determines whether this is a pending resource. + // This is true if, on the host side, the there is a creation_message and no + // PP_Resource. + virtual bool IsPending() const = 0; + + // Var override. + virtual ResourceVar* AsResourceVar() OVERRIDE; + virtual PP_VarType GetType() const OVERRIDE; + + // Helper function that converts a PP_Var to a ResourceVar. This will + // return NULL if the PP_Var is not of Resource type. + static ResourceVar* FromPPVar(PP_Var var); + + protected: + ResourceVar(); + + virtual ~ResourceVar(); + + private: + DISALLOW_COPY_AND_ASSIGN(ResourceVar); +}; + +} // namespace ppapi + +#endif // PPAPI_SHARED_IMPL_RESOURCE_VAR_H_ diff --git a/chromium/ppapi/shared_impl/tcp_socket_shared.cc b/chromium/ppapi/shared_impl/tcp_socket_shared.cc deleted file mode 100644 index ae23b28f426..00000000000 --- a/chromium/ppapi/shared_impl/tcp_socket_shared.cc +++ /dev/null @@ -1,372 +0,0 @@ -// Copyright 2013 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/shared_impl/tcp_socket_shared.h" - -#include <string.h> - -#include <algorithm> - -#include "base/basictypes.h" -#include "base/bind.h" -#include "base/logging.h" -#include "ppapi/c/pp_bool.h" -#include "ppapi/c/pp_completion_callback.h" -#include "ppapi/c/pp_errors.h" -#include "ppapi/shared_impl/ppapi_globals.h" -#include "ppapi/shared_impl/private/ppb_x509_certificate_private_shared.h" -#include "ppapi/shared_impl/socket_option_data.h" -#include "ppapi/shared_impl/var_tracker.h" -#include "ppapi/shared_impl/var.h" -#include "ppapi/thunk/enter.h" -#include "ppapi/thunk/ppb_x509_certificate_private_api.h" - -namespace ppapi { - -const int32_t TCPSocketShared::kMaxReadSize = 1024 * 1024; -const int32_t TCPSocketShared::kMaxWriteSize = 1024 * 1024; -const int32_t TCPSocketShared::kMaxSendBufferSize = - 1024 * TCPSocketShared::kMaxWriteSize; -const int32_t TCPSocketShared::kMaxReceiveBufferSize = - 1024 * TCPSocketShared::kMaxReadSize; - -TCPSocketShared::TCPSocketShared(ResourceObjectType resource_type, - uint32 socket_id) - : resource_type_(resource_type) { - Init(socket_id); -} - -TCPSocketShared::~TCPSocketShared() { -} - -void TCPSocketShared::OnConnectCompleted( - int32_t result, - const PP_NetAddress_Private& local_addr, - const PP_NetAddress_Private& remote_addr) { - // It is possible that |connect_callback_| is pending while - // |connection_state_| is not BEFORE_CONNECT: DisconnectImpl() has been - // called, but a ConnectCompleted notification came earlier than the task to - // abort |connect_callback_|. We don't want to update |connection_state_| or - // other members in that case. - if (connection_state_ != BEFORE_CONNECT || - !TrackedCallback::IsPending(connect_callback_)) { - return; - } - - result = OverridePPError(result); - if (result == PP_OK) { - local_addr_ = local_addr; - remote_addr_ = remote_addr; - connection_state_ = CONNECTED; - } - connect_callback_->Run(result); -} - -void TCPSocketShared::OnSSLHandshakeCompleted( - bool succeeded, - const PPB_X509Certificate_Fields& certificate_fields) { - // It is possible that |ssl_handshake_callback_| is pending while - // |connection_state_| is not CONNECT: DisconnectImpl() has been - // called, but a SSLHandshakeCompleted notification came earlier than the task - // to abort |ssl_handshake_callback_|. We don't want to update - // |connection_state_| or other members in that case. - if (connection_state_ != CONNECTED || - !TrackedCallback::IsPending(ssl_handshake_callback_)) { - return; - } - - if (succeeded) { - connection_state_ = SSL_CONNECTED; - server_certificate_ = new PPB_X509Certificate_Private_Shared( - resource_type_, - GetOwnerResource()->pp_instance(), - certificate_fields); - ssl_handshake_callback_->Run(PP_OK); - } else { - // The resource might be released in the callback so we need to hold - // a reference so we can Disconnect() first. - GetOwnerResource()->AddRef(); - ssl_handshake_callback_->Run(PP_ERROR_FAILED); - DisconnectImpl(); - GetOwnerResource()->Release(); - } -} - -void TCPSocketShared::OnReadCompleted(int32_t result, - const std::string& data) { - // It is possible that |read_callback_| is pending while |read_buffer_| is - // NULL: DisconnectImpl() has been called, but a ReadCompleted notification - // came earlier than the task to abort |read_callback_|. We shouldn't access - // the buffer in that case. The user may have released it. - if (!TrackedCallback::IsPending(read_callback_) || !read_buffer_) - return; - - result = OverridePPError(result); - bool succeeded = result == PP_OK; - if (succeeded) { - CHECK_LE(static_cast<int32_t>(data.size()), bytes_to_read_); - if (!data.empty()) - memcpy(read_buffer_, data.c_str(), data.size()); - } - read_buffer_ = NULL; - bytes_to_read_ = -1; - - read_callback_->Run( - succeeded ? static_cast<int32_t>(data.size()) : result); -} - -void TCPSocketShared::OnWriteCompleted(int32_t result) { - if (!TrackedCallback::IsPending(write_callback_)) - return; - - result = OverridePPError(result); - write_callback_->Run(result); -} - -void TCPSocketShared::OnSetOptionCompleted(int32_t result) { - if (set_option_callbacks_.empty()) { - NOTREACHED(); - return; - } - - result = OverridePPError(result); - scoped_refptr<TrackedCallback> callback = set_option_callbacks_.front(); - set_option_callbacks_.pop(); - - if (TrackedCallback::IsPending(callback)) - callback->Run(result); -} - -int32_t TCPSocketShared::OverridePPError(int32_t pp_error) { - return pp_error; -} - -int32_t TCPSocketShared::ConnectImpl(const char* host, - uint16_t port, - scoped_refptr<TrackedCallback> callback) { - if (!host) - return PP_ERROR_BADARGUMENT; - if (connection_state_ != BEFORE_CONNECT) - return PP_ERROR_FAILED; - if (TrackedCallback::IsPending(connect_callback_)) - return PP_ERROR_INPROGRESS; // Can only have one pending request. - - connect_callback_ = callback; - // Send the request, the browser will call us back via ConnectACK. - SendConnect(host, port); - return PP_OK_COMPLETIONPENDING; -} - -int32_t TCPSocketShared::ConnectWithNetAddressImpl( - const PP_NetAddress_Private* addr, - scoped_refptr<TrackedCallback> callback) { - if (!addr) - return PP_ERROR_BADARGUMENT; - if (connection_state_ != BEFORE_CONNECT) - return PP_ERROR_FAILED; - if (TrackedCallback::IsPending(connect_callback_)) - return PP_ERROR_INPROGRESS; // Can only have one pending request. - - connect_callback_ = callback; - // Send the request, the browser will call us back via ConnectACK. - SendConnectWithNetAddress(*addr); - return PP_OK_COMPLETIONPENDING; -} - -PP_Bool TCPSocketShared::GetLocalAddressImpl( - PP_NetAddress_Private* local_addr) { - if (!IsConnected() || !local_addr) - return PP_FALSE; - - *local_addr = local_addr_; - return PP_TRUE; -} - -PP_Bool TCPSocketShared::GetRemoteAddressImpl( - PP_NetAddress_Private* remote_addr) { - if (!IsConnected() || !remote_addr) - return PP_FALSE; - - *remote_addr = remote_addr_; - return PP_TRUE; -} - -int32_t TCPSocketShared::SSLHandshakeImpl( - const char* server_name, - uint16_t server_port, - scoped_refptr<TrackedCallback> callback) { - if (!server_name) - return PP_ERROR_BADARGUMENT; - - if (connection_state_ != CONNECTED) - return PP_ERROR_FAILED; - if (TrackedCallback::IsPending(ssl_handshake_callback_) || - TrackedCallback::IsPending(read_callback_) || - TrackedCallback::IsPending(write_callback_)) - return PP_ERROR_INPROGRESS; - - ssl_handshake_callback_ = callback; - - // Send the request, the browser will call us back via SSLHandshakeACK. - SendSSLHandshake(server_name, server_port, trusted_certificates_, - untrusted_certificates_); - return PP_OK_COMPLETIONPENDING; -} - -PP_Resource TCPSocketShared::GetServerCertificateImpl() { - if (!server_certificate_.get()) - return 0; - return server_certificate_->GetReference(); -} - -PP_Bool TCPSocketShared::AddChainBuildingCertificateImpl( - PP_Resource certificate, - PP_Bool trusted) { - // TODO(raymes): The plumbing for this functionality is implemented but the - // certificates aren't yet used for the connection, so just return false for - // now. - return PP_FALSE; - - thunk::EnterResourceNoLock<thunk::PPB_X509Certificate_Private_API> - enter_cert(certificate, true); - if (enter_cert.failed()) - return PP_FALSE; - - PP_Var der_var = enter_cert.object()->GetField( - PP_X509CERTIFICATE_PRIVATE_RAW); - ArrayBufferVar* der_array_buffer = ArrayBufferVar::FromPPVar(der_var); - PP_Bool success = PP_FALSE; - if (der_array_buffer) { - const char* der_bytes = static_cast<const char*>(der_array_buffer->Map()); - uint32_t der_length = der_array_buffer->ByteLength(); - std::vector<char> der(der_bytes, der_bytes + der_length); - if (PP_ToBool(trusted)) - trusted_certificates_.push_back(der); - else - untrusted_certificates_.push_back(der); - success = PP_TRUE; - } - PpapiGlobals::Get()->GetVarTracker()->ReleaseVar(der_var); - return success; -} - -int32_t TCPSocketShared::ReadImpl(char* buffer, - int32_t bytes_to_read, - scoped_refptr<TrackedCallback> callback) { - if (!buffer || bytes_to_read <= 0) - return PP_ERROR_BADARGUMENT; - - if (!IsConnected()) - return PP_ERROR_FAILED; - if (TrackedCallback::IsPending(read_callback_) || - TrackedCallback::IsPending(ssl_handshake_callback_)) - return PP_ERROR_INPROGRESS; - read_buffer_ = buffer; - bytes_to_read_ = std::min(bytes_to_read, kMaxReadSize); - read_callback_ = callback; - - // Send the request, the browser will call us back via ReadACK. - SendRead(bytes_to_read_); - return PP_OK_COMPLETIONPENDING; -} - -int32_t TCPSocketShared::WriteImpl(const char* buffer, - int32_t bytes_to_write, - scoped_refptr<TrackedCallback> callback) { - if (!buffer || bytes_to_write <= 0) - return PP_ERROR_BADARGUMENT; - - if (!IsConnected()) - return PP_ERROR_FAILED; - if (TrackedCallback::IsPending(write_callback_) || - TrackedCallback::IsPending(ssl_handshake_callback_)) - return PP_ERROR_INPROGRESS; - - if (bytes_to_write > kMaxWriteSize) - bytes_to_write = kMaxWriteSize; - - write_callback_ = callback; - - // Send the request, the browser will call us back via WriteACK. - SendWrite(std::string(buffer, bytes_to_write)); - return PP_OK_COMPLETIONPENDING; -} - -void TCPSocketShared::DisconnectImpl() { - if (connection_state_ == DISCONNECTED) - return; - - connection_state_ = DISCONNECTED; - - SendDisconnect(); - socket_id_ = 0; - - PostAbortIfNecessary(&connect_callback_); - PostAbortIfNecessary(&ssl_handshake_callback_); - PostAbortIfNecessary(&read_callback_); - PostAbortIfNecessary(&write_callback_); - read_buffer_ = NULL; - bytes_to_read_ = -1; - server_certificate_ = NULL; -} - -int32_t TCPSocketShared::SetOptionImpl( - PP_TCPSocket_Option name, - const PP_Var& value, - scoped_refptr<TrackedCallback> callback) { - if (!IsConnected()) - return PP_ERROR_FAILED; - - SocketOptionData option_data; - switch (name) { - case PP_TCPSOCKET_OPTION_NO_DELAY: { - if (value.type != PP_VARTYPE_BOOL) - return PP_ERROR_BADARGUMENT; - option_data.SetBool(PP_ToBool(value.value.as_bool)); - break; - } - case PP_TCPSOCKET_OPTION_SEND_BUFFER_SIZE: - case PP_TCPSOCKET_OPTION_RECV_BUFFER_SIZE: { - if (value.type != PP_VARTYPE_INT32) - return PP_ERROR_BADARGUMENT; - option_data.SetInt32(value.value.as_int); - break; - } - default: { - NOTREACHED(); - return PP_ERROR_BADARGUMENT; - } - } - - set_option_callbacks_.push(callback); - SendSetOption(name, option_data); - return PP_OK_COMPLETIONPENDING; -} - -void TCPSocketShared::Init(uint32 socket_id) { - DCHECK(socket_id != 0); - socket_id_ = socket_id; - connection_state_ = BEFORE_CONNECT; - read_buffer_ = NULL; - bytes_to_read_ = -1; - - local_addr_.size = 0; - memset(local_addr_.data, 0, - arraysize(local_addr_.data) * sizeof(*local_addr_.data)); - remote_addr_.size = 0; - memset(remote_addr_.data, 0, - arraysize(remote_addr_.data) * sizeof(*remote_addr_.data)); -} - -bool TCPSocketShared::IsConnected() const { - return connection_state_ == CONNECTED || connection_state_ == SSL_CONNECTED; -} - -void TCPSocketShared::PostAbortIfNecessary( - scoped_refptr<TrackedCallback>* callback) { - if (TrackedCallback::IsPending(*callback)) - (*callback)->PostAbort(); -} - -} // namespace ppapi diff --git a/chromium/ppapi/shared_impl/test_globals.cc b/chromium/ppapi/shared_impl/test_globals.cc index 133b9437dd0..f4d58cfd8d0 100644 --- a/chromium/ppapi/shared_impl/test_globals.cc +++ b/chromium/ppapi/shared_impl/test_globals.cc @@ -55,10 +55,6 @@ std::string TestGlobals::GetCmdLine() { void TestGlobals::PreCacheFontForFlash(const void* /* logfontw */) { } -base::Lock* TestGlobals::GetProxyLock() { - return NULL; -} - void TestGlobals::LogWithSource(PP_Instance instance, PP_LogLevel level, const std::string& source, diff --git a/chromium/ppapi/shared_impl/test_globals.h b/chromium/ppapi/shared_impl/test_globals.h index 082af34b26c..2a0ece302a1 100644 --- a/chromium/ppapi/shared_impl/test_globals.h +++ b/chromium/ppapi/shared_impl/test_globals.h @@ -18,6 +18,9 @@ class TestVarTracker : public VarTracker { public: TestVarTracker() : VarTracker(THREAD_SAFE) {} virtual ~TestVarTracker() {} + virtual ResourceVar* MakeResourceVar(PP_Resource pp_resource) OVERRIDE { + return NULL; + } virtual ArrayBufferVar* CreateArrayBuffer(uint32 size_in_bytes) OVERRIDE { return NULL; } @@ -61,7 +64,6 @@ class TestGlobals : public PpapiGlobals { virtual PP_Module GetModuleForInstance(PP_Instance instance) OVERRIDE; virtual std::string GetCmdLine() OVERRIDE; virtual void PreCacheFontForFlash(const void* logfontw) OVERRIDE; - virtual base::Lock* GetProxyLock() OVERRIDE; virtual void LogWithSource(PP_Instance instance, PP_LogLevel level, const std::string& source, diff --git a/chromium/ppapi/shared_impl/tracked_callback.cc b/chromium/ppapi/shared_impl/tracked_callback.cc index 1a3ac21adb5..f3b8bb9820d 100644 --- a/chromium/ppapi/shared_impl/tracked_callback.cc +++ b/chromium/ppapi/shared_impl/tracked_callback.cc @@ -62,7 +62,7 @@ TrackedCallback::TrackedCallback( tracker_->Add(make_scoped_refptr(this)); } - base::Lock* proxy_lock = PpapiGlobals::Get()->GetProxyLock(); + base::Lock* proxy_lock = ProxyLock::Get(); if (proxy_lock) { // If the proxy_lock is valid, we're running out-of-process, and locking // is enabled. @@ -165,16 +165,22 @@ void TrackedCallback::PostRun(int32_t result) { // should never try to PostRun more than once otherwise. DCHECK(result == PP_ERROR_ABORTED || !is_scheduled_); - base::Closure callback_closure( - RunWhileLocked(base::Bind(&TrackedCallback::Run, this, result))); - if (!target_loop_.get()) { - // We must be running in-process and on the main thread (the Enter - // classes protect against having a null target_loop_ otherwise). - DCHECK(IsMainThread()); - DCHECK(PpapiGlobals::Get()->IsHostGlobals()); - base::MessageLoop::current()->PostTask(FROM_HERE, callback_closure); + if (is_blocking()) { + // We might not have a MessageLoop to post to, so we must call Run() + // directly. + Run(result); } else { - target_loop_->PostClosure(FROM_HERE, callback_closure, 0); + base::Closure callback_closure( + RunWhileLocked(base::Bind(&TrackedCallback::Run, this, result))); + if (target_loop_) { + target_loop_->PostClosure(FROM_HERE, callback_closure, 0); + } else { + // We must be running in-process and on the main thread (the Enter + // classes protect against having a null target_loop_ otherwise). + DCHECK(IsMainThread()); + DCHECK(PpapiGlobals::Get()->IsHostGlobals()); + base::MessageLoop::current()->PostTask(FROM_HERE, callback_closure); + } } is_scheduled_ = true; } diff --git a/chromium/ppapi/shared_impl/tracked_callback_unittest.cc b/chromium/ppapi/shared_impl/tracked_callback_unittest.cc index 9ceb96e7cf7..55db0aaf93e 100644 --- a/chromium/ppapi/shared_impl/tracked_callback_unittest.cc +++ b/chromium/ppapi/shared_impl/tracked_callback_unittest.cc @@ -8,6 +8,7 @@ #include "ppapi/c/pp_completion_callback.h" #include "ppapi/c/pp_errors.h" #include "ppapi/shared_impl/callback_tracker.h" +#include "ppapi/shared_impl/proxy_lock.h" #include "ppapi/shared_impl/resource.h" #include "ppapi/shared_impl/resource_tracker.h" #include "ppapi/shared_impl/test_globals.h" @@ -26,9 +27,12 @@ class TrackedCallbackTest : public testing::Test { PP_Instance pp_instance() const { return pp_instance_; } virtual void SetUp() OVERRIDE { + ProxyLock::EnableLockingOnThreadForTest(); + ProxyAutoLock lock; globals_.GetResourceTracker()->DidCreateInstance(pp_instance_); } virtual void TearDown() OVERRIDE { + ProxyAutoLock lock; globals_.GetResourceTracker()->DidDeleteInstance(pp_instance_); } @@ -89,6 +93,7 @@ class CallbackShutdownTest : public TrackedCallbackTest { // Tests that callbacks are properly aborted on module shutdown. TEST_F(CallbackShutdownTest, AbortOnShutdown) { + ProxyAutoLock lock; scoped_refptr<Resource> resource(new Resource(OBJECT_IS_IMPL, pp_instance())); // Set up case (1) (see above). @@ -250,6 +255,7 @@ class CallbackMockResource : public Resource { // Test that callbacks get aborted on the last resource unref. TEST_F(CallbackResourceTest, AbortOnNoRef) { + ProxyAutoLock lock; ResourceTracker* resource_tracker = PpapiGlobals::Get()->GetResourceTracker(); @@ -273,23 +279,33 @@ TEST_F(CallbackResourceTest, AbortOnNoRef) { // Kill resource #1, spin the message loop to run posted calls, and check that // things are in the expected states. resource_tracker->ReleaseResource(resource_1_id); - base::MessageLoop::current()->RunUntilIdle(); + { + ProxyAutoUnlock unlock; + base::MessageLoop::current()->RunUntilIdle(); + } resource_1->CheckFinalState(); resource_2->CheckIntermediateState(); // Kill resource #2. resource_tracker->ReleaseResource(resource_2_id); - base::MessageLoop::current()->RunUntilIdle(); + { + ProxyAutoUnlock unlock; + base::MessageLoop::current()->RunUntilIdle(); + } resource_1->CheckFinalState(); resource_2->CheckFinalState(); // This shouldn't be needed, but make sure there are no stranded tasks. - base::MessageLoop::current()->RunUntilIdle(); + { + ProxyAutoUnlock unlock; + base::MessageLoop::current()->RunUntilIdle(); + } } // Test that "resurrecting" a resource (getting a new ID for a |Resource|) // doesn't resurrect callbacks. TEST_F(CallbackResourceTest, Resurrection) { + ProxyAutoLock lock; ResourceTracker* resource_tracker = PpapiGlobals::Get()->GetResourceTracker(); @@ -300,21 +316,33 @@ TEST_F(CallbackResourceTest, Resurrection) { // Unref it, spin the message loop to run posted calls, and check that things // are in the expected states. resource_tracker->ReleaseResource(resource_id); - base::MessageLoop::current()->RunUntilIdle(); + { + ProxyAutoUnlock unlock; + base::MessageLoop::current()->RunUntilIdle(); + } resource->CheckFinalState(); // "Resurrect" it and check that the callbacks are still dead. PP_Resource new_resource_id = resource->GetReference(); - base::MessageLoop::current()->RunUntilIdle(); + { + ProxyAutoUnlock unlock; + base::MessageLoop::current()->RunUntilIdle(); + } resource->CheckFinalState(); // Unref it again and do the same. resource_tracker->ReleaseResource(new_resource_id); - base::MessageLoop::current()->RunUntilIdle(); + { + ProxyAutoUnlock unlock; + base::MessageLoop::current()->RunUntilIdle(); + } resource->CheckFinalState(); // This shouldn't be needed, but make sure there are no stranded tasks. - base::MessageLoop::current()->RunUntilIdle(); + { + ProxyAutoUnlock unlock; + base::MessageLoop::current()->RunUntilIdle(); + } } } // namespace ppapi diff --git a/chromium/ppapi/shared_impl/unittest_utils.cc b/chromium/ppapi/shared_impl/unittest_utils.cc index f5d064b4db6..6974bd20b3f 100644 --- a/chromium/ppapi/shared_impl/unittest_utils.cc +++ b/chromium/ppapi/shared_impl/unittest_utils.cc @@ -8,8 +8,10 @@ #include "base/containers/hash_tables.h" #include "base/logging.h" +#include "ipc/ipc_message.h" #include "ppapi/shared_impl/array_var.h" #include "ppapi/shared_impl/dictionary_var.h" +#include "ppapi/shared_impl/resource_var.h" #include "ppapi/shared_impl/var.h" #include "ppapi/shared_impl/var_tracker.h" @@ -151,6 +153,42 @@ bool Equals(const PP_Var& expected, } return true; } + case PP_VARTYPE_RESOURCE: { + ResourceVar* expected_var = ResourceVar::FromPPVar(expected); + ResourceVar* actual_var = ResourceVar::FromPPVar(actual); + DCHECK(expected_var && actual_var); + if (expected_var->GetPPResource() != actual_var->GetPPResource()) { + LOG(ERROR) << "expected: " << expected_var->GetPPResource() + << " actual: " << actual_var->GetPPResource(); + return false; + } + + const IPC::Message* actual_message = actual_var->GetCreationMessage(); + const IPC::Message* expected_message = + expected_var->GetCreationMessage(); + if (expected_message->size() != actual_message->size()) { + LOG(ERROR) << "expected creation message size: " + << expected_message->size() << " actual: " + << actual_message->size(); + return false; + } + + // Set the upper 24 bits of actual creation_message flags to the same as + // expected. This is an unpredictable reference number that changes + // between serialization/deserialization, and we do not want it to cause + // the comparison to fail. + IPC::Message local_actual_message(*actual_message); + local_actual_message.SetHeaderValues( + actual_message->routing_id(), actual_message->type(), + (expected_message->flags() & 0xffffff00) | + (actual_message->flags() & 0xff)); + if (memcmp(expected_message->data(), local_actual_message.data(), + expected_message->size()) != 0) { + LOG(ERROR) << "expected creation message does not match actual."; + return false; + } + return true; + } } NOTREACHED(); return false; diff --git a/chromium/ppapi/shared_impl/url_request_info_data.cc b/chromium/ppapi/shared_impl/url_request_info_data.cc index 8bb02a447f0..15b27875608 100644 --- a/chromium/ppapi/shared_impl/url_request_info_data.cc +++ b/chromium/ppapi/shared_impl/url_request_info_data.cc @@ -17,6 +17,7 @@ const int32_t kDefaultPrefetchBufferLowerThreshold = 50 * 1000 * 1000; URLRequestInfoData::BodyItem::BodyItem() : is_file(false), + file_ref_pp_resource(0), start_offset(0), number_of_bytes(-1), expected_last_modified_time(0.0) { @@ -25,6 +26,7 @@ URLRequestInfoData::BodyItem::BodyItem() URLRequestInfoData::BodyItem::BodyItem(const std::string& data) : is_file(false), data(data), + file_ref_pp_resource(0), start_offset(0), number_of_bytes(-1), expected_last_modified_time(0.0) { @@ -36,8 +38,8 @@ URLRequestInfoData::BodyItem::BodyItem( int64_t number_of_bytes, PP_Time expected_last_modified_time) : is_file(true), - file_ref(file_ref), - file_ref_host_resource(file_ref->host_resource()), + file_ref_resource(file_ref), + file_ref_pp_resource(file_ref->pp_resource()), start_offset(start_offset), number_of_bytes(number_of_bytes), expected_last_modified_time(expected_last_modified_time) { diff --git a/chromium/ppapi/shared_impl/url_request_info_data.h b/chromium/ppapi/shared_impl/url_request_info_data.h index 501251a5388..d0acf4ba515 100644 --- a/chromium/ppapi/shared_impl/url_request_info_data.h +++ b/chromium/ppapi/shared_impl/url_request_info_data.h @@ -9,10 +9,12 @@ #include <vector> #include "base/memory/ref_counted.h" +#include "ppapi/c/pp_resource.h" #include "ppapi/c/pp_stdint.h" #include "ppapi/c/pp_time.h" -#include "ppapi/shared_impl/host_resource.h" +#include "ppapi/shared_impl/ppapi_globals.h" #include "ppapi/shared_impl/ppapi_shared_export.h" +#include "ppapi/shared_impl/resource_tracker.h" namespace ppapi { @@ -32,19 +34,12 @@ struct PPAPI_SHARED_EXPORT URLRequestInfoData { std::string data; - // Is is_file is set, these variables are set. Note that the resource - // may still be NULL in some cases, such as deserialization errors. - // - // This is a bit tricky. In the plugin side of the proxy, both the file ref - // and the file_ref_host_resource will be set and valid. The scoped_refptr - // ensures that the resource is alive for as long as the BodyItem is. - // - // When we deserialize this in the renderer, only the - // file_ref_host_resource's are serialized over IPC. The file_refs won't be - // valid until the host resources are converted to Resource pointers in the - // PPB_URLRequestInfo_Impl. - scoped_refptr<Resource> file_ref; - HostResource file_ref_host_resource; + // Only set on the plugin-side, for refcounting purposes. Only valid when + // |is_file| is set. + scoped_refptr<Resource> file_ref_resource; + // This struct holds no ref to this resource. Only valid when |is_file| is + // set. + PP_Resource file_ref_pp_resource; int64_t start_offset; int64_t number_of_bytes; diff --git a/chromium/ppapi/shared_impl/url_response_info_data.h b/chromium/ppapi/shared_impl/url_response_info_data.h index a40ca50fc78..c6f7dbd197f 100644 --- a/chromium/ppapi/shared_impl/url_response_info_data.h +++ b/chromium/ppapi/shared_impl/url_response_info_data.h @@ -8,7 +8,7 @@ #include <string> #include "ppapi/c/pp_stdint.h" -#include "ppapi/shared_impl/ppb_file_ref_shared.h" +#include "ppapi/shared_impl/file_ref_create_info.h" #include "ppapi/shared_impl/ppapi_shared_export.h" namespace ppapi { @@ -23,8 +23,8 @@ struct PPAPI_SHARED_EXPORT URLResponseInfoData { std::string status_text; std::string redirect_url; - // Nonzero when streaming to a file. - PPB_FileRef_CreateInfo body_as_file_ref; + // Valid when streaming to a file. + FileRefCreateInfo body_as_file_ref; }; } // namespace ppapi diff --git a/chromium/ppapi/shared_impl/var.cc b/chromium/ppapi/shared_impl/var.cc index e3ea224de4b..d128d90241a 100644 --- a/chromium/ppapi/shared_impl/var.cc +++ b/chromium/ppapi/shared_impl/var.cc @@ -9,8 +9,10 @@ #include "base/logging.h" #include "base/strings/string_number_conversions.h" #include "base/strings/string_util.h" +#include "base/strings/stringprintf.h" #include "ppapi/c/pp_var.h" #include "ppapi/shared_impl/ppapi_globals.h" +#include "ppapi/shared_impl/resource_var.h" #include "ppapi/shared_impl/var_tracker.h" namespace ppapi { @@ -62,6 +64,19 @@ std::string Var::PPVarToLogString(PP_Var var) { return "[Dictionary]"; case PP_VARTYPE_ARRAY_BUFFER: return "[Array buffer]"; + case PP_VARTYPE_RESOURCE: { + ResourceVar* resource(ResourceVar::FromPPVar(var)); + if (!resource) + return "[Invalid resource]"; + + if (resource->IsPending()) { + return base::StringPrintf("[Pending resource]"); + } else if (resource->GetPPResource()) { + return base::StringPrintf("[Resource %d]", resource->GetPPResource()); + } else { + return "[Null resource]"; + } + } default: return "[Invalid var]"; } @@ -91,6 +106,10 @@ DictionaryVar* Var::AsDictionaryVar() { return NULL; } +ResourceVar* Var::AsResourceVar() { + return NULL; +} + PP_Var Var::GetPPVar() { int32 id = GetOrCreateVarID(); if (!id) diff --git a/chromium/ppapi/shared_impl/var.h b/chromium/ppapi/shared_impl/var.h index bded4656f7e..d656019c74e 100644 --- a/chromium/ppapi/shared_impl/var.h +++ b/chromium/ppapi/shared_impl/var.h @@ -22,6 +22,7 @@ class ArrayVar; class DictionaryVar; class NPObjectVar; class ProxyObjectVar; +class ResourceVar; class StringVar; class VarTracker; @@ -41,6 +42,7 @@ class PPAPI_SHARED_EXPORT Var : public base::RefCounted<Var> { virtual ProxyObjectVar* AsProxyObjectVar(); virtual ArrayVar* AsArrayVar(); virtual DictionaryVar* AsDictionaryVar(); + virtual ResourceVar* AsResourceVar(); // Creates a PP_Var corresponding to this object. The return value will have // one reference addrefed on behalf of the caller. diff --git a/chromium/ppapi/shared_impl/var_tracker.cc b/chromium/ppapi/shared_impl/var_tracker.cc index 254c51ab579..bada0ab76dd 100644 --- a/chromium/ppapi/shared_impl/var_tracker.cc +++ b/chromium/ppapi/shared_impl/var_tracker.cc @@ -13,6 +13,7 @@ #include "ppapi/shared_impl/host_resource.h" #include "ppapi/shared_impl/id_assignment.h" #include "ppapi/shared_impl/proxy_lock.h" +#include "ppapi/shared_impl/resource_var.h" #include "ppapi/shared_impl/var.h" namespace ppapi { @@ -234,6 +235,13 @@ PP_Var VarTracker::MakeArrayBufferPPVar(uint32 size_in_bytes, return array_buffer->GetPPVar(); } +PP_Var VarTracker::MakeResourcePPVar(PP_Resource pp_resource) { + CheckThreadingPreconditions(); + + ResourceVar* resource_var = MakeResourceVar(pp_resource); + return resource_var ? resource_var->GetPPVar() : PP_MakeNull(); +} + std::vector<PP_Var> VarTracker::GetLiveVars() { CheckThreadingPreconditions(); diff --git a/chromium/ppapi/shared_impl/var_tracker.h b/chromium/ppapi/shared_impl/var_tracker.h index d7fb49ccfe0..379f645bbf8 100644 --- a/chromium/ppapi/shared_impl/var_tracker.h +++ b/chromium/ppapi/shared_impl/var_tracker.h @@ -85,6 +85,15 @@ class PPAPI_SHARED_EXPORT VarTracker { // usually immediately put this in a scoped_refptr). ArrayBufferVar* MakeArrayBufferVar(uint32 size_in_bytes, const void* data); + // Creates a new resource var that points to a given resource ID. Returns a + // PP_Var that references it and has an initial reference count of 1. + PP_Var MakeResourcePPVar(PP_Resource pp_resource); + + // Creates a new resource var that points to a given resource ID. This is + // implemented by the host and plugin tracker separately, because the plugin + // keeps a reference to the resource, and the host does not. + virtual ResourceVar* MakeResourceVar(PP_Resource pp_resource) = 0; + // Return a vector containing all PP_Vars that are in the tracker. This is // to help implement PPB_Testing_Dev.GetLiveVars and should generally not be // used in production code. The PP_Vars are returned in no particular order, diff --git a/chromium/ppapi/shared_impl/var_tracker_unittest.cc b/chromium/ppapi/shared_impl/var_tracker_unittest.cc index 23e2f59d948..0fe1a03b396 100644 --- a/chromium/ppapi/shared_impl/var_tracker_unittest.cc +++ b/chromium/ppapi/shared_impl/var_tracker_unittest.cc @@ -5,6 +5,7 @@ #include "testing/gtest/include/gtest/gtest.h" #include "base/compiler_specific.h" +#include "ppapi/shared_impl/proxy_lock.h" #include "ppapi/shared_impl/var.h" #include "ppapi/shared_impl/var_tracker.h" #include "ppapi/shared_impl/test_globals.h" @@ -53,6 +54,7 @@ class VarTrackerTest : public testing::Test { // Test implementation. virtual void SetUp() OVERRIDE { ASSERT_EQ(0, mock_var_alive_count); + ProxyLock::EnableLockingOnThreadForTest(); } virtual void TearDown() OVERRIDE { } @@ -66,6 +68,7 @@ class VarTrackerTest : public testing::Test { // Test that ResetVarID is called when the last PP_Var ref was deleted but the // object lives on. TEST_F(VarTrackerTest, LastResourceRef) { + ProxyAutoLock lock; scoped_refptr<MockStringVar> var(new MockStringVar(std::string("xyz"))); PP_Var pp_var = var->GetPPVar(); EXPECT_TRUE(var->HasValidVarID()); @@ -82,6 +85,7 @@ TEST_F(VarTrackerTest, LastResourceRef) { } TEST_F(VarTrackerTest, GetPluginRefAgain) { + ProxyAutoLock lock; scoped_refptr<MockStringVar> var(new MockStringVar(std::string("xyz"))); PP_Var pp_var = var->GetPPVar(); EXPECT_TRUE(var_tracker().ReleaseVar(pp_var)); @@ -112,6 +116,7 @@ TEST_F(VarTrackerTest, GetPluginRefAgain) { // Tests when the plugin is holding a ref to a PP_Var when the instance is // owned only by VarTracker. TEST_F(VarTrackerTest, PluginRefWithoutVarRef) { + ProxyAutoLock lock; // Make a PP_Var with one ref held by the plugin, and release the reference. scoped_refptr<MockStringVar> var(new MockStringVar(std::string("zzz"))); PP_Var pp_var = var->GetPPVar(); @@ -129,6 +134,7 @@ TEST_F(VarTrackerTest, PluginRefWithoutVarRef) { // Tests on Var having type of PP_VARTYPE_OBJECT. TEST_F(VarTrackerTest, ObjectRef) { + ProxyAutoLock lock; scoped_refptr<MockObjectVar> var(new MockObjectVar()); PP_Var pp_var = var->GetPPVar(); EXPECT_TRUE(var_tracker().ReleaseVar(pp_var)); diff --git a/chromium/ppapi/shared_impl/var_value_conversions.cc b/chromium/ppapi/shared_impl/var_value_conversions.cc index 46f31618687..e3a5bddc4f0 100644 --- a/chromium/ppapi/shared_impl/var_value_conversions.cc +++ b/chromium/ppapi/shared_impl/var_value_conversions.cc @@ -131,6 +131,9 @@ bool CreateValueFromVarHelper(const std::set<int64_t>& parent_ids, value->reset(binary_value); return true; } + case PP_VARTYPE_RESOURCE: { + return false; + } } NOTREACHED(); return false; diff --git a/chromium/ppapi/shared_impl/var_value_conversions_unittest.cc b/chromium/ppapi/shared_impl/var_value_conversions_unittest.cc index 88d645ad197..f8a0a3129e8 100644 --- a/chromium/ppapi/shared_impl/var_value_conversions_unittest.cc +++ b/chromium/ppapi/shared_impl/var_value_conversions_unittest.cc @@ -142,6 +142,7 @@ class VarValueConversionsTest : public testing::Test { // testing::Test implementation. virtual void SetUp() { + ProxyLock::EnableLockingOnThreadForTest(); ProxyLock::Acquire(); } virtual void TearDown() { diff --git a/chromium/ppapi/thunk/enter.cc b/chromium/ppapi/thunk/enter.cc index bd955b2ca8f..47889dd1577 100644 --- a/chromium/ppapi/thunk/enter.cc +++ b/chromium/ppapi/thunk/enter.cc @@ -29,14 +29,6 @@ namespace thunk { namespace subtle { -void AssertLockHeld() { - base::Lock* proxy_lock = PpapiGlobals::Get()->GetProxyLock(); - // The lock is only valid in the plugin side of the proxy, so it only makes - // sense to assert there. Otherwise, silently succeed. - if (proxy_lock) - proxy_lock->AssertAcquired(); -} - EnterBase::EnterBase() : resource_(NULL), retval_(PP_OK) { diff --git a/chromium/ppapi/thunk/enter.h b/chromium/ppapi/thunk/enter.h index a5a00720fe0..4641cbb6264 100644 --- a/chromium/ppapi/thunk/enter.h +++ b/chromium/ppapi/thunk/enter.h @@ -43,9 +43,6 @@ namespace thunk { namespace subtle { -// Assert that we are holding the proxy lock. -PPAPI_THUNK_EXPORT void AssertLockHeld(); - // This helps us define our RAII Enter classes easily. To make an RAII class // which locks the proxy lock on construction and unlocks on destruction, // inherit from |LockOnEntry<true>| before all other base classes. This ensures @@ -63,12 +60,12 @@ struct LockOnEntry<false> { #if (!NDEBUG) LockOnEntry() { // You must already hold the lock to use Enter*NoLock. - AssertLockHeld(); + ProxyLock::AssertAcquired(); } ~LockOnEntry() { // You must not release the lock before leaving the scope of the // Enter*NoLock. - AssertLockHeld(); + ProxyLock::AssertAcquired(); } #endif }; diff --git a/chromium/ppapi/thunk/interfaces_legacy.h b/chromium/ppapi/thunk/interfaces_legacy.h index 6e53ea45802..60518249a06 100644 --- a/chromium/ppapi/thunk/interfaces_legacy.h +++ b/chromium/ppapi/thunk/interfaces_legacy.h @@ -10,8 +10,6 @@ LEGACY_IFACE(PPB_INPUT_EVENT_INTERFACE_1_0, LEGACY_IFACE(PPB_INSTANCE_PRIVATE_INTERFACE_0_1, ::ppapi::thunk::GetPPB_Instance_Private_0_1_Thunk()) LEGACY_IFACE(PPB_CORE_INTERFACE_1_0, &core_interface) -LEGACY_IFACE(PPB_GPUBLACKLIST_PRIVATE_INTERFACE, - PPB_GpuBlacklist_Private_Impl::GetInterface()) LEGACY_IFACE(PPB_OPENGLES2_INTERFACE, ::ppapi::PPB_OpenGLES2_Shared::GetInterface()) LEGACY_IFACE(PPB_OPENGLES2_INSTANCEDARRAYS_INTERFACE, diff --git a/chromium/ppapi/thunk/interfaces_ppb_private.h b/chromium/ppapi/thunk/interfaces_ppb_private.h index 3e0289cc3c7..038d5c521c0 100644 --- a/chromium/ppapi/thunk/interfaces_ppb_private.h +++ b/chromium/ppapi/thunk/interfaces_ppb_private.h @@ -25,15 +25,15 @@ PROXIED_IFACE(PPB_Broker, PPB_BROKER_TRUSTED_INTERFACE_0_3, PROXIED_IFACE(PPB_Instance, PPB_BROWSERFONT_TRUSTED_INTERFACE_1_0, PPB_BrowserFont_Trusted_1_0) PROXIED_IFACE(PPB_Instance, - PPB_CONTENTDECRYPTOR_PRIVATE_INTERFACE_0_6, - PPB_ContentDecryptor_Private_0_6) + PPB_CONTENTDECRYPTOR_PRIVATE_INTERFACE_0_7, + PPB_ContentDecryptor_Private_0_7) PROXIED_IFACE(PPB_Instance, PPB_CHARSET_TRUSTED_INTERFACE_1_0, PPB_CharSet_Trusted_1_0) PROXIED_IFACE(NoAPIName, PPB_FILECHOOSER_TRUSTED_INTERFACE_0_5, PPB_FileChooserTrusted_0_5) PROXIED_IFACE(NoAPIName, PPB_FILECHOOSER_TRUSTED_INTERFACE_0_6, PPB_FileChooserTrusted_0_6) -PROXIED_IFACE(PPB_FileRef, PPB_FILEREFPRIVATE_INTERFACE_0_1, +PROXIED_IFACE(NoAPIName, PPB_FILEREFPRIVATE_INTERFACE_0_1, PPB_FileRefPrivate_0_1) // TODO(xhwang): Move PPB_Flash_DeviceID back to interfaces_ppb_private_flash.h. PROXIED_IFACE(NoAPIName, PPB_FLASH_DEVICEID_INTERFACE_1_0, @@ -44,7 +44,10 @@ PROXIED_IFACE(PPB_Instance, PPB_FLASHFULLSCREEN_INTERFACE_1_0, PPB_FlashFullscreen_0_1) PROXIED_IFACE(NoAPIName, PPB_PDF_INTERFACE, PPB_PDF) - +#if defined(OS_CHROMEOS) +PROXIED_IFACE(NoAPIName, PPB_PLATFORMVERIFICATION_PRIVATE_INTERFACE_0_1, + PPB_PlatformVerification_Private_0_1) +#endif PROXIED_IFACE(NoAPIName, PPB_TALK_PRIVATE_INTERFACE_1_0, PPB_Talk_Private_1_0) PROXIED_IFACE(NoAPIName, PPB_TALK_PRIVATE_INTERFACE_2_0, diff --git a/chromium/ppapi/thunk/interfaces_ppb_private_no_permissions.h b/chromium/ppapi/thunk/interfaces_ppb_private_no_permissions.h index 44cbc3658fa..15e8043eefa 100644 --- a/chromium/ppapi/thunk/interfaces_ppb_private_no_permissions.h +++ b/chromium/ppapi/thunk/interfaces_ppb_private_no_permissions.h @@ -9,9 +9,6 @@ // These interfaces don't require private permissions. However, they only work // for whitelisted origins. -PROXIED_API(PPB_TCPSocket_Private) -UNPROXIED_API(PPB_NetworkList_Private) -PROXIED_API(PPB_NetworkMonitor_Private) PROXIED_IFACE(NoAPIName, PPB_HOSTRESOLVER_PRIVATE_INTERFACE_0_1, PPB_HostResolver_Private_0_1) @@ -19,11 +16,11 @@ PROXIED_IFACE(NoAPIName, PPB_TCPSERVERSOCKET_PRIVATE_INTERFACE_0_1, PPB_TCPServerSocket_Private_0_1) PROXIED_IFACE(NoAPIName, PPB_TCPSERVERSOCKET_PRIVATE_INTERFACE_0_2, PPB_TCPServerSocket_Private_0_2) -PROXIED_IFACE(PPB_TCPSocket_Private, PPB_TCPSOCKET_PRIVATE_INTERFACE_0_3, +PROXIED_IFACE(NoAPIName, PPB_TCPSOCKET_PRIVATE_INTERFACE_0_3, PPB_TCPSocket_Private_0_3) -PROXIED_IFACE(PPB_TCPSocket_Private, PPB_TCPSOCKET_PRIVATE_INTERFACE_0_4, +PROXIED_IFACE(NoAPIName, PPB_TCPSOCKET_PRIVATE_INTERFACE_0_4, PPB_TCPSocket_Private_0_4) -PROXIED_IFACE(PPB_TCPSocket_Private, PPB_TCPSOCKET_PRIVATE_INTERFACE_0_5, +PROXIED_IFACE(NoAPIName, PPB_TCPSOCKET_PRIVATE_INTERFACE_0_5, PPB_TCPSocket_Private_0_5) PROXIED_IFACE(NoAPIName, PPB_UDPSOCKET_PRIVATE_INTERFACE_0_2, PPB_UDPSocket_Private_0_2) @@ -38,11 +35,6 @@ PROXIED_IFACE(NoAPIName, PPB_NETADDRESS_PRIVATE_INTERFACE_1_0, PPB_NetAddress_Private_1_0) PROXIED_IFACE(NoAPIName, PPB_NETADDRESS_PRIVATE_INTERFACE_1_1, PPB_NetAddress_Private_1_1) -PROXIED_IFACE(NoAPIName, PPB_NETWORKLIST_PRIVATE_INTERFACE_0_2, - PPB_NetworkList_Private_0_2) -PROXIED_IFACE(PPB_NetworkMonitor_Private, - PPB_NETWORKMONITOR_PRIVATE_INTERFACE_0_2, - PPB_NetworkMonitor_Private_0_2) PROXIED_IFACE(NoAPIName, PPB_EXT_CRXFILESYSTEM_PRIVATE_INTERFACE_0_1, PPB_Ext_CrxFileSystem_Private_0_1) diff --git a/chromium/ppapi/thunk/interfaces_ppb_public_dev.h b/chromium/ppapi/thunk/interfaces_ppb_public_dev.h index ca487aac253..1ba0435313d 100644 --- a/chromium/ppapi/thunk/interfaces_ppb_public_dev.h +++ b/chromium/ppapi/thunk/interfaces_ppb_public_dev.h @@ -25,8 +25,8 @@ PROXIED_IFACE(NoAPIName, PPB_FILECHOOSER_DEV_INTERFACE_0_6, UNPROXIED_IFACE(PPB_Find, PPB_FIND_DEV_INTERFACE_0_3, PPB_Find_Dev_0_3) PROXIED_IFACE(NoAPIName, PPB_IME_INPUT_EVENT_DEV_INTERFACE_0_2, PPB_IMEInputEvent_Dev_0_2) -PROXIED_IFACE(NoAPIName, PPB_KEYBOARD_INPUT_EVENT_DEV_INTERFACE_0_1, - PPB_KeyboardInputEvent_Dev_0_1) +PROXIED_IFACE(NoAPIName, PPB_KEYBOARD_INPUT_EVENT_DEV_INTERFACE_0_2, + PPB_KeyboardInputEvent_Dev_0_2) PROXIED_IFACE(NoAPIName, PPB_MEMORY_DEV_INTERFACE_0_1, PPB_Memory_Dev_0_1) PROXIED_IFACE(NoAPIName, PPB_PRINTING_DEV_INTERFACE_0_7, PPB_Printing_Dev_0_7) @@ -68,6 +68,7 @@ PROXIED_IFACE(NoAPIName, PPB_GRAPHICS2D_DEV_INTERFACE_0_1, PPB_Graphics2D_Dev_0_1) PROXIED_IFACE(PPB_Instance, PPB_CHAR_SET_DEV_INTERFACE_0_4, PPB_CharSet_Dev_0_4) PROXIED_IFACE(PPB_Instance, PPB_URLUTIL_DEV_INTERFACE_0_6, PPB_URLUtil_Dev_0_6) +PROXIED_IFACE(PPB_Instance, PPB_URLUTIL_DEV_INTERFACE_0_7, PPB_URLUtil_Dev_0_7) UNPROXIED_IFACE(PPB_Scrollbar, PPB_SCROLLBAR_DEV_INTERFACE_0_5, PPB_Scrollbar_Dev_0_5) PROXIED_IFACE(PPB_Instance, PPB_TEXTINPUT_DEV_INTERFACE_0_1, diff --git a/chromium/ppapi/thunk/interfaces_ppb_public_stable.h b/chromium/ppapi/thunk/interfaces_ppb_public_stable.h index b0918a3f056..91e023afe66 100644 --- a/chromium/ppapi/thunk/interfaces_ppb_public_stable.h +++ b/chromium/ppapi/thunk/interfaces_ppb_public_stable.h @@ -19,11 +19,9 @@ // that exist in the webkit/plugins/ppapi/*_impl.h, but not in the proxy. PROXIED_API(PPB_Audio) PROXIED_API(PPB_Core) -PROXIED_API(PPB_FileRef) PROXIED_API(PPB_Graphics3D) PROXIED_API(PPB_ImageData) PROXIED_API(PPB_Instance) -PROXIED_API(PPB_TCPSocket) // AudioConfig isn't proxied in the normal way, we have only local classes and // serialize it to a struct when we need it on the host side. @@ -46,8 +44,9 @@ UNPROXIED_API(PPB_AudioConfig) // interface string. // Note: Core is special and is registered manually. PROXIED_IFACE(PPB_Audio, PPB_AUDIO_INTERFACE_1_0, PPB_Audio_1_0) -PROXIED_IFACE(PPB_FileRef, PPB_FILEREF_INTERFACE_1_0, PPB_FileRef_1_0) -PROXIED_IFACE(PPB_FileRef, PPB_FILEREF_INTERFACE_1_1, PPB_FileRef_1_1) +PROXIED_IFACE(PPB_Audio, PPB_AUDIO_INTERFACE_1_1, PPB_Audio_1_1) +PROXIED_IFACE(NoAPIName, PPB_FILEREF_INTERFACE_1_0, PPB_FileRef_1_0) +PROXIED_IFACE(NoAPIName, PPB_FILEREF_INTERFACE_1_1, PPB_FileRef_1_1) PROXIED_IFACE(NoAPIName, PPB_FILESYSTEM_INTERFACE_1_0, PPB_FileSystem_1_0) PROXIED_IFACE(PPB_Graphics3D, PPB_GRAPHICS_3D_INTERFACE_1_0, PPB_Graphics3D_1_0) PROXIED_IFACE(PPB_ImageData, PPB_IMAGEDATA_INTERFACE_1_0, PPB_ImageData_1_0) @@ -77,8 +76,12 @@ PROXIED_IFACE(PPB_Instance, PPB_MESSAGING_INTERFACE_1_0, PPB_Messaging_1_0) PROXIED_IFACE(PPB_Instance, PPB_MOUSECURSOR_INTERFACE_1_0, PPB_MouseCursor_1_0) PROXIED_IFACE(PPB_Instance, PPB_MOUSELOCK_INTERFACE_1_0, PPB_MouseLock_1_0) PROXIED_IFACE(NoAPIName, PPB_NETADDRESS_INTERFACE_1_0, PPB_NetAddress_1_0) +PROXIED_IFACE(NoAPIName, PPB_NETWORKLIST_INTERFACE_1_0, PPB_NetworkList_1_0) +PROXIED_IFACE(NoAPIName, PPB_NETWORKMONITOR_INTERFACE_1_0, + PPB_NetworkMonitor_1_0) PROXIED_IFACE(NoAPIName, PPB_NETWORKPROXY_INTERFACE_1_0, PPB_NetworkProxy_1_0) -PROXIED_IFACE(PPB_TCPSocket, PPB_TCPSOCKET_INTERFACE_1_0, PPB_TCPSocket_1_0) +PROXIED_IFACE(NoAPIName, PPB_TCPSOCKET_INTERFACE_1_0, PPB_TCPSocket_1_0) +PROXIED_IFACE(NoAPIName, PPB_TCPSOCKET_INTERFACE_1_1, PPB_TCPSocket_1_1) PROXIED_IFACE(NoAPIName, PPB_TEXTINPUTCONTROLLER_INTERFACE_1_0, PPB_TextInputController_1_0) PROXIED_IFACE(NoAPIName, PPB_UDPSOCKET_INTERFACE_1_0, PPB_UDPSocket_1_0) diff --git a/chromium/ppapi/thunk/ppb_audio_thunk.cc b/chromium/ppapi/thunk/ppb_audio_thunk.cc index 5dddb891784..646ae6b4c44 100644 --- a/chromium/ppapi/thunk/ppb_audio_thunk.cc +++ b/chromium/ppapi/thunk/ppb_audio_thunk.cc @@ -2,8 +2,6 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -// From ppb_audio.idl modified Thu Dec 20 13:10:26 2012. - #include "ppapi/c/pp_errors.h" #include "ppapi/c/ppb_audio.h" #include "ppapi/shared_impl/tracked_callback.h" @@ -18,6 +16,20 @@ namespace thunk { namespace { +PP_Resource Create_1_0(PP_Instance instance, + PP_Resource config, + PPB_Audio_Callback_1_0 audio_callback, + void* user_data) { + VLOG(4) << "PPB_Audio::Create()"; + EnterResourceCreation enter(instance); + if (enter.failed()) + return 0; + return enter.functions()->CreateAudio1_0(instance, + config, + audio_callback, + user_data); +} + PP_Resource Create(PP_Instance instance, PP_Resource config, PPB_Audio_Callback audio_callback, @@ -63,6 +75,14 @@ PP_Bool StopPlayback(PP_Resource audio) { } const PPB_Audio_1_0 g_ppb_audio_thunk_1_0 = { + &Create_1_0, + &IsAudio, + &GetCurrentConfig, + &StartPlayback, + &StopPlayback +}; + +const PPB_Audio_1_1 g_ppb_audio_thunk_1_1 = { &Create, &IsAudio, &GetCurrentConfig, @@ -76,5 +96,9 @@ const PPB_Audio_1_0* GetPPB_Audio_1_0_Thunk() { return &g_ppb_audio_thunk_1_0; } +const PPB_Audio_1_1* GetPPB_Audio_1_1_Thunk() { + return &g_ppb_audio_thunk_1_1; +} + } // namespace thunk } // namespace ppapi diff --git a/chromium/ppapi/thunk/ppb_content_decryptor_private_thunk.cc b/chromium/ppapi/thunk/ppb_content_decryptor_private_thunk.cc index 9450eedcbd6..7fe79e12848 100644 --- a/chromium/ppapi/thunk/ppb_content_decryptor_private_thunk.cc +++ b/chromium/ppapi/thunk/ppb_content_decryptor_private_thunk.cc @@ -3,7 +3,7 @@ // found in the LICENSE file. // From private/ppb_content_decryptor_private.idl, -// modified Tue Apr 16 11:25:44 2013. +// modified Tue Sep 17 11:31:05 2013. #include "ppapi/c/pp_errors.h" #include "ppapi/c/private/ppb_content_decryptor_private.h" @@ -18,17 +18,6 @@ namespace thunk { namespace { -void NeedKey(PP_Instance instance, - struct PP_Var key_system, - struct PP_Var session_id, - struct PP_Var init_data) { - VLOG(4) << "PPB_ContentDecryptor_Private::NeedKey()"; - EnterInstance enter(instance); - if (enter.failed()) - return; - enter.functions()->NeedKey(instance, key_system, session_id, init_data); -} - void KeyAdded(PP_Instance instance, struct PP_Var key_system, struct PP_Var session_id) { @@ -144,9 +133,8 @@ void DeliverSamples( decrypted_block_info); } -const PPB_ContentDecryptor_Private_0_6 - g_ppb_contentdecryptor_private_thunk_0_6 = { - &NeedKey, +const PPB_ContentDecryptor_Private_0_7 + g_ppb_contentdecryptor_private_thunk_0_7 = { &KeyAdded, &KeyMessage, &KeyError, @@ -160,9 +148,9 @@ const PPB_ContentDecryptor_Private_0_6 } // namespace -const PPB_ContentDecryptor_Private_0_6* - GetPPB_ContentDecryptor_Private_0_6_Thunk() { - return &g_ppb_contentdecryptor_private_thunk_0_6; +const PPB_ContentDecryptor_Private_0_7* + GetPPB_ContentDecryptor_Private_0_7_Thunk() { + return &g_ppb_contentdecryptor_private_thunk_0_7; } } // namespace thunk diff --git a/chromium/ppapi/thunk/ppb_file_ref_api.h b/chromium/ppapi/thunk/ppb_file_ref_api.h index ba92b63fcc4..b473ae28721 100644 --- a/chromium/ppapi/thunk/ppb_file_ref_api.h +++ b/chromium/ppapi/thunk/ppb_file_ref_api.h @@ -10,11 +10,12 @@ #include "base/memory/linked_ptr.h" #include "base/memory/ref_counted.h" #include "ppapi/c/ppb_file_ref.h" +#include "ppapi/shared_impl/file_ref_create_info.h" #include "ppapi/thunk/ppapi_thunk_export.h" namespace ppapi { -struct PPB_FileRef_CreateInfo; +struct FileRefCreateInfo; class TrackedCallback; namespace thunk { @@ -40,25 +41,10 @@ class PPAPI_THUNK_EXPORT PPB_FileRef_API { virtual int32_t ReadDirectoryEntries( const PP_ArrayOutput& output, scoped_refptr<TrackedCallback> callback) = 0; - // We define variants of Query and ReadDirectoryEntries because - // 1. we need to take linked_ptr instead of raw pointers to avoid - // use-after-free, and 2. we don't use PP_ArrayOutput for the - // communication between renderers and the browser in - // ReadDirectoryEntries. The *InHost functions must not be called in - // plugins, and Query and ReadDirectoryEntries must not be called in - // renderers. - // TODO(hamaji): These functions must be removed when we move - // FileRef to the new resource design. http://crbug.com/225441 - virtual int32_t QueryInHost(linked_ptr<PP_FileInfo> info, - scoped_refptr<TrackedCallback> callback) = 0; - virtual int32_t ReadDirectoryEntriesInHost( - linked_ptr<std::vector<ppapi::PPB_FileRef_CreateInfo> > files, - linked_ptr<std::vector<PP_FileType> > file_types, - scoped_refptr<TrackedCallback> callback) = 0; // Internal function for use in proxying. Returns the internal CreateInfo // (the contained resource does not carry a ref on behalf of the caller). - virtual const PPB_FileRef_CreateInfo& GetCreateInfo() const = 0; + virtual const FileRefCreateInfo& GetCreateInfo() const = 0; // Private API virtual PP_Var GetAbsolutePath() = 0; diff --git a/chromium/ppapi/thunk/ppb_file_ref_thunk.cc b/chromium/ppapi/thunk/ppb_file_ref_thunk.cc index beb0e41f573..64c90b55dbc 100644 --- a/chromium/ppapi/thunk/ppb_file_ref_thunk.cc +++ b/chromium/ppapi/thunk/ppb_file_ref_thunk.cc @@ -7,6 +7,7 @@ #include "ppapi/c/pp_completion_callback.h" #include "ppapi/c/pp_errors.h" #include "ppapi/c/private/ppb_file_ref_private.h" +#include "ppapi/shared_impl/file_ref_create_info.h" #include "ppapi/shared_impl/proxy_lock.h" #include "ppapi/shared_impl/tracked_callback.h" #include "ppapi/thunk/enter.h" @@ -32,7 +33,13 @@ PP_Resource Create(PP_Resource file_system, const char* path) { EnterResourceCreationNoLock enter(instance); if (enter.failed()) return 0; - return enter.functions()->CreateFileRef(instance, file_system, path); + FileRefCreateInfo info; + info.file_system_type = enter_file_system.object()->GetType(); + info.internal_path = std::string(path); + info.browser_pending_host_resource_id = 0; + info.renderer_pending_host_resource_id = 0; + info.file_system_plugin_resource = file_system; + return enter.functions()->CreateFileRef(instance, info); } PP_Bool IsFileRef(PP_Resource resource) { diff --git a/chromium/ppapi/thunk/ppb_input_event_api.h b/chromium/ppapi/thunk/ppb_input_event_api.h index 18bda799a89..e2eb3576566 100644 --- a/chromium/ppapi/thunk/ppb_input_event_api.h +++ b/chromium/ppapi/thunk/ppb_input_event_api.h @@ -38,6 +38,7 @@ class PPAPI_THUNK_EXPORT PPB_InputEvent_API { virtual PP_Var GetCharacterText() = 0; virtual PP_Bool SetUsbKeyCode(uint32_t) = 0; virtual uint32_t GetUsbKeyCode() = 0; + virtual PP_Var GetCode() = 0; virtual uint32_t GetIMESegmentNumber() = 0; virtual uint32_t GetIMESegmentOffset(uint32_t index) = 0; virtual int32_t GetIMETargetSegment() = 0; diff --git a/chromium/ppapi/thunk/ppb_input_event_thunk.cc b/chromium/ppapi/thunk/ppb_input_event_thunk.cc index f54eefa8a02..5a0927da68d 100644 --- a/chromium/ppapi/thunk/ppb_input_event_thunk.cc +++ b/chromium/ppapi/thunk/ppb_input_event_thunk.cc @@ -311,9 +311,19 @@ uint32_t GetUsbKeyCode(PP_Resource key_event) { return enter.object()->GetUsbKeyCode(); } -const PPB_KeyboardInputEvent_Dev g_ppb_keyboard_input_event_dev_thunk = { +PP_Var GetCode(PP_Resource key_event) { + VLOG(4) << "PPB_KeyboardInputEvent_Dev::GetCode()"; + EnterInputEvent enter(key_event, true); + if (enter.failed()) + return PP_MakeUndefined(); + return enter.object()->GetCode(); +} + +const PPB_KeyboardInputEvent_Dev_0_2 + g_ppb_keyboard_input_event_dev_0_2_thunk = { &SetUsbKeyCode, &GetUsbKeyCode, + &GetCode, }; // Composition ----------------------------------------------------------------- @@ -511,9 +521,9 @@ const PPB_KeyboardInputEvent_1_0* GetPPB_KeyboardInputEvent_1_0_Thunk() { return &g_ppb_keyboard_input_event_thunk; } -const PPB_KeyboardInputEvent_Dev_0_1* - GetPPB_KeyboardInputEvent_Dev_0_1_Thunk() { - return &g_ppb_keyboard_input_event_dev_thunk; +const PPB_KeyboardInputEvent_Dev_0_2* + GetPPB_KeyboardInputEvent_Dev_0_2_Thunk() { + return &g_ppb_keyboard_input_event_dev_0_2_thunk; } const PPB_WheelInputEvent_1_0* GetPPB_WheelInputEvent_1_0_Thunk() { diff --git a/chromium/ppapi/thunk/ppb_instance_api.h b/chromium/ppapi/thunk/ppb_instance_api.h index c1d024e0d95..0d424a5ed53 100644 --- a/chromium/ppapi/thunk/ppb_instance_api.h +++ b/chromium/ppapi/thunk/ppb_instance_api.h @@ -142,10 +142,6 @@ class PPB_Instance_API { PP_URLComponents_Dev* components) = 0; #if !defined(OS_NACL) // Content Decryptor. - virtual void NeedKey(PP_Instance instance, - PP_Var key_system, - PP_Var session_id, - PP_Var init_data) = 0; virtual void KeyAdded(PP_Instance instance, PP_Var key_system, PP_Var session_id) = 0; @@ -189,6 +185,8 @@ class PPB_Instance_API { PP_Instance target) = 0; virtual PP_Var GetPluginInstanceURL(PP_Instance instance, PP_URLComponents_Dev* components) = 0; + virtual PP_Var GetPluginReferrerURL(PP_Instance instance, + PP_URLComponents_Dev* components) = 0; #endif // !defined(OS_NACL) static const ApiID kApiID = API_ID_PPB_INSTANCE; diff --git a/chromium/ppapi/thunk/ppb_network_list_api.h b/chromium/ppapi/thunk/ppb_network_list_api.h index bbadded6f75..df27a20e74d 100644 --- a/chromium/ppapi/thunk/ppb_network_list_api.h +++ b/chromium/ppapi/thunk/ppb_network_list_api.h @@ -7,32 +7,23 @@ #include <vector> -#include "ppapi/c/private/ppb_network_list_private.h" +#include "ppapi/c/ppb_network_list.h" #include "ppapi/thunk/ppapi_thunk_export.h" namespace ppapi { - -struct NetworkInfo; -typedef std::vector<NetworkInfo> NetworkList; - namespace thunk { class PPAPI_THUNK_EXPORT PPB_NetworkList_API { public: virtual ~PPB_NetworkList_API() {} - // This function is not exposed through the C API, but returns the - // internal data for easy proxying. - virtual const NetworkList& GetNetworkListData() const = 0; - // Private API virtual uint32_t GetCount() = 0; virtual PP_Var GetName(uint32_t index) = 0; - virtual PP_NetworkListType_Private GetType(uint32_t index) = 0; - virtual PP_NetworkListState_Private GetState(uint32_t index) = 0; + virtual PP_NetworkList_Type GetType(uint32_t index) = 0; + virtual PP_NetworkList_State GetState(uint32_t index) = 0; virtual int32_t GetIpAddresses(uint32_t index, - PP_NetAddress_Private addresses[], - uint32_t count) = 0; + const PP_ArrayOutput& output) = 0; virtual PP_Var GetDisplayName(uint32_t index) = 0; virtual uint32_t GetMTU(uint32_t index) = 0; }; diff --git a/chromium/ppapi/thunk/ppb_network_list_private_thunk.cc b/chromium/ppapi/thunk/ppb_network_list_thunk.cc index 211c79364f3..393a752cc01 100644 --- a/chromium/ppapi/thunk/ppb_network_list_private_thunk.cc +++ b/chromium/ppapi/thunk/ppb_network_list_thunk.cc @@ -2,11 +2,10 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -// From private/ppb_network_list_private.idl, -// modified Tue Apr 16 11:25:45 2013. +// From ppb_network_list.idl modified Mon Sep 9 11:18:02 2013. #include "ppapi/c/pp_errors.h" -#include "ppapi/c/private/ppb_network_list_private.h" +#include "ppapi/c/ppb_network_list.h" #include "ppapi/shared_impl/tracked_callback.h" #include "ppapi/thunk/enter.h" #include "ppapi/thunk/ppb_instance_api.h" @@ -20,13 +19,13 @@ namespace thunk { namespace { PP_Bool IsNetworkList(PP_Resource resource) { - VLOG(4) << "PPB_NetworkList_Private::IsNetworkList()"; + VLOG(4) << "PPB_NetworkList::IsNetworkList()"; EnterResource<PPB_NetworkList_API> enter(resource, false); return PP_FromBool(enter.succeeded()); } uint32_t GetCount(PP_Resource resource) { - VLOG(4) << "PPB_NetworkList_Private::GetCount()"; + VLOG(4) << "PPB_NetworkList::GetCount()"; EnterResource<PPB_NetworkList_API> enter(resource, true); if (enter.failed()) return 0; @@ -34,42 +33,41 @@ uint32_t GetCount(PP_Resource resource) { } struct PP_Var GetName(PP_Resource resource, uint32_t index) { - VLOG(4) << "PPB_NetworkList_Private::GetName()"; + VLOG(4) << "PPB_NetworkList::GetName()"; EnterResource<PPB_NetworkList_API> enter(resource, true); if (enter.failed()) return PP_MakeUndefined(); return enter.object()->GetName(index); } -PP_NetworkListType_Private GetType(PP_Resource resource, uint32_t index) { - VLOG(4) << "PPB_NetworkList_Private::GetType()"; +PP_NetworkList_Type GetType(PP_Resource resource, uint32_t index) { + VLOG(4) << "PPB_NetworkList::GetType()"; EnterResource<PPB_NetworkList_API> enter(resource, true); if (enter.failed()) - return PP_NETWORKLIST_UNKNOWN; + return PP_NETWORKLIST_TYPE_UNKNOWN; return enter.object()->GetType(index); } -PP_NetworkListState_Private GetState(PP_Resource resource, uint32_t index) { - VLOG(4) << "PPB_NetworkList_Private::GetState()"; +PP_NetworkList_State GetState(PP_Resource resource, uint32_t index) { + VLOG(4) << "PPB_NetworkList::GetState()"; EnterResource<PPB_NetworkList_API> enter(resource, true); if (enter.failed()) - return PP_NETWORKLIST_DOWN; + return PP_NETWORKLIST_STATE_DOWN; return enter.object()->GetState(index); } int32_t GetIpAddresses(PP_Resource resource, uint32_t index, - struct PP_NetAddress_Private addresses[], - uint32_t count) { - VLOG(4) << "PPB_NetworkList_Private::GetIpAddresses()"; + struct PP_ArrayOutput output) { + VLOG(4) << "PPB_NetworkList::GetIpAddresses()"; EnterResource<PPB_NetworkList_API> enter(resource, true); if (enter.failed()) return enter.retval(); - return enter.object()->GetIpAddresses(index, addresses, count); + return enter.object()->GetIpAddresses(index, output); } struct PP_Var GetDisplayName(PP_Resource resource, uint32_t index) { - VLOG(4) << "PPB_NetworkList_Private::GetDisplayName()"; + VLOG(4) << "PPB_NetworkList::GetDisplayName()"; EnterResource<PPB_NetworkList_API> enter(resource, true); if (enter.failed()) return PP_MakeUndefined(); @@ -77,14 +75,14 @@ struct PP_Var GetDisplayName(PP_Resource resource, uint32_t index) { } uint32_t GetMTU(PP_Resource resource, uint32_t index) { - VLOG(4) << "PPB_NetworkList_Private::GetMTU()"; + VLOG(4) << "PPB_NetworkList::GetMTU()"; EnterResource<PPB_NetworkList_API> enter(resource, true); if (enter.failed()) return 0; return enter.object()->GetMTU(index); } -const PPB_NetworkList_Private_0_2 g_ppb_networklist_private_thunk_0_2 = { +const PPB_NetworkList_1_0 g_ppb_networklist_thunk_1_0 = { &IsNetworkList, &GetCount, &GetName, @@ -97,8 +95,8 @@ const PPB_NetworkList_Private_0_2 g_ppb_networklist_private_thunk_0_2 = { } // namespace -const PPB_NetworkList_Private_0_2* GetPPB_NetworkList_Private_0_2_Thunk() { - return &g_ppb_networklist_private_thunk_0_2; +const PPB_NetworkList_1_0* GetPPB_NetworkList_1_0_Thunk() { + return &g_ppb_networklist_thunk_1_0; } } // namespace thunk diff --git a/chromium/ppapi/thunk/ppb_network_monitor_api.h b/chromium/ppapi/thunk/ppb_network_monitor_api.h new file mode 100644 index 00000000000..c787324c830 --- /dev/null +++ b/chromium/ppapi/thunk/ppb_network_monitor_api.h @@ -0,0 +1,29 @@ +// Copyright 2013 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_PPB_NETWORK_MONITOR_API_H_ +#define PPAPI_THUNK_PPB_NETWORK_MONITOR_API_H_ + +#include "ppapi/c/ppb_network_monitor.h" +#include "ppapi/thunk/ppapi_thunk_export.h" + +namespace ppapi { + +class TrackedCallback; + +namespace thunk { + +class PPAPI_THUNK_EXPORT PPB_NetworkMonitor_API { + public: + virtual ~PPB_NetworkMonitor_API() {} + + virtual int32_t UpdateNetworkList( + PP_Resource* network_list, + scoped_refptr<TrackedCallback> callback) = 0; +}; + +} // namespace thunk +} // namespace ppapi + +#endif // PPAPI_THUNK_PPB_NETWORK_MONITOR_API_H_ diff --git a/chromium/ppapi/thunk/ppb_network_monitor_private_api.h b/chromium/ppapi/thunk/ppb_network_monitor_private_api.h deleted file mode 100644 index 124f6446c22..00000000000 --- a/chromium/ppapi/thunk/ppb_network_monitor_private_api.h +++ /dev/null @@ -1,22 +0,0 @@ -// Copyright (c) 2012 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#ifndef PPAPI_THUNK_PPB_NETWORK_MONITOR_PRIVATE_API_H_ -#define PPAPI_THUNK_PPB_NETWORK_MONITOR_PRIVATE_API_H_ - -#include "ppapi/c/private/ppb_network_monitor_private.h" -#include "ppapi/thunk/ppapi_thunk_export.h" - -namespace ppapi { -namespace thunk { - -class PPAPI_THUNK_EXPORT PPB_NetworkMonitor_Private_API { - public: - virtual ~PPB_NetworkMonitor_Private_API() {} -}; - -} // namespace thunk -} // namespace ppapi - -#endif // PPAPI_THUNK_PPB_NETWORK_MONITOR_PRIVATE_API_H_ diff --git a/chromium/ppapi/thunk/ppb_network_monitor_private_thunk.cc b/chromium/ppapi/thunk/ppb_network_monitor_private_thunk.cc deleted file mode 100644 index 0382e923990..00000000000 --- a/chromium/ppapi/thunk/ppb_network_monitor_private_thunk.cc +++ /dev/null @@ -1,45 +0,0 @@ -// Copyright (c) 2012 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#include "ppapi/c/pp_errors.h" -#include "ppapi/thunk/enter.h" -#include "ppapi/thunk/thunk.h" -#include "ppapi/thunk/ppb_network_monitor_private_api.h" -#include "ppapi/thunk/resource_creation_api.h" - -namespace ppapi { -namespace thunk { - -namespace { - -typedef EnterResource<PPB_NetworkMonitor_Private_API> EnterNetworkMonitor; - -PP_Resource Create(PP_Instance instance, - PPB_NetworkMonitor_Callback callback, - void* user_data) { - EnterResourceCreation enter(instance); - if (enter.failed()) - return 0; - return enter.functions()->CreateNetworkMonitor(instance, callback, user_data); -} - -PP_Bool IsNetworkMonitor(PP_Resource resource) { - EnterNetworkMonitor enter(resource, false); - return PP_FromBool(enter.succeeded()); -} - -const PPB_NetworkMonitor_Private g_ppb_network_monitor_private_thunk = { - &Create, - &IsNetworkMonitor, -}; - -} // namespace - -const PPB_NetworkMonitor_Private_0_2* -GetPPB_NetworkMonitor_Private_0_2_Thunk() { - return &g_ppb_network_monitor_private_thunk; -} - -} // namespace thunk -} // namespace ppapi diff --git a/chromium/ppapi/thunk/ppb_network_monitor_thunk.cc b/chromium/ppapi/thunk/ppb_network_monitor_thunk.cc new file mode 100644 index 00000000000..089d783b63b --- /dev/null +++ b/chromium/ppapi/thunk/ppb_network_monitor_thunk.cc @@ -0,0 +1,60 @@ +// Copyright (c) 2012 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +// From ppb_network_monitor.idl modified Thu Sep 5 12:10:00 2013. + +#include "ppapi/c/pp_completion_callback.h" +#include "ppapi/c/pp_errors.h" +#include "ppapi/c/ppb_network_monitor.h" +#include "ppapi/shared_impl/tracked_callback.h" +#include "ppapi/thunk/enter.h" +#include "ppapi/thunk/ppb_instance_api.h" +#include "ppapi/thunk/ppb_network_monitor_api.h" +#include "ppapi/thunk/resource_creation_api.h" +#include "ppapi/thunk/thunk.h" + +namespace ppapi { +namespace thunk { + +namespace { + +PP_Resource Create(PP_Instance instance) { + VLOG(4) << "PPB_NetworkMonitor::Create()"; + EnterResourceCreation enter(instance); + if (enter.failed()) + return 0; + return enter.functions()->CreateNetworkMonitor(instance); +} + +int32_t UpdateNetworkList(PP_Resource network_monitor, + PP_Resource* network_list, + struct PP_CompletionCallback callback) { + VLOG(4) << "PPB_NetworkMonitor::UpdateNetworkList()"; + EnterResource<PPB_NetworkMonitor_API> enter(network_monitor, callback, true); + if (enter.failed()) + return enter.retval(); + return enter.SetResult(enter.object()->UpdateNetworkList(network_list, + enter.callback())); +} + +PP_Bool IsNetworkMonitor(PP_Resource resource) { + VLOG(4) << "PPB_NetworkMonitor::IsNetworkMonitor()"; + EnterResource<PPB_NetworkMonitor_API> enter(resource, false); + return PP_FromBool(enter.succeeded()); +} + +const PPB_NetworkMonitor_1_0 g_ppb_networkmonitor_thunk_1_0 = { + &Create, + &UpdateNetworkList, + &IsNetworkMonitor +}; + +} // namespace + +const PPB_NetworkMonitor_1_0* GetPPB_NetworkMonitor_1_0_Thunk() { + return &g_ppb_networkmonitor_thunk_1_0; +} + +} // namespace thunk +} // namespace ppapi diff --git a/chromium/ppapi/thunk/ppb_output_protection_private_thunk.cc b/chromium/ppapi/thunk/ppb_output_protection_private_thunk.cc new file mode 100644 index 00000000000..8708806a2a2 --- /dev/null +++ b/chromium/ppapi/thunk/ppb_output_protection_private_thunk.cc @@ -0,0 +1,78 @@ +// Copyright 2013 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. + +// From private/ppb_output_protection_private.idl, +// modified Thu Aug 29 13:39:04 2013. + +#include "ppapi/c/pp_completion_callback.h" +#include "ppapi/c/pp_errors.h" +#include "ppapi/c/private/ppb_output_protection_private.h" +#include "ppapi/shared_impl/tracked_callback.h" +#include "ppapi/thunk/enter.h" +#include "ppapi/thunk/ppb_instance_api.h" +#include "ppapi/thunk/ppb_output_protection_api.h" +#include "ppapi/thunk/resource_creation_api.h" +#include "ppapi/thunk/thunk.h" + +namespace ppapi { +namespace thunk { + +namespace { + +PP_Resource Create(PP_Instance instance) { + VLOG(4) << "PPB_OutputProtection_Private::Create()"; + EnterResourceCreation enter(instance); + if (enter.failed()) + return 0; + return enter.functions()->CreateOutputProtectionPrivate(instance); +} + +PP_Bool IsOutputProtection(PP_Resource resource) { + VLOG(4) << "PPB_OutputProtection_Private::IsOutputProtection()"; + EnterResource<PPB_OutputProtection_API> enter(resource, false); + return PP_FromBool(enter.succeeded()); +} + +int32_t QueryStatus(PP_Resource resource, + uint32_t* link_mask, + uint32_t* protection_mask, + struct PP_CompletionCallback callback) { + VLOG(4) << "PPB_OutputProtection_Private::QueryStatus()"; + EnterResource<PPB_OutputProtection_API> enter(resource, callback, true); + if (enter.failed()) + return enter.retval(); + return enter.SetResult(enter.object()->QueryStatus(link_mask, + protection_mask, + enter.callback())); +} + +int32_t EnableProtection(PP_Resource resource, + uint32_t desired_protection_mask, + struct PP_CompletionCallback callback) { + VLOG(4) << "PPB_OutputProtection_Private::EnableProtection()"; + EnterResource<PPB_OutputProtection_API> enter(resource, callback, true); + if (enter.failed()) + return enter.retval(); + return enter.SetResult(enter.object()->EnableProtection( + desired_protection_mask, + enter.callback())); +} + +const PPB_OutputProtection_Private_0_1 + g_ppb_outputprotection_private_thunk_0_1 = { + &Create, + &IsOutputProtection, + &QueryStatus, + &EnableProtection +}; + +} // namespace + +const PPB_OutputProtection_Private_0_1* + GetPPB_OutputProtection_Private_0_1_Thunk() { + return &g_ppb_outputprotection_private_thunk_0_1; +} + +} // namespace thunk +} // namespace ppapi diff --git a/chromium/ppapi/thunk/ppb_platform_verification_api.h b/chromium/ppapi/thunk/ppb_platform_verification_api.h new file mode 100644 index 00000000000..fc2872b0cb3 --- /dev/null +++ b/chromium/ppapi/thunk/ppb_platform_verification_api.h @@ -0,0 +1,36 @@ +// Copyright 2013 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_PPB_PLATFORM_VERIFICATION_API_H_ +#define PPAPI_THUNK_PPB_PLATFORM_VERIFICATION_API_H_ + +#include "base/memory/ref_counted.h" +#include "ppapi/thunk/ppapi_thunk_export.h" + +namespace ppapi { + +class TrackedCallback; + +namespace thunk { + +class PPAPI_THUNK_EXPORT PPB_PlatformVerification_API { + public: + virtual ~PPB_PlatformVerification_API() {} + + virtual int32_t CanChallengePlatform( + PP_Bool* can_challenge_platform, + const scoped_refptr<TrackedCallback>& callback) = 0; + virtual int32_t ChallengePlatform( + const PP_Var& service_id, + const PP_Var& challenge, + PP_Var* signed_data, + PP_Var* signed_data_signature, + PP_Var* platform_key_certificate, + const scoped_refptr<TrackedCallback>& callback) = 0; +}; + +} // namespace thunk +} // namespace ppapi + +#endif // PPAPI_THUNK_PPB_PLATFORM_VERIFICATION_API_H_ diff --git a/chromium/ppapi/thunk/ppb_platform_verification_private_thunk.cc b/chromium/ppapi/thunk/ppb_platform_verification_private_thunk.cc new file mode 100644 index 00000000000..74cd360e8da --- /dev/null +++ b/chromium/ppapi/thunk/ppb_platform_verification_private_thunk.cc @@ -0,0 +1,85 @@ +// Copyright 2013 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. + +// From private/ppb_platform_verification_private.idl, +// modified Thu Sep 12 11:48:28 2013. + +#include "ppapi/c/pp_completion_callback.h" +#include "ppapi/c/pp_errors.h" +#include "ppapi/c/private/ppb_platform_verification_private.h" +#include "ppapi/shared_impl/tracked_callback.h" +#include "ppapi/thunk/enter.h" +#include "ppapi/thunk/ppb_instance_api.h" +#include "ppapi/thunk/ppb_platform_verification_api.h" +#include "ppapi/thunk/resource_creation_api.h" +#include "ppapi/thunk/thunk.h" + +namespace ppapi { +namespace thunk { + +namespace { + +PP_Resource Create(PP_Instance instance) { + VLOG(4) << "PPB_PlatformVerification_Private::Create()"; + EnterResourceCreation enter(instance); + if (enter.failed()) + return 0; + return enter.functions()->CreatePlatformVerificationPrivate(instance); +} + +PP_Bool IsPlatformVerification(PP_Resource resource) { + VLOG(4) << "PPB_PlatformVerification_Private::IsPlatformVerification()"; + EnterResource<PPB_PlatformVerification_API> enter(resource, false); + return PP_FromBool(enter.succeeded()); +} + +int32_t CanChallengePlatform(PP_Resource instance, + PP_Bool* can_challenge_platform, + struct PP_CompletionCallback callback) { + VLOG(4) << "PPB_PlatformVerification_Private::CanChallengePlatform()"; + EnterResource<PPB_PlatformVerification_API> enter(instance, callback, true); + if (enter.failed()) + return enter.retval(); + return enter.SetResult(enter.object()->CanChallengePlatform( + can_challenge_platform, + enter.callback())); +} + +int32_t ChallengePlatform(PP_Resource instance, + struct PP_Var service_id, + struct PP_Var challenge, + struct PP_Var* signed_data, + struct PP_Var* signed_data_signature, + struct PP_Var* platform_key_certificate, + struct PP_CompletionCallback callback) { + VLOG(4) << "PPB_PlatformVerification_Private::ChallengePlatform()"; + EnterResource<PPB_PlatformVerification_API> enter(instance, callback, true); + if (enter.failed()) + return enter.retval(); + return enter.SetResult(enter.object()->ChallengePlatform( + service_id, + challenge, + signed_data, + signed_data_signature, + platform_key_certificate, + enter.callback())); +} + +const PPB_PlatformVerification_Private_0_1 + g_ppb_platformverification_private_thunk_0_1 = { + &Create, + &IsPlatformVerification, + &CanChallengePlatform, + &ChallengePlatform +}; + +} // namespace + +const PPB_PlatformVerification_Private_0_1* + GetPPB_PlatformVerification_Private_0_1_Thunk() { + return &g_ppb_platformverification_private_thunk_0_1; +} + +} // namespace thunk +} // namespace ppapi diff --git a/chromium/ppapi/thunk/ppb_tcp_socket_api.h b/chromium/ppapi/thunk/ppb_tcp_socket_api.h index d33685fd97f..beed0c6317a 100644 --- a/chromium/ppapi/thunk/ppb_tcp_socket_api.h +++ b/chromium/ppapi/thunk/ppb_tcp_socket_api.h @@ -19,6 +19,8 @@ class PPAPI_THUNK_EXPORT PPB_TCPSocket_API { public: virtual ~PPB_TCPSocket_API() {} + virtual int32_t Bind(PP_Resource addr, + scoped_refptr<TrackedCallback> callback) = 0; virtual int32_t Connect(PP_Resource addr, scoped_refptr<TrackedCallback> callback) = 0; virtual PP_Resource GetLocalAddress() = 0; @@ -29,6 +31,10 @@ class PPAPI_THUNK_EXPORT PPB_TCPSocket_API { virtual int32_t Write(const char* buffer, int32_t bytes_to_write, scoped_refptr<TrackedCallback> callback) = 0; + virtual int32_t Listen(int32_t backlog, + scoped_refptr<TrackedCallback> callback) = 0; + virtual int32_t Accept(PP_Resource* accepted_tcp_socket, + scoped_refptr<TrackedCallback> callback) = 0; virtual void Close() = 0; virtual int32_t SetOption(PP_TCPSocket_Option name, const PP_Var& value, diff --git a/chromium/ppapi/thunk/ppb_tcp_socket_thunk.cc b/chromium/ppapi/thunk/ppb_tcp_socket_thunk.cc index ff612fb54db..42ae702e5e3 100644 --- a/chromium/ppapi/thunk/ppb_tcp_socket_thunk.cc +++ b/chromium/ppapi/thunk/ppb_tcp_socket_thunk.cc @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -// From ppb_tcp_socket.idl modified Thu Jun 20 16:36:53 2013. +// From ppb_tcp_socket.idl modified Sun Sep 15 16:14:21 2013. #include "ppapi/c/pp_completion_callback.h" #include "ppapi/c/pp_errors.h" @@ -19,6 +19,14 @@ namespace thunk { namespace { +PP_Resource Create_1_0(PP_Instance instance) { + VLOG(4) << "PPB_TCPSocket::Create_1_0()"; + EnterResourceCreation enter(instance); + if (enter.failed()) + return 0; + return enter.functions()->CreateTCPSocket1_0(instance); +} + PP_Resource Create(PP_Instance instance) { VLOG(4) << "PPB_TCPSocket::Create()"; EnterResourceCreation enter(instance); @@ -33,6 +41,16 @@ PP_Bool IsTCPSocket(PP_Resource resource) { return PP_FromBool(enter.succeeded()); } +int32_t Bind(PP_Resource tcp_socket, + PP_Resource addr, + struct PP_CompletionCallback callback) { + VLOG(4) << "PPB_TCPSocket::Bind()"; + EnterResource<PPB_TCPSocket_API> enter(tcp_socket, callback, true); + if (enter.failed()) + return enter.retval(); + return enter.SetResult(enter.object()->Bind(addr, enter.callback())); +} + int32_t Connect(PP_Resource tcp_socket, PP_Resource addr, struct PP_CompletionCallback callback) { @@ -85,6 +103,27 @@ int32_t Write(PP_Resource tcp_socket, enter.callback())); } +int32_t Listen(PP_Resource tcp_socket, + int32_t backlog, + struct PP_CompletionCallback callback) { + VLOG(4) << "PPB_TCPSocket::Listen()"; + EnterResource<PPB_TCPSocket_API> enter(tcp_socket, callback, true); + if (enter.failed()) + return enter.retval(); + return enter.SetResult(enter.object()->Listen(backlog, enter.callback())); +} + +int32_t Accept(PP_Resource tcp_socket, + PP_Resource* accepted_tcp_socket, + struct PP_CompletionCallback callback) { + VLOG(4) << "PPB_TCPSocket::Accept()"; + EnterResource<PPB_TCPSocket_API> enter(tcp_socket, callback, true); + if (enter.failed()) + return enter.retval(); + return enter.SetResult(enter.object()->Accept(accepted_tcp_socket, + enter.callback())); +} + void Close(PP_Resource tcp_socket) { VLOG(4) << "PPB_TCPSocket::Close()"; EnterResource<PPB_TCPSocket_API> enter(tcp_socket, true); @@ -107,13 +146,28 @@ int32_t SetOption(PP_Resource tcp_socket, } const PPB_TCPSocket_1_0 g_ppb_tcpsocket_thunk_1_0 = { + &Create_1_0, + &IsTCPSocket, + &Connect, + &GetLocalAddress, + &GetRemoteAddress, + &Read, + &Write, + &Close, + &SetOption +}; + +const PPB_TCPSocket_1_1 g_ppb_tcpsocket_thunk_1_1 = { &Create, &IsTCPSocket, + &Bind, &Connect, &GetLocalAddress, &GetRemoteAddress, &Read, &Write, + &Listen, + &Accept, &Close, &SetOption }; @@ -124,5 +178,9 @@ const PPB_TCPSocket_1_0* GetPPB_TCPSocket_1_0_Thunk() { return &g_ppb_tcpsocket_thunk_1_0; } +const PPB_TCPSocket_1_1* GetPPB_TCPSocket_1_1_Thunk() { + return &g_ppb_tcpsocket_thunk_1_1; +} + } // namespace thunk } // namespace ppapi diff --git a/chromium/ppapi/thunk/ppb_url_util_thunk.cc b/chromium/ppapi/thunk/ppb_url_util_thunk.cc index 3dc9f3aa4bb..e4ba7b547ca 100644 --- a/chromium/ppapi/thunk/ppb_url_util_thunk.cc +++ b/chromium/ppapi/thunk/ppb_url_util_thunk.cc @@ -53,7 +53,15 @@ PP_Var GetPluginInstanceURL(PP_Instance instance, return enter.functions()->GetPluginInstanceURL(instance, components); } -const PPB_URLUtil_Dev g_ppb_url_util = { +PP_Var GetPluginReferrerURL(PP_Instance instance, + PP_URLComponents_Dev* components) { + EnterInstance enter(instance); + if (enter.failed()) + return PP_MakeUndefined(); + return enter.functions()->GetPluginReferrerURL(instance, components); +} + +const PPB_URLUtil_Dev_0_6 g_ppb_url_util_0_6 = { &PPB_URLUtil_Shared::Canonicalize, &PPB_URLUtil_Shared::ResolveRelativeToURL, &ResolveRelativeToDocument, @@ -64,10 +72,26 @@ const PPB_URLUtil_Dev g_ppb_url_util = { &GetPluginInstanceURL }; +const PPB_URLUtil_Dev_0_7 g_ppb_url_util_0_7 = { + &PPB_URLUtil_Shared::Canonicalize, + &PPB_URLUtil_Shared::ResolveRelativeToURL, + &ResolveRelativeToDocument, + &PPB_URLUtil_Shared::IsSameSecurityOrigin, + &DocumentCanRequest, + &DocumentCanAccessDocument, + &GetDocumentURL, + &GetPluginInstanceURL, + &GetPluginReferrerURL +}; + } // namespace const PPB_URLUtil_Dev_0_6* GetPPB_URLUtil_Dev_0_6_Thunk() { - return &g_ppb_url_util; + return &g_ppb_url_util_0_6; +} + +const PPB_URLUtil_Dev_0_7* GetPPB_URLUtil_Dev_0_7_Thunk() { + return &g_ppb_url_util_0_7; } } // namespace thunk diff --git a/chromium/ppapi/thunk/resource_creation_api.h b/chromium/ppapi/thunk/resource_creation_api.h index 082f1ccb070..aa731cfd7ba 100644 --- a/chromium/ppapi/thunk/resource_creation_api.h +++ b/chromium/ppapi/thunk/resource_creation_api.h @@ -5,7 +5,9 @@ #ifndef PPAPI_THUNK_RESOURCE_CREATION_API_H_ #define PPAPI_THUNK_RESOURCE_CREATION_API_H_ +#include "ppapi/c/dev/pp_video_dev.h" #include "ppapi/c/dev/ppb_file_chooser_dev.h" +#include "ppapi/c/dev/ppb_truetype_font_dev.h" #include "ppapi/c/pp_bool.h" #include "ppapi/c/pp_instance.h" #include "ppapi/c/pp_resource.h" @@ -15,11 +17,9 @@ #include "ppapi/c/ppb_graphics_3d.h" #include "ppapi/c/ppb_image_data.h" #include "ppapi/c/ppb_input_event.h" +#include "ppapi/c/ppb_network_monitor.h" #include "ppapi/c/ppb_websocket.h" -#include "ppapi/c/dev/pp_video_dev.h" -#include "ppapi/c/dev/ppb_truetype_font_dev.h" #include "ppapi/c/private/pp_private_font_charset.h" -#include "ppapi/c/private/ppb_network_monitor_private.h" #include "ppapi/shared_impl/api_id.h" #include "ppapi/shared_impl/ppb_image_data_shared.h" @@ -33,7 +33,7 @@ struct PP_Size; namespace ppapi { -struct PPB_FileRef_CreateInfo; +struct FileRefCreateInfo; struct URLRequestInfoData; struct URLResponseInfoData; @@ -49,19 +49,11 @@ class ResourceCreationAPI { virtual ~ResourceCreationAPI() {} virtual PP_Resource CreateFileIO(PP_Instance instance) = 0; - virtual PP_Resource CreateFileRef(PP_Instance instance, - PP_Resource file_system, - const char* path) = 0; - // Like the above version but takes a serialized file ref. The resource - // in the serialized file ref is passed into this, which takes ownership of - // the reference. In the proxy, the return value will be a plugin resource. - // In the impl, the return value will be the same resource ID. virtual PP_Resource CreateFileRef( - const PPB_FileRef_CreateInfo& serialized) = 0; + PP_Instance instance, + const FileRefCreateInfo& serialized) = 0; virtual PP_Resource CreateFileSystem(PP_Instance instance, PP_FileSystemType type) = 0; - virtual PP_Resource CreateIsolatedFileSystem(PP_Instance instance, - const char* fsid) = 0; virtual PP_Resource CreateIMEInputEvent(PP_Instance instance, PP_InputEvent_Type type, PP_TimeTicks time_stamp, @@ -110,6 +102,10 @@ class ResourceCreationAPI { const PP_FloatPoint* wheel_ticks, PP_Bool scroll_by_page) = 0; + virtual PP_Resource CreateAudio1_0(PP_Instance instance, + PP_Resource config_id, + PPB_Audio_Callback_1_0 audio_callback, + void* user_data) = 0; virtual PP_Resource CreateAudio(PP_Instance instance, PP_Resource config_id, PPB_Audio_Callback audio_callback, @@ -149,13 +145,11 @@ class ResourceCreationAPI { virtual PP_Resource CreateNetAddressFromNetAddressPrivate( PP_Instance instance, const PP_NetAddress_Private& private_addr) = 0; - virtual PP_Resource CreateNetworkMonitor( - PP_Instance instance, - PPB_NetworkMonitor_Callback callback, - void* user_data) = 0; + virtual PP_Resource CreateNetworkMonitor(PP_Instance instance) = 0; virtual PP_Resource CreatePrinting(PP_Instance instance) = 0; virtual PP_Resource CreateTCPServerSocketPrivate(PP_Instance instance) = 0; - virtual PP_Resource CreateTCPSocket(PP_Instance instace) = 0; + virtual PP_Resource CreateTCPSocket1_0(PP_Instance instace) = 0; + virtual PP_Resource CreateTCPSocket(PP_Instance instance) = 0; virtual PP_Resource CreateTCPSocketPrivate(PP_Instance instace) = 0; virtual PP_Resource CreateUDPSocket(PP_Instance instace) = 0; virtual PP_Resource CreateUDPSocketPrivate(PP_Instance instace) = 0; @@ -178,6 +172,8 @@ class ResourceCreationAPI { virtual PP_Resource CreateFlashMenu(PP_Instance instance, const PP_Flash_Menu* menu_data) = 0; virtual PP_Resource CreateFlashMessageLoop(PP_Instance instance) = 0; + virtual PP_Resource CreatePlatformVerificationPrivate( + PP_Instance instance) = 0; virtual PP_Resource CreateScrollbar(PP_Instance instance, PP_Bool vertical) = 0; virtual PP_Resource CreateTalk(PP_Instance instance) = 0; diff --git a/chromium/ppapi/utility/private/DEPS b/chromium/ppapi/utility/private/DEPS deleted file mode 100644 index ebf428559ef..00000000000 --- a/chromium/ppapi/utility/private/DEPS +++ /dev/null @@ -1,3 +0,0 @@ -include_rules = [ - "+ppapi/cpp/private", -] diff --git a/chromium/ppapi/utility/private/network_list_observer_private.cc b/chromium/ppapi/utility/private/network_list_observer_private.cc deleted file mode 100644 index 1969ee1e5f6..00000000000 --- a/chromium/ppapi/utility/private/network_list_observer_private.cc +++ /dev/null @@ -1,33 +0,0 @@ -// Copyright (c) 2012 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#include "ppapi/utility/private/network_list_observer_private.h" - -#include "ppapi/cpp/private/network_list_private.h" -#include "ppapi/cpp/module.h" - -namespace pp { - -NetworkListObserverPrivate::NetworkListObserverPrivate( - const InstanceHandle& instance) - : PP_ALLOW_THIS_IN_INITIALIZER_LIST( - monitor_(instance, - &NetworkListObserverPrivate::NetworkListCallbackHandler, - this)) { -} - -NetworkListObserverPrivate::~NetworkListObserverPrivate() { -} - -// static -void NetworkListObserverPrivate::NetworkListCallbackHandler( - void* user_data, - PP_Resource list_resource) { - NetworkListObserverPrivate* object = - static_cast<NetworkListObserverPrivate*>(user_data); - NetworkListPrivate list(PASS_REF, list_resource); - object->OnNetworkListChanged(list); -} - -} // namespace pp diff --git a/chromium/ppapi/utility/private/network_list_observer_private.h b/chromium/ppapi/utility/private/network_list_observer_private.h deleted file mode 100644 index 066f2ffd6e1..00000000000 --- a/chromium/ppapi/utility/private/network_list_observer_private.h +++ /dev/null @@ -1,49 +0,0 @@ -// Copyright (c) 2012 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#ifndef PPAPI_UTILITY_PRIVATE_NETWORK_LIST_OBSERVER_H_ -#define PPAPI_UTILITY_PRIVATE_NETWORK_LIST_OBSERVER_H_ - -#include "ppapi/cpp/private/network_monitor_private.h" - -namespace pp { - -class NetworkListPrivate; - -/// <code>NetworkListObserver</code> is a wrapper for -/// <code>pp::NetworkMonitorPrivate</code> that makes it easier to -/// handle network list update notifications. A child class must -/// implement the <code>OnNetworkListChanged()</code> method. That -/// method will be called once after the object is created and then -/// every time network configuration changes. -class NetworkListObserverPrivate { - public: - explicit NetworkListObserverPrivate(const InstanceHandle& instance); - virtual ~NetworkListObserverPrivate(); - - protected: - /// Called once after this object is created and later every time - /// network configuration changes. Child classes must implement this - /// method. - /// - /// @param[in] list The current list of network interfaces. - virtual void OnNetworkListChanged(const NetworkListPrivate& list) = 0; - - private: - // Private copy constructor and assign operator to disallow copying of this - // object. This is necessary to guarantee that |monitor_| is not shared with - // another list observer and is always destroyed when this object is - // destroyed. - NetworkListObserverPrivate(const NetworkListObserverPrivate&); - void operator=(const NetworkListObserverPrivate&); - - static void NetworkListCallbackHandler(void* user_data, - PP_Resource list_resource); - - NetworkMonitorPrivate monitor_; -}; - -} // namespace pp - -#endif // PPAPI_UTILITY_PRIVATE_NETWORK_LIST_OBSERVER_H_ |