summaryrefslogtreecommitdiff
path: root/ppapi
diff options
context:
space:
mode:
authorBen Murdoch <benm@google.com>2013-08-06 11:01:04 +0100
committerBen Murdoch <benm@google.com>2013-08-06 11:01:04 +0100
commit2385ea399aae016c0806a4f9ef3c9cfe3d2a39df (patch)
treee910e76d19265ff3230c473da95410d3f3a007af /ppapi
parent8ee924b76946696c0f52e56d28cc5ab741919041 (diff)
downloadchromium_org-2385ea399aae016c0806a4f9ef3c9cfe3d2a39df.tar.gz
Merge from Chromium at DEPS revision r215849
This commit was generated by merge_to_master.py. Change-Id: I225a31651af894e33bdd71e7121702bcbe5310f4
Diffstat (limited to 'ppapi')
-rw-r--r--ppapi/api/private/ppb_nacl_private.idl10
-rw-r--r--ppapi/c/private/ppb_nacl_private.h28
-rw-r--r--ppapi/native_client/native_client.gyp10
-rw-r--r--ppapi/native_client/src/trusted/plugin/pnacl_coordinator.cc41
-rw-r--r--ppapi/native_client/src/trusted/plugin/pnacl_coordinator.h3
-rw-r--r--ppapi/native_client/src/untrusted/pnacl_irt_shim/pnacl_shim.c6
-rw-r--r--ppapi/native_client/src/untrusted/pnacl_support_extension/README60
-rw-r--r--ppapi/native_client/src/untrusted/pnacl_support_extension/autoupdate-ascii-chrome-component-portable-nacl.config56
-rwxr-xr-xppapi/native_client/src/untrusted/pnacl_support_extension/pnacl_component_crx_gen.py306
-rw-r--r--ppapi/native_client/src/untrusted/pnacl_support_extension/pnacl_manifest_template.json7
-rw-r--r--ppapi/native_client/src/untrusted/pnacl_support_extension/pnacl_support_extension.gyp2
-rw-r--r--ppapi/ppapi_proxy.gypi4
-rw-r--r--ppapi/ppapi_shared.gypi3
-rw-r--r--ppapi/ppapi_shared.target.darwin-arm.mk1
-rw-r--r--ppapi/ppapi_shared.target.darwin-mips.mk1
-rw-r--r--ppapi/ppapi_shared.target.darwin-x86.mk1
-rw-r--r--ppapi/ppapi_shared.target.linux-arm.mk1
-rw-r--r--ppapi/ppapi_shared.target.linux-mips.mk1
-rw-r--r--ppapi/ppapi_shared.target.linux-x86.mk1
-rw-r--r--ppapi/proxy/interface_list.cc1
-rw-r--r--ppapi/proxy/ppapi_messages.h53
-rw-r--r--ppapi/proxy/ppb_tcp_server_socket_private_proxy.cc199
-rw-r--r--ppapi/proxy/ppb_tcp_server_socket_private_proxy.h60
-rw-r--r--ppapi/proxy/resource_creation_proxy.cc5
-rw-r--r--ppapi/proxy/tcp_server_socket_private_resource.cc138
-rw-r--r--ppapi/proxy/tcp_server_socket_private_resource.h69
-rw-r--r--ppapi/shared_impl/api_id.h2
-rw-r--r--ppapi/shared_impl/private/ppb_tcp_server_socket_shared.cc121
-rw-r--r--ppapi/shared_impl/private/ppb_tcp_server_socket_shared.h84
-rw-r--r--ppapi/tests/test_case.cc20
-rw-r--r--ppapi/tests/test_case.h23
-rw-r--r--ppapi/tests/test_file_io.cc4
-rw-r--r--ppapi/thunk/interfaces_ppb_private_no_permissions.h7
33 files changed, 343 insertions, 985 deletions
diff --git a/ppapi/api/private/ppb_nacl_private.idl b/ppapi/api/private/ppb_nacl_private.idl
index 9e4e898abe..1054723c85 100644
--- a/ppapi/api/private/ppb_nacl_private.idl
+++ b/ppapi/api/private/ppb_nacl_private.idl
@@ -79,10 +79,16 @@ interface PPB_NaCl_Private {
[in] uint32_t desired_access,
[in] uint32_t options);
+ /* Check if PNaCl is installed and attempt to install if necessary.
+ * Callback is called when the check is done and PNaCl is already installed,
+ * or after an on-demand install is attempted. Called back with PP_OK if
+ * PNaCl is available. Called back with an error otherwise.
+ */
+ int32_t EnsurePnaclInstalled([in] PP_Instance instance,
+ [in] PP_CompletionCallback callback);
+
/* Returns a read-only file descriptor of a file rooted in the Pnacl
* component directory, or an invalid handle on failure.
- * Do we want this to take a completion callback and be async, or
- * could we make this happen on another thread?
*/
PP_FileHandle GetReadonlyPnaclFd([in] str_t filename);
diff --git a/ppapi/c/private/ppb_nacl_private.h b/ppapi/c/private/ppb_nacl_private.h
index bab26c5120..d89ed5b047 100644
--- a/ppapi/c/private/ppb_nacl_private.h
+++ b/ppapi/c/private/ppb_nacl_private.h
@@ -3,7 +3,7 @@
* found in the LICENSE file.
*/
-/* From private/ppb_nacl_private.idl modified Tue Jul 23 13:16:52 2013. */
+/* From private/ppb_nacl_private.idl modified Mon Jul 29 16:44:58 2013. */
#ifndef PPAPI_C_PRIVATE_PPB_NACL_PRIVATE_H_
#define PPAPI_C_PRIVATE_PPB_NACL_PRIVATE_H_
@@ -50,9 +50,9 @@ typedef enum {
*/
/* PPB_NaCl_Private */
struct PPB_NaCl_Private_1_0 {
- /* Launches NaCl's sel_ldr process. Returns PP_NACL_OK on success and
- * writes a NaClHandle to imc_handle. Returns PP_NACL_FAILED on failure.
- * The |enable_ppapi_dev| parameter controls whether GetInterface
+ /* Launches NaCl's sel_ldr process. Returns PP_EXTERNAL_PLUGIN_OK on success
+ * and writes a NaClHandle to imc_handle. Returns PP_EXTERNAL_PLUGIN_FAILED on
+ * failure. The |enable_ppapi_dev| parameter controls whether GetInterface
* returns 'Dev' interfaces to the NaCl plugin. The |uses_ppapi| flag
* indicates that the nexe run by sel_ldr will use the PPAPI APIs.
* This implies that LaunchSelLdr is run from the main thread. If a nexe
@@ -74,11 +74,12 @@ struct PPB_NaCl_Private_1_0 {
void* imc_handle,
struct PP_Var* error_message);
/* This function starts the IPC proxy so the nexe can communicate with the
- * browser. Returns PP_NACL_OK on success, otherwise a result code indicating
- * the failure. PP_NACL_FAILED is returned if LaunchSelLdr wasn't called with
- * the instance. PP_NACL_ERROR_MODULE is returned if the module can't be
- * initialized. PP_NACL_ERROR_INSTANCE is returned if the instance can't be
- * initialized. PP_NACL_USE_SRPC is returned if the plugin should use SRPC.
+ * browser. Returns PP_EXTERNAL_PLUGIN_OK on success, otherwise a result code
+ * indicating the failure. PP_EXTERNAL_PLUGIN_FAILED is returned if
+ * LaunchSelLdr wasn't called with the instance.
+ * PP_EXTERNAL_PLUGIN_ERROR_MODULE is returned if the module can't be
+ * initialized. PP_EXTERNAL_PLUGIN_ERROR_INSTANCE is returned if the instance
+ * can't be initialized.
*/
PP_ExternalPluginResult (*StartPpapiProxy)(PP_Instance instance);
/* On POSIX systems, this function returns the file descriptor of
@@ -101,10 +102,15 @@ struct PPB_NaCl_Private_1_0 {
PP_FileHandle* target_handle,
uint32_t desired_access,
uint32_t options);
+ /* Check if PNaCl is installed and attempt to install if necessary.
+ * Callback is called when the check is done and PNaCl is already installed,
+ * or after an on-demand install is attempted. Called back with PP_OK if
+ * PNaCl is available. Called back with an error otherwise.
+ */
+ int32_t (*EnsurePnaclInstalled)(PP_Instance instance,
+ struct PP_CompletionCallback callback);
/* Returns a read-only file descriptor of a file rooted in the Pnacl
* component directory, or an invalid handle on failure.
- * Do we want this to take a completion callback and be async, or
- * could we make this happen on another thread?
*/
PP_FileHandle (*GetReadonlyPnaclFd)(const char* filename);
/* This creates a temporary file that will be deleted by the time
diff --git a/ppapi/native_client/native_client.gyp b/ppapi/native_client/native_client.gyp
index 5ab56198ea..aca69d7b14 100644
--- a/ppapi/native_client/native_client.gyp
+++ b/ppapi/native_client/native_client.gyp
@@ -128,6 +128,9 @@
'-Wl,<(NACL_RODATA_FLAG)=<(NACL_IRT_DATA_START)',
'-Wl,-Ttext-segment=<(NACL_IRT_TEXT_START)',
],
+ 'extra_args': [
+ '--strip-all',
+ ],
'conditions': [
# untrusted.gypi and build_nexe.py currently build
# both x86-32 and x86-64 whenever target_arch is some
@@ -142,12 +145,7 @@
{
'enable_x86_32': 0
}
- ]
- ],
- 'extra_args': [
- '--strip-all',
- ],
- 'conditions': [
+ ],
['target_arch!="arm"', {
'extra_deps_newlib64': [
'>(tc_lib_dir_irt64)/libppapi_proxy_untrusted.a',
diff --git a/ppapi/native_client/src/trusted/plugin/pnacl_coordinator.cc b/ppapi/native_client/src/trusted/plugin/pnacl_coordinator.cc
index f22cfa437c..e5649f3dd8 100644
--- a/ppapi/native_client/src/trusted/plugin/pnacl_coordinator.cc
+++ b/ppapi/native_client/src/trusted/plugin/pnacl_coordinator.cc
@@ -241,19 +241,13 @@ PnaclCoordinator* PnaclCoordinator::BitcodeToNative(
reinterpret_cast<const void*>(coordinator->manifest_.get()),
coordinator->off_the_record_));
- // Loading resources (e.g. llc and ld nexes) is done with PnaclResources.
- coordinator->resources_.reset(
- new PnaclResources(plugin,
- coordinator,
- coordinator->manifest_.get()));
- CHECK(coordinator->resources_ != NULL);
-
- // The first step of loading resources: read the resource info file.
- pp::CompletionCallback resource_info_read_cb =
+ // First check that PNaCl is installed.
+ pp::CompletionCallback pnacl_installed_cb =
coordinator->callback_factory_.NewCallback(
- &PnaclCoordinator::ResourceInfoWasRead);
- coordinator->resources_->ReadResourceInfo(PnaclUrls::GetResourceInfoUrl(),
- resource_info_read_cb);
+ &PnaclCoordinator::DidCheckPnaclInstalled);
+ plugin->nacl_interface()->EnsurePnaclInstalled(
+ plugin->pp_instance(),
+ pnacl_installed_cb.pp_completion_callback());
return coordinator;
}
@@ -664,6 +658,29 @@ void PnaclCoordinator::NexeReadDidOpen(int32_t pp_error) {
translate_notify_callback_.Run(pp_error);
}
+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."));
+ return;
+ }
+
+ // Loading resources (e.g. llc and ld nexes) is done with PnaclResources.
+ resources_.reset(new PnaclResources(plugin_,
+ this,
+ this->manifest_.get()));
+ CHECK(resources_ != NULL);
+
+ // The first step of loading resources: read the resource info file.
+ pp::CompletionCallback resource_info_read_cb =
+ callback_factory_.NewCallback(
+ &PnaclCoordinator::ResourceInfoWasRead);
+ resources_->ReadResourceInfo(PnaclUrls::GetResourceInfoUrl(),
+ resource_info_read_cb);
+}
+
void PnaclCoordinator::ResourceInfoWasRead(int32_t pp_error) {
PLUGIN_PRINTF(("PluginCoordinator::ResourceInfoWasRead (pp_error=%"
NACL_PRId32 ")\n", pp_error));
diff --git a/ppapi/native_client/src/trusted/plugin/pnacl_coordinator.h b/ppapi/native_client/src/trusted/plugin/pnacl_coordinator.h
index 1cd430cfc7..06ff7c7234 100644
--- a/ppapi/native_client/src/trusted/plugin/pnacl_coordinator.h
+++ b/ppapi/native_client/src/trusted/plugin/pnacl_coordinator.h
@@ -148,6 +148,9 @@ class PnaclCoordinator: public CallbackSource<FileStreamData> {
const PnaclOptions& pnacl_options,
const pp::CompletionCallback& translate_notify_callback);
+ // Callback for when we know PNaCl is installed.
+ void DidCheckPnaclInstalled(int32_t pp_error);
+
// Callback for when the resource info JSON file has been read.
void ResourceInfoWasRead(int32_t pp_error);
diff --git a/ppapi/native_client/src/untrusted/pnacl_irt_shim/pnacl_shim.c b/ppapi/native_client/src/untrusted/pnacl_irt_shim/pnacl_shim.c
index 9d46f3599f..9eabc69d76 100644
--- a/ppapi/native_client/src/untrusted/pnacl_irt_shim/pnacl_shim.c
+++ b/ppapi/native_client/src/untrusted/pnacl_irt_shim/pnacl_shim.c
@@ -2838,6 +2838,11 @@ static int32_t Pnacl_M13_PPB_NaCl_Private_BrokerDuplicateHandle(PP_FileHandle so
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) {
+ 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) {
const struct PPB_NaCl_Private_1_0 *iface = Pnacl_WrapperInfo_PPB_NaCl_Private_1_0.real_iface;
return iface->GetReadonlyPnaclFd(filename);
@@ -4663,6 +4668,7 @@ struct PPB_NaCl_Private_1_0 Pnacl_Wrappers_PPB_NaCl_Private_1_0 = {
.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,
diff --git a/ppapi/native_client/src/untrusted/pnacl_support_extension/README b/ppapi/native_client/src/untrusted/pnacl_support_extension/README
index d2c3a2858c..8f419dd12d 100644
--- a/ppapi/native_client/src/untrusted/pnacl_support_extension/README
+++ b/ppapi/native_client/src/untrusted/pnacl_support_extension/README
@@ -1,56 +1,8 @@
How to package PNaCl translator components (llc, ld, native libs) for Chrome.
-We are approaching this two ways. One is more production-friendly.
-Another is more friendly to churn (e.g., during dogfood).
-
-(A) Prod-ready: Install and update using the Chrome component updater
- (like Pepper Flash). This is distributed through Omaha.
-(B) Churn-friendly: Install via the chrome webstore, as an extension.
-
-With (A) the installer/updater can check the exact target architecture
-and only install those files. The omaha config can also detect your
-Chromium version to determine which translator files go with
-that Chromium version's NaCl plugin (which contains the PNaCl coordinator).
-
-With (B) the chrome webstore will not ask for arch and chrome version,
-so we are stuck with one package for all of the latest chrome channels.
-- However, uploading to the webstore is easy and does not require
-editting config files and pushing those config files to Omaha.
-
-
-How update for scenario (A)
-
-- The Chrome component updater uses Chrome Extensions (CRX) files as an
- archive format. Thus, we need to generate a CRX via the included script.
-- Place the new CRX at an accessible URL. Each version must have a different
- URL. A simple way to do this is to add the version quad to the URL.
-- Edit autoupdate-ascii-pnacl.config with the new version information.
- See "prodversionmin:", etc. for the chrome version requirements -- tweak
- this to control which version of PNaCl is matched with different
- versions / channels of Chrome.
- See "UpdatedVersion:" for the version of PNaCl.
- See the "Codebase:" URL for the location of the the new version.
- Again, new versions must have new URLs.
- See Omaha docs for the format.
-- Validate the config file. Search for doc "OmahaServerUpdate" for how
- to validate this new config file.
-- Send the new autoupdate-ascii-pnacl.config to the omaha staging sandbox.
- See the internal Omaha wikis for how to do this.
-- If the staging sandbox works okay, then do a bigger push.
- TODO(jvoung): figure out how to do the bigger push from Omaha folks.
- Eventually, the Chromium PMs will be responsible for these pushes.
-
-
-MISC: To discover the public Chrome Extension ID that is specified
-in the omaha config, use chromium/src/tools/crx_id/crx_id.py
-We keep these the same across all versions to simplify the Omaha config
-(one Omaha file instead of a new one each time). This sameness is achieved
-by reusing the old private key to generate the new versions.
-The AppId must also match the Chromium code that pings Omaha (baked in AppID).
-
-
-How update for (B)
-
-- Generate .zip representing the CRX using the include script.
-- Upload .zip to the chrome webstore.
-- Hit publish button on chrome webstore to make it available.
+Run gyp w/ GYP_DEFINES "target_arch=arm", ia32, x64, etc. to compile the
+PNaCl shim for each architecture. Running gyp will also run the
+python script in this directory once for each architecture, and set up
+a target-specific set of translators. Zip up the multi-CRX, upload,
+do QA, and publish. See internal wiki "PNaCl Translator in Chrome" for
+convenience scripts and more details.
diff --git a/ppapi/native_client/src/untrusted/pnacl_support_extension/autoupdate-ascii-chrome-component-portable-nacl.config b/ppapi/native_client/src/untrusted/pnacl_support_extension/autoupdate-ascii-chrome-component-portable-nacl.config
deleted file mode 100644
index c851550cdc..0000000000
--- a/ppapi/native_client/src/untrusted/pnacl_support_extension/autoupdate-ascii-chrome-component-portable-nacl.config
+++ /dev/null
@@ -1,56 +0,0 @@
-# PNaCl Omaha Config
-# For docs, search for "omaha-server-configuration-format" on the sites page.
-
-# TODO(jvoung): update this app ID to the real one.
-# There is a possibility of using the private key from the Webstore version.
-# See README for how to read the AppId and "Raw Bytes" out from the CRX file.
-# Raw Bytes: {0x4c, 0xa7, 0x26, 0x86, 0xa8, 0x26, 0x83, 0x4d, 0x3c, 0x55,
-# 0x8c, 0x8b, 0x54, 0x7e, 0x27, 0x46, 0xa0, 0xf8, 0xd5, 0x0e, 0xea,
-# 0x33, 0x46, 0x6e, 0xab, 0x6c, 0xde, 0xba, 0xc0, 0x91, 0xd4, 0x5e}
-AppId: "emkhcgigkicgidendmffimilfehocheg"
-ConfigName: "Chrome Portable NaCl"
-
-############################################################
-
-Rule {
- Test {Attr: "arch" Match: "x86"}
- Test {Version: "[0.0.0.0-0.1.0.12)"}
- Update {
- Pair: {Tag: "version" Value: "0.1.0.12"}
- Pair: {Tag: "prodversionmin" Value: "21.0.0.0"}
- UpdatedVersion: "0.1.0.12"
- # TODO(jvoung): Could this be hosted on omaha.corp instead?
- # If so, document how to update the binaries (including the note about
- # changing the directory name with each version).
- Codebase: "https://www.corp.google.com/~jvoung/pnacl/0.1.0.12/x86-32.crx"
- }
-}
-
-Rule {
- Test {Attr: "arch" Match: "x64"}
- Test {Version: "[0.0.0.0-0.1.0.12)"}
- Update {
- Pair: {Tag: "version" Value: "0.1.0.12"}
- Pair: {Tag: "prodversionmin" Value: "21.0.0.0"}
- UpdatedVersion: "0.1.0.12"
- Codebase: "https://www.corp.google.com/~jvoung/pnacl/0.1.0.12/x86-64.crx"
- }
-}
-
-# TODO(jvoung): Change this to the real the arch tag for ARM, sent by the
-# component updater's query string (it doesn't have that case yet).
-Rule {
- Test {Attr: "arch" Match: "arm"}
- Test {Version: "[0.0.0.0-0.1.0.12)"}
- Update {
- Pair: {Tag: "version" Value: "0.1.0.12"}
- Pair: {Tag: "prodversionmin" Value: "21.0.0.0"}
- UpdatedVersion: "0.1.0.12"
- Codebase: "https://www.corp.google.com/~jvoung/pnacl/0.1.0.12/arm.crx"
- }
-}
-
-Rule {
- # Catch all, no update
- NoUpdate: true
-}
diff --git a/ppapi/native_client/src/untrusted/pnacl_support_extension/pnacl_component_crx_gen.py b/ppapi/native_client/src/untrusted/pnacl_support_extension/pnacl_component_crx_gen.py
index 8b16de95f4..4a12c4a361 100755
--- a/ppapi/native_client/src/untrusted/pnacl_support_extension/pnacl_component_crx_gen.py
+++ b/ppapi/native_client/src/untrusted/pnacl_support_extension/pnacl_component_crx_gen.py
@@ -3,32 +3,22 @@
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
-"""This script packages the PNaCl translator files as:
- (1) a Chrome Extension (crx), which can be used as a straight-forward CRX,
- or used with the Chrome incremental installer (component updater)
- (2) a Chrome Extension as a zip for uploading to the CWS.
- (3) layout files for a normal Chrome installer.
+"""This script lays out the PNaCl translator files for a
+ normal Chrome installer, for one platform. Once run num-of-arches times,
+ the result can then be packed into a multi-CRX zip file.
This script depends on and pulls in the translator nexes and libraries
from the toolchain directory (so that must be downloaded first) and
it depends on the pnacl_irt_shim.
"""
-import glob
import logging
import optparse
import os
import platform
import re
import shutil
-import subprocess
import sys
-import tempfile
-import zipfile
-
-# shutil.copytree does not allow the target directory to exist.
-# Borrow this copy_tree, which does allow it (overwrites conflicts?).
-from distutils.dir_util import copy_tree as copytree_existing
J = os.path.join
@@ -129,38 +119,6 @@ def DetermineInstallerArches(target_arch):
return [arch]
-class CRXGen(object):
- """ Generate a CRX file. Can generate a fresh CRX and private key, or
- create a version of new CRX with the same AppID, using an existing
- private key.
-
- NOTE: We use the chrome binary to do CRX packing. There is also a bash
- script available at: http://code.google.com/chrome/extensions/crx.html
- but it is not featureful (doesn't know how to generate private keys).
-
- We should probably make a version of this that doesn't require chrome.
- """
-
- @staticmethod
- def RunCRXGen(chrome_path, manifest_dir, private_key=None):
- if chrome_path is None:
- raise Exception('Chrome binary not specified!')
- if not os.path.isfile(chrome_path):
- raise Exception('Chrome binary not found: %s' % chrome_path)
- cmdline = []
- if BUILD_PLATFORM == 'linux':
- # In linux, run chrome in headless mode (even though crx-packing should
- # be headless, it's not quite with the zygote). This allows you to
- # run the tool under ssh or screen, etc.
- cmdline.append('xvfb-run')
- cmdline += [chrome_path, '--pack-extension=%s' % manifest_dir]
- if private_key is not None:
- cmdline.append('--pack-extension-key=%s' % private_key)
- StepBanner('GEN CRX', str(cmdline))
- if subprocess.call(cmdline) != 0:
- raise Exception('Failed to RunCRXGen: %s' % (cmdline))
-
-
######################################################################
def IsValidVersion(version):
@@ -174,26 +132,7 @@ def IsValidVersion(version):
class PnaclPackaging(object):
- # For dogfooding, we also create a webstore extension.
- # See: https://chrome.google.com/webstore/a/google.com/detail/gcodniebolpnpaiggndmcmmfpldlknih
- # To test offline, we need to be able to load via the command line on chrome,
- # but we also need the AppID to remain the same. Thus we supply the
- # public key in the unpacked/offline extension manifest. See:
- # http://code.google.com/chrome/extensions/manifest.html#key
- # Summary:
- # 1) install the extension, then look for key in
- # 2) <profile>/Default/Extensions/<extensionId>/<versionString>/manifest.json
- # (Fret not -- this is not the private key, it's just a key stored in the
- # user's profile directory).
- WEBSTORE_PUBLIC_KEY = ("MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQC7zhW8iyt"
- "dYid7SXLokWfxNoz2Co9x2ItkVUS53Iq12xDLfcKkUZ2RNX"
- "Qtua+yKgRTRMP0HigPtn2KZeeJYzvBYLP/kz62B3nM5nS8M"
- "o0qQKEsJiNgTf1uOgYGPyrE6GrFBFolLGstnZ1msVgNHEv2"
- "dZruC2XewOJihvmeQsOjjwIDAQAB")
-
package_base = os.path.dirname(__file__)
- # The extension system's manifest.json.
- manifest_template = J(package_base, 'pnacl_manifest_template.json')
# Pnacl-specific info - set from the command line.
pnacl_template = None
@@ -206,39 +145,6 @@ class PnaclPackaging(object):
PnaclPackaging.pnacl_template = path
@staticmethod
- def GenerateManifests(target_dir, version, arch, web_accessible,
- all_host_permissions,
- manifest_key=None):
- PnaclPackaging.GenerateExtensionManifest(target_dir, version,
- web_accessible,
- all_host_permissions,
- manifest_key)
- # For now, make the ABI version the same as pnacl-version...
- # It should probably be separate though.
- PnaclPackaging.GeneratePnaclInfo(target_dir, version, arch)
-
-
- @staticmethod
- def GenerateExtensionManifest(target_dir, version,
- web_accessible, all_host_permissions,
- manifest_key):
- manifest_template_fd = open(PnaclPackaging.manifest_template, 'r')
- manifest_template = manifest_template_fd.read()
- manifest_template_fd.close()
- output_fd = open(J(target_dir, 'manifest.json'), 'w')
- extra = ''
- if web_accessible != []:
- extra += '"web_accessible_resources": [\n%s],\n' % ',\n'.join(
- [ ' "%s"' % to_quote for to_quote in web_accessible ])
- if manifest_key is not None:
- extra += ' "key": "%s",\n' % manifest_key
- if all_host_permissions:
- extra += ' "permissions": ["http://*/"],\n'
- output_fd.write(manifest_template % { "version" : version,
- "extra" : extra, })
- output_fd.close()
-
- @staticmethod
def GeneratePnaclInfo(target_dir, version, arch, is_installer=False):
pnacl_template_fd = open(PnaclPackaging.pnacl_template, 'r')
pnacl_template = pnacl_template_fd.read()
@@ -249,11 +155,6 @@ class PnaclPackaging(object):
else:
out_name = J(target_dir, PnaclPackaging.pnacl_json)
output_fd = open(out_name, 'w')
- if isinstance(arch, list):
- # FIXME: Handle a list of arches, not just a wildcard "all".
- # Alternatively, perhaps we shouldn't bother checking what arch is
- # installed and assume the installer does the right thing.
- arch = 'all'
output_fd.write(pnacl_template % { "abi-version" : version,
"arch" : arch, })
output_fd.close()
@@ -319,173 +220,6 @@ def Clean():
######################################################################
-
-def ZipDirectory(base_dir, zipfile):
- """ Zip all the files in base_dir into the given opened zipfile object.
- """
- for (root, dirs, files) in os.walk(base_dir, followlinks=True):
- for f in files:
- full_name = J(root, f)
- zipfile.write(full_name, os.path.relpath(full_name, base_dir))
-
-
-def ListDirectoryRecursivelyAsURLs(base_dir):
- """ List all files that can be found from base_dir. Return names as
- URLs relative to the base_dir.
- """
- file_list = []
- for (root, dirs, files) in os.walk(base_dir, followlinks=True):
- for f in files:
- full_name = J(root, f)
- if os.path.isfile(full_name):
- rel_name = os.path.relpath(full_name, base_dir)
- url = '/'.join(rel_name.split(os.path.sep))
- file_list.append(url)
- return file_list
-
-
-def GetWebAccessibleResources(base_dir):
- ''' Return the default list of web_accessible_resources to allow us
- to do a CORS request to get extension files. '''
- resources = ListDirectoryRecursivelyAsURLs(base_dir)
- # Make sure that the pnacl.json file is accessible.
- resources.append(os.path.basename(PnaclPackaging.pnacl_json))
- return resources
-
-def GeneratePrivateKey(options):
- """ Generate a dummy extension to generate a fresh private key. This will
- be left in the build dir, and the dummy extension will be cleaned up.
- """
- StepBanner('GEN PRIVATE KEY', 'Generating fresh private key')
- tempdir = tempfile.mkdtemp(dir=PnaclDirs.OutputDir())
- ext_dir = J(tempdir, 'dummy_extension')
- os.mkdir(ext_dir)
- PnaclPackaging.GenerateManifests(ext_dir,
- '0.0.0.0',
- 'dummy_arch',
- [],
- False)
- CRXGen.RunCRXGen(options.chrome_path, ext_dir)
- shutil.copy(J(tempdir, 'dummy_extension.pem'),
- PnaclDirs.OutputDir())
- shutil.rmtree(tempdir)
- logging.info('\n<<< Fresh key is now in %s/dummy_extension.pem >>>\n' %
- PnaclDirs.OutputDir())
-
-
-def BuildArchCRXForComponentUpdater(version_quad, arch, lib_overrides,
- options):
- """ Build an architecture specific version for the chrome component
- install (an actual CRX, vs a zip file). Though this is a CRX,
- it is not used as a chrome extension as the CWS and unpacked version.
- """
- parent_dir, target_dir = PnaclDirs.OutputArchDir(arch)
-
- StepBanner('BUILD ARCH CRX %s' % arch,
- 'Packaging for arch %s in %s' % (arch, target_dir))
-
- # Copy llc and ld.
- copytree_existing(PnaclDirs.SandboxedCompilerDir(arch), target_dir)
-
- # Rename llc.nexe to llc, ld.nexe to ld
- for tool in ('llc', 'ld'):
- shutil.move(J(target_dir, '%s.nexe' % tool), J(target_dir, tool))
-
- # Copy native libraries.
- copytree_existing(PnaclDirs.LibDir(arch), target_dir)
- # Also copy files from the list of overrides.
- if arch in lib_overrides:
- for override in lib_overrides[arch]:
- logging.info('Copying override %s to %s' % (override, target_dir))
- shutil.copy(override, target_dir)
-
- # Skip the CRX generation if we are only building the unpacked version
- # for commandline testing.
- if options.unpacked_only:
- return
-
- # Generate manifest one level up (to have layout look like the "all" package).
- # NOTE: this does not have 'web_accessible_resources' and does not have
- # the all_host_permissions, since it isn't used via chrome-extension://
- # URL requests.
- PnaclPackaging.GenerateManifests(parent_dir,
- version_quad,
- arch,
- [],
- False)
- CRXGen.RunCRXGen(options.chrome_path, parent_dir, options.prev_priv_key)
-
-
-def LayoutAllDir(version_quad):
- StepBanner("Layout All Dir", "Copying Arch specific to Arch-independent.")
- target_dir = PnaclDirs.OutputAllDir(version_quad)
- for arch in ARCHES:
- arch_parent, arch_dir = PnaclDirs.OutputArchDir(arch)
- # NOTE: The arch_parent contains the arch-specific manifest.json files.
- # We carefully avoid copying those to the "all dir" since having
- # more than one manifest.json will confuse the CRX tools (e.g., you will
- # get a mysterious failure when uploading to the webstore).
- copytree_existing(arch_dir,
- J(target_dir, PnaclDirs.OutputArchBase(arch)))
-
-
-def BuildCWSZip(version_quad):
- """ Build a 'universal' chrome extension zipfile for webstore use (where the
- installer doesn't know the target arch). Assumes the individual arch
- versions were built.
- """
- StepBanner("CWS ZIP", "Making a zip with all architectures.")
- target_dir = PnaclDirs.OutputAllDir(version_quad)
-
- web_accessible = GetWebAccessibleResources(target_dir)
-
- # Overwrite the arch-specific 'manifest.json' that was there.
- PnaclPackaging.GenerateManifests(target_dir,
- version_quad,
- 'all',
- web_accessible,
- True)
- target_zip = J(PnaclDirs.OutputDir(), 'pnacl_all.zip')
- zipf = zipfile.ZipFile(target_zip, 'w', compression=zipfile.ZIP_DEFLATED)
- ZipDirectory(target_dir, zipf)
- zipf.close()
-
-
-def BuildUnpacked(version_quad):
- """ Build an unpacked chrome extension with all files for commandline
- testing (load on chrome commandline).
- """
- StepBanner("UNPACKED CRX", "Making an unpacked CRX of all architectures.")
-
- target_dir = PnaclDirs.OutputAllDir(version_quad)
- web_accessible = GetWebAccessibleResources(target_dir)
- # Overwrite the manifest file (if there was one already).
- PnaclPackaging.GenerateManifests(target_dir,
- version_quad,
- 'all',
- web_accessible,
- True,
- PnaclPackaging.WEBSTORE_PUBLIC_KEY)
-
-
-def BuildExtensionStyle(version_quad, lib_overrides, options):
- """ Package the pnacl components 3 ways, all of which are
- chrome-extension-like.
-
- 1) Arch-specific CRXes that can be queried by Omaha.
- 2) A zip containing all arch files for the Chrome Webstore.
- 3) An unpacked extension with all arch files for offline testing.
- """
- StepBanner("BUILD_ALL", "Packaging extension for version: %s" % version_quad)
- for arch in ARCHES:
- BuildArchCRXForComponentUpdater(version_quad, arch, lib_overrides, options)
- LayoutAllDir(version_quad)
- if not options.unpacked_only:
- BuildCWSZip(version_quad)
- BuildUnpacked(version_quad)
-
-######################################################################
-
def UseWhitelistedChars(orig_basename, arch):
""" Make the filename match the pattern expected by nacl_file_host.
@@ -515,7 +249,7 @@ def CopyFlattenDirsAndPrefix(src_dir, arch, dest_dir):
shutil.copy(full_name, J(dest_dir, target_name))
-def BuildArchForInstaller(version_quad, arch, lib_overrides, options):
+def BuildArchForInstaller(version_quad, arch, lib_overrides):
""" Build an architecture specific version for the chrome installer.
"""
target_dir = PnaclDirs.OutputDir()
@@ -540,15 +274,14 @@ def BuildArchForInstaller(version_quad, arch, lib_overrides, options):
shutil.copy(override, J(target_dir, target_name))
-def BuildInstallerStyle(version_quad, lib_overrides, options):
+def BuildInstallerStyle(version_quad, lib_overrides, arches):
""" Package the pnacl component for use within the chrome installer
infrastructure. These files need to be named in a special way
so that white-listing of files is easy.
"""
StepBanner("BUILD_ALL", "Packaging installer for version: %s" % version_quad)
- arches = DetermineInstallerArches(options.installer_only)
for arch in arches:
- BuildArchForInstaller(version_quad, arch, lib_overrides, options)
+ BuildArchForInstaller(version_quad, arch, lib_overrides)
# Generate pnacl info manifest.
# Hack around the fact that there may be more than one arch, on Windows.
if len(arches) == 1:
@@ -568,30 +301,19 @@ def Main():
parser.add_option('-c', '--clean', dest='clean',
action='store_true', default=False,
help='Clean out destination directory first.')
- parser.add_option('-u', '--unpacked_only', action='store_true',
- dest='unpacked_only', default=False,
- help='Only generate the unpacked version')
- parser.add_option('-i', '--installer_only',
- dest='installer_only', default=None,
- help='Only generate the chrome installer version for arch')
parser.add_option('-d', '--dest', dest='dest',
help='The destination root for laying out the extension')
- parser.add_option('-p', '--priv_key',
- dest='prev_priv_key', default=None,
- help='Specify the old private key')
parser.add_option('-L', '--lib_override',
dest='lib_overrides', action='append', default=[],
help='Specify path to a fresher native library ' +
'that overrides the tarball library with ' +
'(arch:libfile) tuple.')
- parser.add_option('-g', '--generate_key',
- action='store_true', dest='gen_key',
- help='Generate a fresh private key, and exit.')
+ parser.add_option('-t', '--target_arch',
+ dest='target_arch', default=None,
+ help='Only generate the chrome installer version for arch')
parser.add_option('--info_template_path',
dest='info_template_path', default=None,
help='Path of the info template file')
- parser.add_option('-C', '--chrome_path', dest='chrome_path',
- help='Location of chrome.')
parser.add_option('-v', '--verbose', dest='verbose', default=False,
action='store_true',
help='Print verbose debug messages.')
@@ -611,10 +333,6 @@ def Main():
if options.clean:
Clean()
- if options.gen_key:
- GeneratePrivateKey(options)
- return 0
-
if options.info_template_path:
PnaclPackaging.SetPnaclInfoTemplatePath(options.info_template_path)
@@ -640,10 +358,8 @@ def Main():
print 'Invalid version format: %s\n' % version_quad
return 1
- if options.installer_only:
- BuildInstallerStyle(version_quad, lib_overrides, options)
- else:
- BuildExtensionStyle(version_quad, lib_overrides, options)
+ arches = DetermineInstallerArches(options.target_arch)
+ BuildInstallerStyle(version_quad, lib_overrides, arches)
return 0
diff --git a/ppapi/native_client/src/untrusted/pnacl_support_extension/pnacl_manifest_template.json b/ppapi/native_client/src/untrusted/pnacl_support_extension/pnacl_manifest_template.json
deleted file mode 100644
index 17b0146e81..0000000000
--- a/ppapi/native_client/src/untrusted/pnacl_support_extension/pnacl_manifest_template.json
+++ /dev/null
@@ -1,7 +0,0 @@
-{
- "description": "Portable Native Client",
- "name": "PNaCl",
- "manifest_version": 2,
- %(extra)s
- "version": "%(version)s"
-}
diff --git a/ppapi/native_client/src/untrusted/pnacl_support_extension/pnacl_support_extension.gyp b/ppapi/native_client/src/untrusted/pnacl_support_extension/pnacl_support_extension.gyp
index 269b4356aa..ece4452d0c 100644
--- a/ppapi/native_client/src/untrusted/pnacl_support_extension/pnacl_support_extension.gyp
+++ b/ppapi/native_client/src/untrusted/pnacl_support_extension/pnacl_support_extension.gyp
@@ -141,7 +141,7 @@
'python', 'pnacl_component_crx_gen.py',
'--dest=<(PRODUCT_DIR)/pnacl',
'<@(lib_overrides)',
- '--installer_only=<(target_arch)',
+ '--target_arch=<(target_arch)',
'--info_template_path=../../../../../native_client/pnacl/driver/pnacl_info_template.json',
# ABI Version Number.
'0.0.0.1',
diff --git a/ppapi/ppapi_proxy.gypi b/ppapi/ppapi_proxy.gypi
index 078f53c75b..884dc15817 100644
--- a/ppapi/ppapi_proxy.gypi
+++ b/ppapi/ppapi_proxy.gypi
@@ -127,8 +127,6 @@
'proxy/ppb_message_loop_proxy.h',
'proxy/ppb_network_monitor_private_proxy.cc',
'proxy/ppb_network_monitor_private_proxy.h',
- 'proxy/ppb_tcp_server_socket_private_proxy.cc',
- 'proxy/ppb_tcp_server_socket_private_proxy.h',
'proxy/ppb_tcp_socket_proxy.cc',
'proxy/ppb_tcp_socket_proxy.h',
'proxy/ppb_tcp_socket_private_proxy.cc',
@@ -178,6 +176,8 @@
'proxy/resource_creation_proxy.h',
'proxy/talk_resource.cc',
'proxy/talk_resource.h',
+ 'proxy/tcp_server_socket_private_resource.cc',
+ 'proxy/tcp_server_socket_private_resource.h',
'proxy/truetype_font_resource.cc',
'proxy/truetype_font_resource.h',
'proxy/truetype_font_singleton_resource.cc',
diff --git a/ppapi/ppapi_shared.gypi b/ppapi/ppapi_shared.gypi
index b5d75d218f..1160143b77 100644
--- a/ppapi/ppapi_shared.gypi
+++ b/ppapi/ppapi_shared.gypi
@@ -124,8 +124,6 @@
'shared_impl/private/ppb_char_set_shared.cc',
'shared_impl/private/ppb_char_set_shared.h',
- 'shared_impl/private/ppb_tcp_server_socket_shared.cc',
- 'shared_impl/private/ppb_tcp_server_socket_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',
@@ -325,7 +323,6 @@
'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/ppb_tcp_server_socket_shared.cc',
'shared_impl/private/tcp_socket_private_impl.cc',
'shared_impl/private/udp_socket_private_impl.cc',
'thunk/ppb_graphics_3d_thunk.cc',
diff --git a/ppapi/ppapi_shared.target.darwin-arm.mk b/ppapi/ppapi_shared.target.darwin-arm.mk
index 5ab62025a6..2ad0583b2b 100644
--- a/ppapi/ppapi_shared.target.darwin-arm.mk
+++ b/ppapi/ppapi_shared.target.darwin-arm.mk
@@ -84,7 +84,6 @@ LOCAL_SRC_FILES := \
ppapi/shared_impl/private/net_address_private_impl.cc \
ppapi/shared_impl/private/net_address_private_impl_constants.cc \
ppapi/shared_impl/private/ppb_char_set_shared.cc \
- ppapi/shared_impl/private/ppb_tcp_server_socket_shared.cc \
ppapi/shared_impl/private/ppb_x509_certificate_private_shared.cc \
ppapi/shared_impl/private/tcp_socket_private_impl.cc \
ppapi/thunk/enter.cc \
diff --git a/ppapi/ppapi_shared.target.darwin-mips.mk b/ppapi/ppapi_shared.target.darwin-mips.mk
index 1f16e6fafb..d785a4c711 100644
--- a/ppapi/ppapi_shared.target.darwin-mips.mk
+++ b/ppapi/ppapi_shared.target.darwin-mips.mk
@@ -84,7 +84,6 @@ LOCAL_SRC_FILES := \
ppapi/shared_impl/private/net_address_private_impl.cc \
ppapi/shared_impl/private/net_address_private_impl_constants.cc \
ppapi/shared_impl/private/ppb_char_set_shared.cc \
- ppapi/shared_impl/private/ppb_tcp_server_socket_shared.cc \
ppapi/shared_impl/private/ppb_x509_certificate_private_shared.cc \
ppapi/shared_impl/private/tcp_socket_private_impl.cc \
ppapi/thunk/enter.cc \
diff --git a/ppapi/ppapi_shared.target.darwin-x86.mk b/ppapi/ppapi_shared.target.darwin-x86.mk
index a5764027f4..3cac2e931a 100644
--- a/ppapi/ppapi_shared.target.darwin-x86.mk
+++ b/ppapi/ppapi_shared.target.darwin-x86.mk
@@ -84,7 +84,6 @@ LOCAL_SRC_FILES := \
ppapi/shared_impl/private/net_address_private_impl.cc \
ppapi/shared_impl/private/net_address_private_impl_constants.cc \
ppapi/shared_impl/private/ppb_char_set_shared.cc \
- ppapi/shared_impl/private/ppb_tcp_server_socket_shared.cc \
ppapi/shared_impl/private/ppb_x509_certificate_private_shared.cc \
ppapi/shared_impl/private/tcp_socket_private_impl.cc \
ppapi/thunk/enter.cc \
diff --git a/ppapi/ppapi_shared.target.linux-arm.mk b/ppapi/ppapi_shared.target.linux-arm.mk
index 5ab62025a6..2ad0583b2b 100644
--- a/ppapi/ppapi_shared.target.linux-arm.mk
+++ b/ppapi/ppapi_shared.target.linux-arm.mk
@@ -84,7 +84,6 @@ LOCAL_SRC_FILES := \
ppapi/shared_impl/private/net_address_private_impl.cc \
ppapi/shared_impl/private/net_address_private_impl_constants.cc \
ppapi/shared_impl/private/ppb_char_set_shared.cc \
- ppapi/shared_impl/private/ppb_tcp_server_socket_shared.cc \
ppapi/shared_impl/private/ppb_x509_certificate_private_shared.cc \
ppapi/shared_impl/private/tcp_socket_private_impl.cc \
ppapi/thunk/enter.cc \
diff --git a/ppapi/ppapi_shared.target.linux-mips.mk b/ppapi/ppapi_shared.target.linux-mips.mk
index 1f16e6fafb..d785a4c711 100644
--- a/ppapi/ppapi_shared.target.linux-mips.mk
+++ b/ppapi/ppapi_shared.target.linux-mips.mk
@@ -84,7 +84,6 @@ LOCAL_SRC_FILES := \
ppapi/shared_impl/private/net_address_private_impl.cc \
ppapi/shared_impl/private/net_address_private_impl_constants.cc \
ppapi/shared_impl/private/ppb_char_set_shared.cc \
- ppapi/shared_impl/private/ppb_tcp_server_socket_shared.cc \
ppapi/shared_impl/private/ppb_x509_certificate_private_shared.cc \
ppapi/shared_impl/private/tcp_socket_private_impl.cc \
ppapi/thunk/enter.cc \
diff --git a/ppapi/ppapi_shared.target.linux-x86.mk b/ppapi/ppapi_shared.target.linux-x86.mk
index a5764027f4..3cac2e931a 100644
--- a/ppapi/ppapi_shared.target.linux-x86.mk
+++ b/ppapi/ppapi_shared.target.linux-x86.mk
@@ -84,7 +84,6 @@ LOCAL_SRC_FILES := \
ppapi/shared_impl/private/net_address_private_impl.cc \
ppapi/shared_impl/private/net_address_private_impl_constants.cc \
ppapi/shared_impl/private/ppb_char_set_shared.cc \
- ppapi/shared_impl/private/ppb_tcp_server_socket_shared.cc \
ppapi/shared_impl/private/ppb_x509_certificate_private_shared.cc \
ppapi/shared_impl/private/tcp_socket_private_impl.cc \
ppapi/thunk/enter.cc \
diff --git a/ppapi/proxy/interface_list.cc b/ppapi/proxy/interface_list.cc
index 4de170b965..d9feb89d08 100644
--- a/ppapi/proxy/interface_list.cc
+++ b/ppapi/proxy/interface_list.cc
@@ -108,7 +108,6 @@
#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_server_socket_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"
diff --git a/ppapi/proxy/ppapi_messages.h b/ppapi/proxy/ppapi_messages.h
index db970c7d4b..6f73e25392 100644
--- a/ppapi/proxy/ppapi_messages.h
+++ b/ppapi/proxy/ppapi_messages.h
@@ -729,29 +729,6 @@ IPC_MESSAGE_ROUTED3(PpapiMsg_PPBTCPSocket_SetOptionACK,
uint32 /* socket_id */,
int32_t /* result */)
-// PPB_TCPServerSocket_Private.
-
-// |socket_resource| should not be used as Resource in browser. The
-// only purpose of this argument is to be echoed back.
-// |status| == PP_ERROR_NOSPACE means that the socket table is full
-// and new socket can't be initialized.
-// |status| == PP_ERROR_FAILED means that socket is correctly
-// initialized (if needed) but Listen call is failed.
-// |status| == PP_OK means that socket is correctly initialized (if
-// needed) and Listen call succeeds.
-IPC_MESSAGE_ROUTED5(PpapiMsg_PPBTCPServerSocket_ListenACK,
- uint32 /* plugin_dispatcher_id */,
- PP_Resource /* socket_resource */,
- uint32 /* socket_id */,
- PP_NetAddress_Private /* local_addr */,
- int32_t /* status */)
-IPC_MESSAGE_ROUTED5(PpapiMsg_PPBTCPServerSocket_AcceptACK,
- uint32 /* plugin_dispatcher_id */,
- uint32 /* server_socket_id */,
- uint32 /* accepted_socket_id */,
- PP_NetAddress_Private /* local_addr */,
- PP_NetAddress_Private /* remote_addr */)
-
#if !defined(OS_NACL) && !defined(NACL_WIN64)
// PPP_Instance_Private.
IPC_SYNC_MESSAGE_ROUTED1_1(PpapiMsg_PPPInstancePrivate_GetInstanceObject,
@@ -1226,19 +1203,6 @@ IPC_MESSAGE_CONTROL3(PpapiHostMsg_PPBTCPSocket_SetOption,
PP_TCPSocket_Option /* name */,
ppapi::SocketOptionData /* value */)
-// PPB_TCPServerSocket_Private.
-IPC_MESSAGE_CONTROL5(PpapiHostMsg_PPBTCPServerSocket_Listen,
- int32 /* routing_id */,
- uint32 /* plugin_dispatcher_id */,
- PP_Resource /* socket_resource */,
- PP_NetAddress_Private /* addr */,
- int32_t /* backlog */)
-IPC_MESSAGE_CONTROL2(PpapiHostMsg_PPBTCPServerSocket_Accept,
- int32 /* tcp_client_socket_routing_id */,
- uint32 /* server_socket_id */)
-IPC_MESSAGE_CONTROL1(PpapiHostMsg_PPBTCPServerSocket_Destroy,
- uint32 /* socket_id */)
-
// PPB_X509Certificate_Private
IPC_SYNC_MESSAGE_CONTROL1_2(PpapiHostMsg_PPBX509Certificate_ParseDER,
std::vector<char> /* der */,
@@ -1604,6 +1568,23 @@ IPC_MESSAGE_CONTROL0(PpapiHostMsg_Printing_GetDefaultPrintSettings)
IPC_MESSAGE_CONTROL1(PpapiPluginMsg_Printing_GetDefaultPrintSettingsReply,
PP_PrintSettings_Dev /* print_settings */)
+// TCP Server Socket -----------------------------------------------------------
+// Creates a PPB_TCPServerSocket_Private resource.
+IPC_MESSAGE_CONTROL0(PpapiHostMsg_TCPServerSocket_CreatePrivate)
+
+IPC_MESSAGE_CONTROL2(PpapiHostMsg_TCPServerSocket_Listen,
+ PP_NetAddress_Private /* addr */,
+ 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_CONTROL3(PpapiPluginMsg_TCPServerSocket_AcceptReply,
+ uint32 /* accepted_socket_id */,
+ PP_NetAddress_Private /* local_addr */,
+ PP_NetAddress_Private /* remote_addr */)
+IPC_MESSAGE_CONTROL0(PpapiHostMsg_TCPServerSocket_StopListening)
+
// UDP Socket ------------------------------------------------------------------
// Creates a PPB_UDPSocket resource.
IPC_MESSAGE_CONTROL0(PpapiHostMsg_UDPSocket_Create)
diff --git a/ppapi/proxy/ppb_tcp_server_socket_private_proxy.cc b/ppapi/proxy/ppb_tcp_server_socket_private_proxy.cc
deleted file mode 100644
index f895aaccd7..0000000000
--- a/ppapi/proxy/ppb_tcp_server_socket_private_proxy.cc
+++ /dev/null
@@ -1,199 +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_server_socket_private_proxy.h"
-
-#include <cstddef>
-
-#include "base/logging.h"
-#include "ppapi/c/pp_errors.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/proxy/ppb_tcp_socket_private_proxy.h"
-#include "ppapi/shared_impl/private/ppb_tcp_server_socket_shared.h"
-#include "ppapi/shared_impl/resource.h"
-#include "ppapi/thunk/enter.h"
-#include "ppapi/thunk/thunk.h"
-
-namespace ppapi {
-namespace proxy {
-
-namespace {
-
-class TCPServerSocket : public PPB_TCPServerSocket_Shared {
- public:
- TCPServerSocket(const HostResource& resource, uint32 plugin_dispatcher_id);
- virtual ~TCPServerSocket();
-
- virtual void OnAcceptCompleted(
- bool succeeded,
- uint32 tcp_socket_id,
- const PP_NetAddress_Private& local_addr,
- const PP_NetAddress_Private& remote_addr) OVERRIDE;
-
- virtual void SendListen(const PP_NetAddress_Private& addr,
- int32_t backlog) OVERRIDE;
- virtual void SendAccept() OVERRIDE;
- virtual void SendStopListening() OVERRIDE;
-
- private:
- void SendToBrowser(IPC::Message* msg);
-
- uint32 plugin_dispatcher_id_;
-
- DISALLOW_COPY_AND_ASSIGN(TCPServerSocket);
-};
-
-TCPServerSocket::TCPServerSocket(const HostResource& resource,
- uint32 plugin_dispatcher_id)
- : PPB_TCPServerSocket_Shared(resource),
- plugin_dispatcher_id_(plugin_dispatcher_id) {
-}
-
-TCPServerSocket::~TCPServerSocket() {
- StopListening();
-}
-
-void TCPServerSocket::OnAcceptCompleted(
- bool succeeded,
- uint32 accepted_socket_id,
- const PP_NetAddress_Private& local_addr,
- const PP_NetAddress_Private& remote_addr) {
- if (!TrackedCallback::IsPending(accept_callback_) || !tcp_socket_buffer_) {
- NOTREACHED();
- return;
- }
-
- if (succeeded) {
- *tcp_socket_buffer_ =
- PPB_TCPSocket_Private_Proxy::CreateProxyResourceForConnectedSocket(
- pp_instance(),
- accepted_socket_id,
- local_addr,
- remote_addr);
- }
- tcp_socket_buffer_ = NULL;
-
- accept_callback_->Run(succeeded ? PP_OK : PP_ERROR_FAILED);
-}
-
-void TCPServerSocket::SendListen(const PP_NetAddress_Private& addr,
- int32_t backlog) {
- SendToBrowser(new PpapiHostMsg_PPBTCPServerSocket_Listen(
- API_ID_PPB_TCPSERVERSOCKET_PRIVATE,
- plugin_dispatcher_id_,
- pp_resource(),
- addr,
- backlog));
-}
-
-void TCPServerSocket::SendAccept() {
- SendToBrowser(new PpapiHostMsg_PPBTCPServerSocket_Accept(
- API_ID_PPB_TCPSOCKET_PRIVATE, socket_id_));
-}
-
-void TCPServerSocket::SendStopListening() {
- if (socket_id_ != 0) {
- SendToBrowser(new PpapiHostMsg_PPBTCPServerSocket_Destroy(socket_id_));
-
- PluginDispatcher* dispatcher =
- PluginDispatcher::GetForInstance(host_resource().instance());
- if (dispatcher) {
- InterfaceProxy* proxy =
- dispatcher->GetInterfaceProxy(API_ID_PPB_TCPSERVERSOCKET_PRIVATE);
- PPB_TCPServerSocket_Private_Proxy* server_socket_proxy =
- static_cast<PPB_TCPServerSocket_Private_Proxy*>(proxy);
- server_socket_proxy->ObjectDestroyed(socket_id_);
- }
- }
-}
-
-void TCPServerSocket::SendToBrowser(IPC::Message* msg) {
- PluginGlobals::Get()->GetBrowserSender()->Send(msg);
-}
-
-} // namespace
-
-//------------------------------------------------------------------------------
-
-PPB_TCPServerSocket_Private_Proxy::PPB_TCPServerSocket_Private_Proxy(
- Dispatcher* dispatcher)
- : InterfaceProxy(dispatcher) {
-}
-
-PPB_TCPServerSocket_Private_Proxy::~PPB_TCPServerSocket_Private_Proxy() {
-}
-
-PP_Resource PPB_TCPServerSocket_Private_Proxy::CreateProxyResource(
- PP_Instance instance) {
- PluginDispatcher* dispatcher = PluginDispatcher::GetForInstance(instance);
- if (!dispatcher)
- return 0;
-
- TCPServerSocket* server_socket =
- new TCPServerSocket(HostResource::MakeInstanceOnly(instance),
- dispatcher->plugin_dispatcher_id());
- return server_socket->GetReference();
-}
-
-void PPB_TCPServerSocket_Private_Proxy::ObjectDestroyed(uint32 socket_id) {
- id_to_server_socket_.erase(socket_id);
-}
-
-bool PPB_TCPServerSocket_Private_Proxy::OnMessageReceived(
- const IPC::Message& msg) {
- bool handled = true;
- IPC_BEGIN_MESSAGE_MAP(PPB_TCPServerSocket_Private_Proxy, msg)
- IPC_MESSAGE_HANDLER(PpapiMsg_PPBTCPServerSocket_ListenACK, OnMsgListenACK)
- IPC_MESSAGE_HANDLER(PpapiMsg_PPBTCPServerSocket_AcceptACK, OnMsgAcceptACK)
- IPC_MESSAGE_UNHANDLED(handled = false)
- IPC_END_MESSAGE_MAP()
- return handled;
-}
-
-void PPB_TCPServerSocket_Private_Proxy::OnMsgListenACK(
- uint32 plugin_dispatcher_id,
- PP_Resource socket_resource,
- uint32 socket_id,
- const PP_NetAddress_Private& local_addr,
- int32_t status) {
- thunk::EnterResourceNoLock<thunk::PPB_TCPServerSocket_Private_API>
- enter(socket_resource, true);
- if (enter.succeeded()) {
- PPB_TCPServerSocket_Shared* server_socket =
- static_cast<PPB_TCPServerSocket_Shared*>(enter.object());
- if (status == PP_OK)
- id_to_server_socket_[socket_id] = server_socket;
- server_socket->OnListenCompleted(socket_id, local_addr, status);
- } else if (socket_id != 0 && status == PP_OK) {
- IPC::Message* msg =
- new PpapiHostMsg_PPBTCPServerSocket_Destroy(socket_id);
- PluginGlobals::Get()->GetBrowserSender()->Send(msg);
- }
-}
-
-void PPB_TCPServerSocket_Private_Proxy::OnMsgAcceptACK(
- uint32 plugin_dispatcher_id,
- uint32 server_socket_id,
- uint32 accepted_socket_id,
- const PP_NetAddress_Private& local_addr,
- const PP_NetAddress_Private& remote_addr) {
- IDToServerSocketMap::iterator it =
- id_to_server_socket_.find(server_socket_id);
- if (it != id_to_server_socket_.end()) {
- bool succeeded = (accepted_socket_id != 0);
- it->second->OnAcceptCompleted(succeeded,
- accepted_socket_id,
- local_addr,
- remote_addr);
- } else if (accepted_socket_id != 0) {
- PluginGlobals::Get()->GetBrowserSender()->Send(
- new PpapiHostMsg_PPBTCPSocket_Disconnect(accepted_socket_id));
- }
-}
-
-} // namespace proxy
-} // namespace ppapi
diff --git a/ppapi/proxy/ppb_tcp_server_socket_private_proxy.h b/ppapi/proxy/ppb_tcp_server_socket_private_proxy.h
deleted file mode 100644
index 3fd985e0a3..0000000000
--- a/ppapi/proxy/ppb_tcp_server_socket_private_proxy.h
+++ /dev/null
@@ -1,60 +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_SERVER_SOCKET_PRIVATE_PROXY_H_
-#define PPAPI_PROXY_PPB_TCP_SERVER_SOCKET_PRIVATE_PROXY_H_
-
-#include <map>
-#include <string>
-
-#include "base/basictypes.h"
-#include "ppapi/c/pp_instance.h"
-#include "ppapi/c/pp_resource.h"
-#include "ppapi/c/private/ppb_net_address_private.h"
-#include "ppapi/proxy/interface_proxy.h"
-
-namespace ppapi {
-
-class PPB_TCPServerSocket_Shared;
-
-namespace proxy {
-
-class PPB_TCPServerSocket_Private_Proxy : public InterfaceProxy {
- public:
- explicit PPB_TCPServerSocket_Private_Proxy(Dispatcher* dispatcher);
- virtual ~PPB_TCPServerSocket_Private_Proxy();
-
- static PP_Resource CreateProxyResource(PP_Instance instance);
-
- void ObjectDestroyed(uint32 socket_id);
-
- // InterfaceProxy implementation.
- virtual bool OnMessageReceived(const IPC::Message& msg);
-
- static const ApiID kApiID = API_ID_PPB_TCPSERVERSOCKET_PRIVATE;
-
- private:
- typedef std::map<uint32, PPB_TCPServerSocket_Shared*>
- IDToServerSocketMap;
-
- void OnMsgListenACK(uint32 plugin_dispatcher_id,
- PP_Resource socket_resource,
- uint32 socket_id,
- const PP_NetAddress_Private& local_addr,
- int32_t status);
- void OnMsgAcceptACK(uint32 plugin_dispatcher_id,
- uint32 server_socket_id,
- uint32 accepted_socket_id,
- const PP_NetAddress_Private& local_addr,
- const PP_NetAddress_Private& remote_addr);
-
- IDToServerSocketMap id_to_server_socket_;
-
- DISALLOW_COPY_AND_ASSIGN(PPB_TCPServerSocket_Private_Proxy);
-};
-
-} // namespace proxy
-} // namespace ppapi
-
-#endif // PPAPI_PROXY_PPB_TCP_SERVER_SOCKET_PRIVATE_PROXY_H_
diff --git a/ppapi/proxy/resource_creation_proxy.cc b/ppapi/proxy/resource_creation_proxy.cc
index 7cb3369d3d..53cade1e91 100644
--- a/ppapi/proxy/resource_creation_proxy.cc
+++ b/ppapi/proxy/resource_creation_proxy.cc
@@ -31,13 +31,13 @@
#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_server_socket_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/truetype_font_resource.h"
#include "ppapi/proxy/udp_socket_private_resource.h"
#include "ppapi/proxy/udp_socket_resource.h"
@@ -324,7 +324,8 @@ PP_Resource ResourceCreationProxy::CreatePrinting(PP_Instance instance) {
PP_Resource ResourceCreationProxy::CreateTCPServerSocketPrivate(
PP_Instance instance) {
- return PPB_TCPServerSocket_Private_Proxy::CreateProxyResource(instance);
+ return (new TCPServerSocketPrivateResource(GetConnection(), instance))->
+ GetReference();
}
PP_Resource ResourceCreationProxy::CreateTCPSocket(
diff --git a/ppapi/proxy/tcp_server_socket_private_resource.cc b/ppapi/proxy/tcp_server_socket_private_resource.cc
new file mode 100644
index 0000000000..6bbf4667ee
--- /dev/null
+++ b/ppapi/proxy/tcp_server_socket_private_resource.cc
@@ -0,0 +1,138 @@
+// 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_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"
+
+namespace ppapi {
+namespace proxy {
+
+TCPServerSocketPrivateResource::TCPServerSocketPrivateResource(
+ Connection connection,
+ PP_Instance instance)
+ : PluginResource(connection, instance),
+ state_(STATE_BEFORE_LISTENING),
+ local_addr_(),
+ plugin_dispatcher_id_(0) {
+ SendCreate(BROWSER, PpapiHostMsg_TCPServerSocket_CreatePrivate());
+
+ PluginDispatcher* dispatcher = PluginDispatcher::GetForInstance(instance);
+ if (dispatcher)
+ plugin_dispatcher_id_ = dispatcher->plugin_dispatcher_id();
+ else
+ NOTREACHED();
+}
+
+TCPServerSocketPrivateResource::~TCPServerSocketPrivateResource() {
+}
+
+thunk::PPB_TCPServerSocket_Private_API*
+TCPServerSocketPrivateResource::AsPPB_TCPServerSocket_Private_API() {
+ return this;
+}
+
+int32_t TCPServerSocketPrivateResource::Listen(
+ const PP_NetAddress_Private* addr,
+ int32_t backlog,
+ scoped_refptr<TrackedCallback> callback) {
+ if (!addr)
+ return PP_ERROR_BADARGUMENT;
+ if (state_ != STATE_BEFORE_LISTENING)
+ return PP_ERROR_FAILED;
+ if (TrackedCallback::IsPending(listen_callback_))
+ return PP_ERROR_INPROGRESS;
+
+ listen_callback_ = callback;
+
+ // Send the request, the browser will call us back via ListenACK
+ Call<PpapiPluginMsg_TCPServerSocket_ListenReply>(
+ BROWSER,
+ PpapiHostMsg_TCPServerSocket_Listen(*addr, backlog),
+ base::Bind(&TCPServerSocketPrivateResource::OnPluginMsgListenReply,
+ base::Unretained(this)));
+ return PP_OK_COMPLETIONPENDING;
+}
+
+int32_t TCPServerSocketPrivateResource::Accept(
+ PP_Resource* tcp_socket,
+ scoped_refptr<TrackedCallback> callback) {
+ if (!tcp_socket)
+ return PP_ERROR_BADARGUMENT;
+ if (state_ != STATE_LISTENING)
+ return PP_ERROR_FAILED;
+ if (TrackedCallback::IsPending(accept_callback_))
+ return PP_ERROR_INPROGRESS;
+
+ accept_callback_ = callback;
+
+ Call<PpapiPluginMsg_TCPServerSocket_AcceptReply>(
+ BROWSER,
+ PpapiHostMsg_TCPServerSocket_Accept(plugin_dispatcher_id_),
+ base::Bind(&TCPServerSocketPrivateResource::OnPluginMsgAcceptReply,
+ base::Unretained(this), tcp_socket));
+ return PP_OK_COMPLETIONPENDING;
+}
+
+int32_t TCPServerSocketPrivateResource::GetLocalAddress(
+ PP_NetAddress_Private* addr) {
+ if (!addr)
+ return PP_ERROR_BADARGUMENT;
+ if (state_ != STATE_LISTENING)
+ return PP_ERROR_FAILED;
+ *addr = local_addr_;
+ return PP_OK;
+}
+
+void TCPServerSocketPrivateResource::StopListening() {
+ if (state_ == STATE_CLOSED)
+ return;
+ state_ = STATE_CLOSED;
+ Post(BROWSER, PpapiHostMsg_TCPServerSocket_StopListening());
+ if (TrackedCallback::IsPending(listen_callback_))
+ listen_callback_->PostAbort();
+ if (TrackedCallback::IsPending(accept_callback_))
+ accept_callback_->PostAbort();
+}
+
+void TCPServerSocketPrivateResource::OnPluginMsgListenReply(
+ const ResourceMessageReplyParams& params,
+ const PP_NetAddress_Private& local_addr) {
+ if (state_ != STATE_BEFORE_LISTENING ||
+ !TrackedCallback::IsPending(listen_callback_)) {
+ return;
+ }
+ if (params.result() == PP_OK) {
+ local_addr_ = local_addr;
+ state_ = STATE_LISTENING;
+ }
+ listen_callback_->Run(params.result());
+}
+
+void TCPServerSocketPrivateResource::OnPluginMsgAcceptReply(
+ PP_Resource* tcp_socket,
+ const ResourceMessageReplyParams& params,
+ uint32 accepted_socket_id,
+ const PP_NetAddress_Private& local_addr,
+ const PP_NetAddress_Private& remote_addr) {
+ DCHECK(tcp_socket);
+ if (state_ != STATE_LISTENING ||
+ !TrackedCallback::IsPending(accept_callback_)) {
+ return;
+ }
+ if (params.result() == PP_OK) {
+ *tcp_socket =
+ PPB_TCPSocket_Private_Proxy::CreateProxyResourceForConnectedSocket(
+ pp_instance(),
+ accepted_socket_id,
+ local_addr,
+ remote_addr);
+ }
+ accept_callback_->Run(params.result());
+}
+
+} // namespace proxy
+} // namespace ppapi
diff --git a/ppapi/proxy/tcp_server_socket_private_resource.h b/ppapi/proxy/tcp_server_socket_private_resource.h
new file mode 100644
index 0000000000..95febde92c
--- /dev/null
+++ b/ppapi/proxy/tcp_server_socket_private_resource.h
@@ -0,0 +1,69 @@
+// 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_SERVER_SOCKET_PRIVATE_RESOURCE_H_
+#define PPAPI_PROXY_TCP_SERVER_SOCKET_PRIVATE_RESOURCE_H_
+
+#include "base/basictypes.h"
+#include "base/compiler_specific.h"
+#include "base/memory/ref_counted.h"
+#include "ppapi/proxy/plugin_resource.h"
+#include "ppapi/proxy/ppapi_proxy_export.h"
+#include "ppapi/shared_impl/tracked_callback.h"
+#include "ppapi/thunk/ppb_tcp_server_socket_private_api.h"
+
+namespace ppapi {
+namespace proxy {
+
+class PPAPI_PROXY_EXPORT TCPServerSocketPrivateResource
+ : public PluginResource,
+ public thunk::PPB_TCPServerSocket_Private_API {
+ public:
+ TCPServerSocketPrivateResource(Connection connection, PP_Instance instance);
+ virtual ~TCPServerSocketPrivateResource();
+
+ // PluginResource implementation.
+ virtual thunk::PPB_TCPServerSocket_Private_API*
+ AsPPB_TCPServerSocket_Private_API() OVERRIDE;
+
+ // PPB_TCPServerSocket_Private_API implementation.
+ virtual int32_t Listen(const PP_NetAddress_Private* addr,
+ int32_t backlog,
+ scoped_refptr<TrackedCallback> callback) OVERRIDE;
+ virtual int32_t Accept(PP_Resource* tcp_socket,
+ scoped_refptr<TrackedCallback> callback) OVERRIDE;
+ virtual int32_t GetLocalAddress(PP_NetAddress_Private* addr) OVERRIDE;
+ virtual void StopListening() OVERRIDE;
+
+ private:
+ enum State {
+ STATE_BEFORE_LISTENING,
+ STATE_LISTENING,
+ STATE_CLOSED
+ };
+
+ // IPC message handlers.
+ void OnPluginMsgListenReply(const ResourceMessageReplyParams& params,
+ const PP_NetAddress_Private& local_addr);
+ void OnPluginMsgAcceptReply(PP_Resource* tcp_socket,
+ const ResourceMessageReplyParams& params,
+ uint32 accepted_socket_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_;
+
+ DISALLOW_COPY_AND_ASSIGN(TCPServerSocketPrivateResource);
+};
+
+} // namespace proxy
+} // namespace ppapi
+
+#endif // PPAPI_PROXY_TCP_SERVER_SOCKET_PRIVATE_RESOURCE_H_
diff --git a/ppapi/shared_impl/api_id.h b/ppapi/shared_impl/api_id.h
index 65a150ea71..3707719fc6 100644
--- a/ppapi/shared_impl/api_id.h
+++ b/ppapi/shared_impl/api_id.h
@@ -39,13 +39,11 @@ enum ApiID {
API_ID_PPB_OPENGLES2,
API_ID_PPB_PDF,
API_ID_PPB_SURFACE_3D,
- API_ID_PPB_TCPSERVERSOCKET_PRIVATE,
API_ID_PPB_TCPSOCKET,
API_ID_PPB_TCPSOCKET_PRIVATE,
API_ID_PPB_TALK,
API_ID_PPB_TESTING,
API_ID_PPB_TEXT_INPUT,
- API_ID_PPB_UDPSOCKET_PRIVATE,
API_ID_PPB_URL_RESPONSE_INFO,
API_ID_PPB_VAR_ARRAY_BUFFER,
API_ID_PPB_VAR_DEPRECATED,
diff --git a/ppapi/shared_impl/private/ppb_tcp_server_socket_shared.cc b/ppapi/shared_impl/private/ppb_tcp_server_socket_shared.cc
deleted file mode 100644
index 11add89641..0000000000
--- a/ppapi/shared_impl/private/ppb_tcp_server_socket_shared.cc
+++ /dev/null
@@ -1,121 +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/ppb_tcp_server_socket_shared.h"
-
-#include <cstddef>
-#include <cstring>
-
-#include "base/logging.h"
-#include "ppapi/c/pp_errors.h"
-#include "ppapi/shared_impl/private/net_address_private_impl.h"
-
-namespace ppapi {
-
-PPB_TCPServerSocket_Shared::PPB_TCPServerSocket_Shared(PP_Instance instance)
- : Resource(OBJECT_IS_IMPL, instance),
- socket_id_(0),
- local_addr_(),
- state_(BEFORE_LISTENING),
- tcp_socket_buffer_(NULL) {
-}
-
-PPB_TCPServerSocket_Shared::PPB_TCPServerSocket_Shared(
- const HostResource& resource)
- : Resource(OBJECT_IS_PROXY, resource),
- socket_id_(0),
- local_addr_(),
- state_(BEFORE_LISTENING),
- tcp_socket_buffer_(NULL) {
-}
-
-PPB_TCPServerSocket_Shared::~PPB_TCPServerSocket_Shared() {
-}
-
-thunk::PPB_TCPServerSocket_Private_API*
-PPB_TCPServerSocket_Shared::AsPPB_TCPServerSocket_Private_API() {
- return this;
-}
-
-int32_t PPB_TCPServerSocket_Shared::Listen(
- const PP_NetAddress_Private* addr,
- int32_t backlog,
- scoped_refptr<TrackedCallback> callback) {
- if (!addr)
- return PP_ERROR_BADARGUMENT;
- if (state_ != BEFORE_LISTENING)
- return PP_ERROR_FAILED;
- if (TrackedCallback::IsPending(listen_callback_))
- return PP_ERROR_INPROGRESS; // Can only have one pending request.
-
- listen_callback_ = callback;
- // Send the request, the browser will call us back via ListenACK
- SendListen(*addr, backlog);
- return PP_OK_COMPLETIONPENDING;
-}
-
-int32_t PPB_TCPServerSocket_Shared::Accept(
- PP_Resource* tcp_socket,
- scoped_refptr<TrackedCallback> callback) {
- if (!tcp_socket)
- return PP_ERROR_BADARGUMENT;
-
- if (state_ != LISTENING)
- return PP_ERROR_FAILED;
- if (TrackedCallback::IsPending(accept_callback_))
- return PP_ERROR_INPROGRESS;
-
- tcp_socket_buffer_ = tcp_socket;
- accept_callback_ = callback;
-
- SendAccept();
- return PP_OK_COMPLETIONPENDING;
-}
-
-int32_t PPB_TCPServerSocket_Shared::GetLocalAddress(
- PP_NetAddress_Private* addr) {
- if (!addr)
- return PP_ERROR_BADARGUMENT;
- if (state_ != LISTENING)
- return PP_ERROR_FAILED;
- *addr = local_addr_;
- return PP_OK;
-}
-
-void PPB_TCPServerSocket_Shared::StopListening() {
- if (state_ == CLOSED)
- return;
-
- state_ = CLOSED;
-
- SendStopListening();
- socket_id_ = 0;
-
- if (TrackedCallback::IsPending(listen_callback_))
- listen_callback_->PostAbort();
- if (TrackedCallback::IsPending(accept_callback_))
- accept_callback_->PostAbort();
- tcp_socket_buffer_ = NULL;
-}
-
-void PPB_TCPServerSocket_Shared::OnListenCompleted(
- uint32 socket_id,
- const PP_NetAddress_Private& local_addr,
- int32_t status) {
- if (state_ != BEFORE_LISTENING ||
- !TrackedCallback::IsPending(listen_callback_)) {
- NOTREACHED();
- return;
- }
-
- if (status == PP_OK) {
- socket_id_ = socket_id;
- local_addr_ = local_addr;
- state_ = LISTENING;
- }
-
- listen_callback_->Run(status);
-}
-
-} // namespace ppapi
diff --git a/ppapi/shared_impl/private/ppb_tcp_server_socket_shared.h b/ppapi/shared_impl/private/ppb_tcp_server_socket_shared.h
deleted file mode 100644
index 29d14a2420..0000000000
--- a/ppapi/shared_impl/private/ppb_tcp_server_socket_shared.h
+++ /dev/null
@@ -1,84 +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_PRIVATE_PPB_TCP_SERVER_SOCKET_SHARED_H_
-#define PPAPI_SHARED_IMPL_PRIVATE_PPB_TCP_SERVER_SOCKET_SHARED_H_
-
-#include "base/compiler_specific.h"
-#include "ppapi/c/pp_completion_callback.h"
-#include "ppapi/shared_impl/resource.h"
-#include "ppapi/shared_impl/tracked_callback.h"
-#include "ppapi/thunk/ppb_tcp_server_socket_private_api.h"
-
-namespace ppapi {
-
-// This class provides the shared implementation of a
-// PPB_TCPServerSocket_Private. The functions that actually send
-// messages to browser are implemented differently for the proxied and
-// non-proxied derived classes.
-class PPAPI_SHARED_EXPORT PPB_TCPServerSocket_Shared
- : public thunk::PPB_TCPServerSocket_Private_API,
- public Resource {
- public:
- // C-tor used in Impl case.
- PPB_TCPServerSocket_Shared(PP_Instance instance);
- // C-tor used in Proxy case.
- PPB_TCPServerSocket_Shared(const HostResource& resource);
-
- virtual ~PPB_TCPServerSocket_Shared();
-
- // Resource overrides.
- virtual PPB_TCPServerSocket_Private_API*
- AsPPB_TCPServerSocket_Private_API() OVERRIDE;
-
- // PPB_TCPServerSocket_Private_API implementation.
- virtual int32_t Listen(const PP_NetAddress_Private* addr,
- int32_t backlog,
- scoped_refptr<TrackedCallback> callback) OVERRIDE;
- virtual int32_t Accept(PP_Resource* tcp_socket,
- scoped_refptr<TrackedCallback> callback) OVERRIDE;
- virtual int32_t GetLocalAddress(PP_NetAddress_Private* addr) OVERRIDE;
- virtual void StopListening() OVERRIDE;
-
- void OnListenCompleted(uint32 socket_id,
- const PP_NetAddress_Private& local_addr,
- int32_t status);
- virtual void OnAcceptCompleted(bool succeeded,
- uint32 accepted_socket_id,
- const PP_NetAddress_Private& local_addr,
- const PP_NetAddress_Private& remote_addr) = 0;
-
- // Send functions that need to be implemented differently for the
- // proxied and non-proxied derived classes.
- virtual void SendListen(const PP_NetAddress_Private& addr,
- int32_t backlog) = 0;
- virtual void SendAccept() = 0;
- virtual void SendStopListening() = 0;
-
- protected:
- enum State {
- // Before listening (including a listen request is pending or a
- // previous listen request failed).
- BEFORE_LISTENING,
- // Socket is successfully bound and in listening mode.
- LISTENING,
- // The socket is closed.
- CLOSED
- };
-
- uint32 socket_id_;
- PP_NetAddress_Private local_addr_;
- State state_;
-
- scoped_refptr<TrackedCallback> listen_callback_;
- scoped_refptr<TrackedCallback> accept_callback_;
-
- PP_Resource* tcp_socket_buffer_;
-
- DISALLOW_COPY_AND_ASSIGN(PPB_TCPServerSocket_Shared);
-};
-
-} // namespace ppapi
-
-#endif // PPAPI_SHARED_IMPL_PRIVATE_PPB_TCP_SERVER_SOCKET_SHARED_H_
diff --git a/ppapi/tests/test_case.cc b/ppapi/tests/test_case.cc
index 733faadbb1..6f61fc505a 100644
--- a/ppapi/tests/test_case.cc
+++ b/ppapi/tests/test_case.cc
@@ -81,7 +81,7 @@ TestCase::TestCase(TestingInstance* instance)
: instance_(instance),
testing_interface_(NULL),
callback_type_(PP_REQUIRED),
- have_populated_remaining_tests_(false) {
+ have_populated_filter_tests_(false) {
// Get the testing_interface_ if it is available, so that we can do Resource
// and Var checks on shutdown (see CheckResourcesAndVars). If it is not
// available, testing_interface_ will be NULL. Some tests do not require it.
@@ -181,21 +181,21 @@ bool TestCase::ShouldRunTest(const std::string& test_name,
if (ShouldRunAllTests(filter))
return true;
- // Lazily initialize our "remaining_tests_" map.
- if (!have_populated_remaining_tests_) {
- ParseTestFilter(filter, &remaining_tests_);
- have_populated_remaining_tests_ = true;
+ // Lazily initialize our "filter_tests_" map.
+ if (!have_populated_filter_tests_) {
+ ParseTestFilter(filter, &filter_tests_);
+ remaining_tests_ = filter_tests_;
+ have_populated_filter_tests_ = true;
}
- std::map<std::string, bool>::iterator iter = remaining_tests_.find(test_name);
- if (iter == remaining_tests_.end()) {
+ std::map<std::string, bool>::iterator iter = filter_tests_.find(test_name);
+ if (iter == filter_tests_.end()) {
// The test name wasn't listed in the filter. Don't run it, but store it
// so TestingInstance::ExecuteTests can report an error later.
skipped_tests_.insert(test_name);
return false;
}
- bool should_run_test = iter->second;
- remaining_tests_.erase(iter);
- return should_run_test;
+ remaining_tests_.erase(test_name);
+ return iter->second;
}
PP_TimeTicks TestCase::NowInTimeTicks() {
diff --git a/ppapi/tests/test_case.h b/ppapi/tests/test_case.h
index 4491c767f9..9a3c31f98d 100644
--- a/ppapi/tests/test_case.h
+++ b/ppapi/tests/test_case.h
@@ -224,18 +224,21 @@ class TestCase {
// Var ids that should be ignored when checking for leaks on shutdown.
std::set<int64_t> ignored_leaked_vars_;
- // The tests that were found in test_filter but have not yet been run. The
- // bool indicates whether the test should be run (i.e., it will be false if
- // the test name was prefixed in the test_filter string).
+ // The tests that were found in test_filter. The bool indicates whether the
+ // test should be run (i.e., it will be false if the test name was prefixed in
+ // the test_filter string).
//
- // This is initialized lazily the first time that ShouldRunTest is called by
- // RunTests. When RunTests is finished, this should be empty. Any remaining
- // tests are tests that were listed in the test_filter but didn't match
- // any calls to ShouldRunTest, meaning it was probably a typo. TestingInstance
- // should log this and consider it a failure.
+ // This is initialized lazily the first time that ShouldRunTest is called.
+ std::map<std::string, bool> filter_tests_;
+ // Flag indicating whether we have populated filter_tests_ yet.
+ bool have_populated_filter_tests_;
+ // This is initialized with the contents of filter_tests_. As each test is
+ // run, it is removed from remaining_tests_. When RunTests is finished,
+ // remaining_tests_ should be empty. Any remaining tests are tests that were
+ // listed in the test_filter but didn't match any calls to ShouldRunTest,
+ // meaning it was probably a typo. TestingInstance should log this and
+ // consider it a failure.
std::map<std::string, bool> remaining_tests_;
- // Flag indicating whether we have populated remaining_tests_ yet.
- bool have_populated_remaining_tests_;
// If ShouldRunTest is called but the given test name doesn't match anything
// in the test_filter, the test name will be added here. This allows
diff --git a/ppapi/tests/test_file_io.cc b/ppapi/tests/test_file_io.cc
index 2d0da5c119..ed2183b669 100644
--- a/ppapi/tests/test_file_io.cc
+++ b/ppapi/tests/test_file_io.cc
@@ -1138,6 +1138,10 @@ std::string TestFileIO::TestRequestOSFileHandleWithOpenExclusive() {
callback.WaitForResult(file_system.Open(1024, callback.GetCallback()));
ASSERT_EQ(PP_OK, callback.result());
+ // Open with PP_FILEOPENFLAG_CREATE and PP_FILEOPENFLAG_EXCLUSIVE will fail
+ // if the file already exists. Delete it here to make sure it does not.
+ callback.WaitForResult(file_ref.Delete(callback.GetCallback()));
+
pp::FileIO_Private file_io(instance_);
callback.WaitForResult(file_io.Open(file_ref,
PP_FILEOPENFLAG_CREATE |
diff --git a/ppapi/thunk/interfaces_ppb_private_no_permissions.h b/ppapi/thunk/interfaces_ppb_private_no_permissions.h
index a76665a712..44cbc3658f 100644
--- a/ppapi/thunk/interfaces_ppb_private_no_permissions.h
+++ b/ppapi/thunk/interfaces_ppb_private_no_permissions.h
@@ -9,18 +9,15 @@
// These interfaces don't require private permissions. However, they only work
// for whitelisted origins.
-PROXIED_API(PPB_TCPServerSocket_Private)
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)
-PROXIED_IFACE(PPB_TCPServerSocket_Private,
- PPB_TCPSERVERSOCKET_PRIVATE_INTERFACE_0_1,
+PROXIED_IFACE(NoAPIName, PPB_TCPSERVERSOCKET_PRIVATE_INTERFACE_0_1,
PPB_TCPServerSocket_Private_0_1)
-PROXIED_IFACE(PPB_TCPServerSocket_Private,
- PPB_TCPSERVERSOCKET_PRIVATE_INTERFACE_0_2,
+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,
PPB_TCPSocket_Private_0_3)