diff options
author | yzshen@chromium.org <yzshen@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-06-16 19:09:38 +0000 |
---|---|---|
committer | yzshen@chromium.org <yzshen@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-06-16 19:09:38 +0000 |
commit | cef56eabc38047340ea3229e85506afcd187984e (patch) | |
tree | 75415933e55859243e9c9bbf54db5468186aa938 | |
parent | 93ef86cbf2c5b896183b811d6297b77726d25f57 (diff) | |
download | chromium_src-cef56eabc38047340ea3229e85506afcd187984e.zip chromium_src-cef56eabc38047340ea3229e85506afcd187984e.tar.gz chromium_src-cef56eabc38047340ea3229e85506afcd187984e.tar.bz2 |
Remove apps in Pepper support and the PPB_Alarms_Dev API.
BUG=366304
TEST=None
Review URL: https://codereview.chromium.org/314823002
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@277513 0039d316-1c4b-4281-b951-d872f2087c98
56 files changed, 1 insertions, 3791 deletions
diff --git a/chrome/browser/component_updater/ppapi_utils.cc b/chrome/browser/component_updater/ppapi_utils.cc index 09d8a72..d8bee1e 100644 --- a/chrome/browser/component_updater/ppapi_utils.cc +++ b/chrome/browser/component_updater/ppapi_utils.cc @@ -6,7 +6,6 @@ #include <cstring> #include "build/build_config.h" -#include "ppapi/c/dev/ppb_alarms_dev.h" #include "ppapi/c/dev/ppb_audio_input_dev.h" #include "ppapi/c/dev/ppb_buffer_dev.h" #include "ppapi/c/dev/ppb_char_set_dev.h" diff --git a/chrome/browser/renderer_host/pepper/chrome_browser_pepper_host_factory.cc b/chrome/browser/renderer_host/pepper/chrome_browser_pepper_host_factory.cc index 10d7bc4..a2c491c 100644 --- a/chrome/browser/renderer_host/pepper/chrome_browser_pepper_host_factory.cc +++ b/chrome/browser/renderer_host/pepper/chrome_browser_pepper_host_factory.cc @@ -6,7 +6,6 @@ #include "build/build_config.h" #include "chrome/browser/renderer_host/pepper/pepper_broker_message_filter.h" -#include "chrome/browser/renderer_host/pepper/pepper_extensions_common_message_filter.h" #include "chrome/browser/renderer_host/pepper/pepper_flash_browser_host.h" #include "chrome/browser/renderer_host/pepper/pepper_flash_clipboard_message_filter.h" #include "chrome/browser/renderer_host/pepper/pepper_flash_drm_host.h" @@ -44,24 +43,6 @@ scoped_ptr<ResourceHost> ChromeBrowserPepperHostFactory::CreateResourceHost( if (!host_->IsValidInstance(instance)) return scoped_ptr<ResourceHost>(); - // Dev interfaces. - if (host_->GetPpapiHost()->permissions().HasPermission( - ppapi::PERMISSION_DEV)) { - switch (message.type()) { - case PpapiHostMsg_ExtensionsCommon_Create::ID: { - scoped_refptr<ResourceMessageFilter> extensions_common_filter( - PepperExtensionsCommonMessageFilter::Create(host_, instance)); - if (!extensions_common_filter.get()) - return scoped_ptr<ResourceHost>(); - return scoped_ptr<ResourceHost>( - new MessageFilterHost(host_->GetPpapiHost(), - instance, - params.pp_resource(), - extensions_common_filter)); - } - } - } - // Private interfaces. if (host_->GetPpapiHost()->permissions().HasPermission( ppapi::PERMISSION_PRIVATE)) { diff --git a/chrome/browser/renderer_host/pepper/pepper_extensions_common_message_filter.cc b/chrome/browser/renderer_host/pepper/pepper_extensions_common_message_filter.cc deleted file mode 100644 index ad2beeb..0000000 --- a/chrome/browser/renderer_host/pepper/pepper_extensions_common_message_filter.cc +++ /dev/null @@ -1,236 +0,0 @@ -// Copyright (c) 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 "chrome/browser/renderer_host/pepper/pepper_extensions_common_message_filter.h" - -#include "base/logging.h" -#include "base/memory/ref_counted.h" -#include "base/values.h" -#include "chrome/browser/browser_process.h" -#include "chrome/browser/profiles/profile.h" -#include "chrome/browser/profiles/profile_manager.h" -#include "content/public/browser/browser_ppapi_host.h" -#include "content/public/browser/browser_thread.h" -#include "content/public/browser/render_frame_host.h" -#include "content/public/browser/web_contents.h" -#include "content/public/browser/web_contents_observer.h" -#include "extensions/browser/extension_function_dispatcher.h" -#include "extensions/common/constants.h" -#include "extensions/common/extension_messages.h" -#include "ipc/ipc_message.h" -#include "ipc/ipc_message_macros.h" -#include "ppapi/c/pp_errors.h" -#include "ppapi/host/dispatch_host_message.h" -#include "ppapi/host/host_message_context.h" -#include "ppapi/proxy/ppapi_messages.h" - -namespace chrome { - -class PepperExtensionsCommonMessageFilter::DispatcherOwner - : public content::WebContentsObserver, - public extensions::ExtensionFunctionDispatcher::Delegate { - public: - DispatcherOwner(PepperExtensionsCommonMessageFilter* message_filter, - Profile* profile, - content::RenderFrameHost* frame_host, - content::WebContents* web_contents) - : content::WebContentsObserver(web_contents), - render_frame_host_(frame_host), - message_filter_(message_filter), - dispatcher_(profile, this) {} - - virtual ~DispatcherOwner() { message_filter_->DetachDispatcherOwner(); } - - // content::WebContentsObserver implementation. - virtual void RenderFrameDeleted(content::RenderFrameHost* render_frame_host) - OVERRIDE { - if (render_frame_host == render_frame_host_) - delete this; - } - - // extensions::ExtensionFunctionDispatcher::Delegate implementation. - virtual extensions::WindowController* GetExtensionWindowController() const - OVERRIDE { - NOTREACHED(); - return NULL; - } - - virtual content::WebContents* GetAssociatedWebContents() const OVERRIDE { - NOTREACHED(); - return NULL; - } - - extensions::ExtensionFunctionDispatcher* dispatcher() { return &dispatcher_; } - content::RenderFrameHost* render_frame_host() { return render_frame_host_; } - - private: - content::RenderFrameHost* render_frame_host_; - scoped_refptr<PepperExtensionsCommonMessageFilter> message_filter_; - extensions::ExtensionFunctionDispatcher dispatcher_; - - DISALLOW_COPY_AND_ASSIGN(DispatcherOwner); -}; - -// static -PepperExtensionsCommonMessageFilter* -PepperExtensionsCommonMessageFilter::Create(content::BrowserPpapiHost* host, - PP_Instance instance) { - DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::IO)); - - int render_process_id = 0; - int render_frame_id = 0; - if (!host->GetRenderFrameIDsForInstance( - instance, &render_process_id, &render_frame_id)) { - return NULL; - } - - base::FilePath profile_directory = host->GetProfileDataDirectory(); - GURL document_url = host->GetDocumentURLForInstance(instance); - - return new PepperExtensionsCommonMessageFilter( - render_process_id, render_frame_id, profile_directory, document_url); -} - -PepperExtensionsCommonMessageFilter::PepperExtensionsCommonMessageFilter( - int render_process_id, - int render_frame_id, - const base::FilePath& profile_directory, - const GURL& document_url) - : render_process_id_(render_process_id), - render_frame_id_(render_frame_id), - profile_directory_(profile_directory), - document_url_(document_url), - dispatcher_owner_(NULL), - dispatcher_owner_initialized_(false) {} - -PepperExtensionsCommonMessageFilter::~PepperExtensionsCommonMessageFilter() {} - -scoped_refptr<base::TaskRunner> -PepperExtensionsCommonMessageFilter::OverrideTaskRunnerForMessage( - const IPC::Message& msg) { - return content::BrowserThread::GetMessageLoopProxyForThread( - content::BrowserThread::UI); -} - -int32_t PepperExtensionsCommonMessageFilter::OnResourceMessageReceived( - const IPC::Message& msg, - ppapi::host::HostMessageContext* context) { - PPAPI_BEGIN_MESSAGE_MAP(PepperExtensionsCommonMessageFilter, msg) - PPAPI_DISPATCH_HOST_RESOURCE_CALL(PpapiHostMsg_ExtensionsCommon_Post, - OnPost) - PPAPI_DISPATCH_HOST_RESOURCE_CALL(PpapiHostMsg_ExtensionsCommon_Call, - OnCall) - PPAPI_END_MESSAGE_MAP() - return PP_ERROR_FAILED; -} - -int32_t PepperExtensionsCommonMessageFilter::OnPost( - ppapi::host::HostMessageContext* context, - const std::string& request_name, - base::ListValue& args) { - DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); - - if (!EnsureDispatcherOwnerInitialized()) - return PP_ERROR_FAILED; - - ExtensionHostMsg_Request_Params params; - PopulateParams(request_name, &args, false, ¶ms); - - dispatcher_owner_->dispatcher()->Dispatch( - params, dispatcher_owner_->render_frame_host()->GetRenderViewHost()); - // There will be no callback so return PP_OK. - return PP_OK; -} - -int32_t PepperExtensionsCommonMessageFilter::OnCall( - ppapi::host::HostMessageContext* context, - const std::string& request_name, - base::ListValue& args) { - DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); - - if (!EnsureDispatcherOwnerInitialized()) - return PP_ERROR_FAILED; - - ExtensionHostMsg_Request_Params params; - PopulateParams(request_name, &args, true, ¶ms); - - dispatcher_owner_->dispatcher()->DispatchWithCallback( - params, - dispatcher_owner_->render_frame_host(), - base::Bind(&PepperExtensionsCommonMessageFilter::OnCallCompleted, - this, - context->MakeReplyMessageContext())); - return PP_OK_COMPLETIONPENDING; -} - -bool PepperExtensionsCommonMessageFilter::EnsureDispatcherOwnerInitialized() { - DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); - if (dispatcher_owner_initialized_) - return (!!dispatcher_owner_); - dispatcher_owner_initialized_ = true; - - DCHECK(!dispatcher_owner_); - content::RenderFrameHost* frame_host = - content::RenderFrameHost::FromID(render_process_id_, render_frame_id_); - content::WebContents* web_contents = - content::WebContents::FromRenderFrameHost(frame_host); - - if (!document_url_.SchemeIs(extensions::kExtensionScheme)) - return false; - - ProfileManager* profile_manager = g_browser_process->profile_manager(); - if (!profile_manager) - return false; - Profile* profile = profile_manager->GetProfile(profile_directory_); - - // It will be automatically destroyed when |view_host| goes away. - dispatcher_owner_ = - new DispatcherOwner(this, profile, frame_host, web_contents); - return true; -} - -void PepperExtensionsCommonMessageFilter::DetachDispatcherOwner() { - DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); - dispatcher_owner_ = NULL; -} - -void PepperExtensionsCommonMessageFilter::PopulateParams( - const std::string& request_name, - base::ListValue* args, - bool has_callback, - ExtensionHostMsg_Request_Params* params) { - DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); - - params->name = request_name; - params->arguments.Swap(args); - - params->extension_id = document_url_.host(); - params->source_url = document_url_; - - // We don't need an ID to map a response to the corresponding request. - params->request_id = 0; - params->has_callback = has_callback; - params->user_gesture = false; -} - -void PepperExtensionsCommonMessageFilter::OnCallCompleted( - ppapi::host::ReplyMessageContext reply_context, - ExtensionFunction::ResponseType type, - const base::ListValue& results, - const std::string& /* error */) { - DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); - - if (type == ExtensionFunction::BAD_MESSAGE) { - // The input arguments were not validated at the plugin side, so don't kill - // the plugin process when we see a message with invalid arguments. - // TODO(yzshen): It is nicer to also do the validation at the plugin side. - type = ExtensionFunction::FAILED; - } - - reply_context.params.set_result( - type == ExtensionFunction::SUCCEEDED ? PP_OK : PP_ERROR_FAILED); - SendReply(reply_context, PpapiPluginMsg_ExtensionsCommon_CallReply(results)); -} - -} // namespace chrome diff --git a/chrome/browser/renderer_host/pepper/pepper_extensions_common_message_filter.h b/chrome/browser/renderer_host/pepper/pepper_extensions_common_message_filter.h deleted file mode 100644 index a5fa92b..0000000 --- a/chrome/browser/renderer_host/pepper/pepper_extensions_common_message_filter.h +++ /dev/null @@ -1,101 +0,0 @@ -// Copyright (c) 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 CHROME_BROWSER_RENDERER_HOST_PEPPER_PEPPER_EXTENSIONS_COMMON_MESSAGE_FILTER_H_ -#define CHROME_BROWSER_RENDERER_HOST_PEPPER_PEPPER_EXTENSIONS_COMMON_MESSAGE_FILTER_H_ - -#include <string> - -#include "base/basictypes.h" -#include "base/compiler_specific.h" -#include "base/files/file_path.h" -#include "base/memory/scoped_ptr.h" -#include "base/strings/string16.h" -#include "extensions/browser/extension_function.h" -#include "ppapi/c/pp_instance.h" -#include "ppapi/host/host_message_context.h" -#include "ppapi/host/resource_message_filter.h" -#include "url/gurl.h" - -struct ExtensionHostMsg_Request_Params; - -namespace base { -class ListValue; -} - -namespace content { -class BrowserPpapiHost; -} - -namespace chrome { - -class PepperExtensionsCommonMessageFilter - : public ppapi::host::ResourceMessageFilter { - public: - static PepperExtensionsCommonMessageFilter* Create( - content::BrowserPpapiHost* host, - PP_Instance instance); - - protected: - PepperExtensionsCommonMessageFilter(int render_process_id, - int render_frame_id, - const base::FilePath& profile_directory, - const GURL& document_url); - virtual ~PepperExtensionsCommonMessageFilter(); - - // ppapi::host::ResourceMessageFilter overrides. - virtual scoped_refptr<base::TaskRunner> OverrideTaskRunnerForMessage( - const IPC::Message& msg) OVERRIDE; - virtual int32_t OnResourceMessageReceived( - const IPC::Message& msg, - ppapi::host::HostMessageContext* context) OVERRIDE; - - private: - // DispatcherOwner holds an ExtensionFunctionDispatcher instance and acts as - // its delegate. It is designed to meet the lifespan requirements of - // ExtensionFunctionDispatcher and its delegate. (Please see the comment of - // ExtensionFunctionDispatcher constructor in - // extension_function_dispatcher.h.) - class DispatcherOwner; - - int32_t OnPost(ppapi::host::HostMessageContext* context, - const std::string& request_name, - base::ListValue& args); - - int32_t OnCall(ppapi::host::HostMessageContext* context, - const std::string& request_name, - base::ListValue& args); - - // Returns true if |dispatcher_owner_| is non-null. - bool EnsureDispatcherOwnerInitialized(); - // Resets |dispatcher_owner_| to NULL. - void DetachDispatcherOwner(); - - void PopulateParams(const std::string& request_name, - base::ListValue* args, - bool has_callback, - ExtensionHostMsg_Request_Params* params); - - void OnCallCompleted(ppapi::host::ReplyMessageContext reply_context, - ExtensionFunction::ResponseType type, - const base::ListValue& results, - const std::string& error); - - // All the members are initialized on the IO thread when the object is - // constructed, and accessed only on the UI thread afterwards. - int render_process_id_; - int render_frame_id_; - base::FilePath profile_directory_; - GURL document_url_; - - // Not-owning pointer. It will be set to NULL when it goes away. - DispatcherOwner* dispatcher_owner_; - bool dispatcher_owner_initialized_; - - DISALLOW_COPY_AND_ASSIGN(PepperExtensionsCommonMessageFilter); -}; - -} // namespace chrome - -#endif // CHROME_BROWSER_RENDERER_HOST_PEPPER_PEPPER_EXTENSIONS_COMMON_MESSAGE_FILTER_H_ diff --git a/chrome/chrome_browser.gypi b/chrome/chrome_browser.gypi index 841c733..8312cf3 100644 --- a/chrome/chrome_browser.gypi +++ b/chrome/chrome_browser.gypi @@ -1857,8 +1857,6 @@ 'browser/renderer_host/pepper/monitor_finder_mac.mm', 'browser/renderer_host/pepper/pepper_broker_message_filter.cc', 'browser/renderer_host/pepper/pepper_broker_message_filter.h', - 'browser/renderer_host/pepper/pepper_extensions_common_message_filter.cc', - 'browser/renderer_host/pepper/pepper_extensions_common_message_filter.h', 'browser/renderer_host/pepper/pepper_flash_browser_host.cc', 'browser/renderer_host/pepper/pepper_flash_browser_host.h', 'browser/renderer_host/pepper/pepper_flash_clipboard_message_filter.cc', diff --git a/chrome/chrome_renderer.gypi b/chrome/chrome_renderer.gypi index f8fb833..f6345be 100644 --- a/chrome/chrome_renderer.gypi +++ b/chrome/chrome_renderer.gypi @@ -85,10 +85,6 @@ 'renderer/extensions/page_actions_custom_bindings.h', 'renderer/extensions/page_capture_custom_bindings.cc', 'renderer/extensions/page_capture_custom_bindings.h', - 'renderer/extensions/pepper_request_natives.cc', - 'renderer/extensions/pepper_request_natives.h', - 'renderer/extensions/pepper_request_proxy.cc', - 'renderer/extensions/pepper_request_proxy.h', 'renderer/extensions/renderer_permissions_policy_delegate.cc', 'renderer/extensions/renderer_permissions_policy_delegate.h', 'renderer/extensions/resource_request_policy.cc', @@ -166,7 +162,6 @@ 'renderer/resources/extensions/page_action_custom_bindings.js', 'renderer/resources/extensions/page_actions_custom_bindings.js', 'renderer/resources/extensions/page_capture_custom_bindings.js', - 'renderer/resources/extensions/pepper_request.js', 'renderer/resources/extensions/system_indicator_custom_bindings.js', 'renderer/resources/extensions/tts_custom_bindings.js', 'renderer/resources/extensions/tts_engine_custom_bindings.js', @@ -191,8 +186,6 @@ 'renderer/page_load_histograms.h', 'renderer/pepper/chrome_renderer_pepper_host_factory.cc', 'renderer/pepper/chrome_renderer_pepper_host_factory.h', - 'renderer/pepper/pepper_extensions_common_host.cc', - 'renderer/pepper/pepper_extensions_common_host.h', 'renderer/pepper/pepper_flash_drm_renderer_host.cc', 'renderer/pepper/pepper_flash_drm_renderer_host.h', 'renderer/pepper/pepper_flash_font_file_host.cc', diff --git a/chrome/renderer/extensions/chrome_extensions_dispatcher_delegate.cc b/chrome/renderer/extensions/chrome_extensions_dispatcher_delegate.cc index 8ea9568..671566b 100644 --- a/chrome/renderer/extensions/chrome_extensions_dispatcher_delegate.cc +++ b/chrome/renderer/extensions/chrome_extensions_dispatcher_delegate.cc @@ -22,7 +22,6 @@ #include "chrome/renderer/extensions/notifications_native_handler.h" #include "chrome/renderer/extensions/page_actions_custom_bindings.h" #include "chrome/renderer/extensions/page_capture_custom_bindings.h" -#include "chrome/renderer/extensions/pepper_request_natives.h" #include "chrome/renderer/extensions/sync_file_system_custom_bindings.h" #include "chrome/renderer/extensions/tab_finder.h" #include "chrome/renderer/extensions/tabs_custom_bindings.h" @@ -127,9 +126,6 @@ void ChromeExtensionsDispatcherDelegate::RegisterNativeHandlers( scoped_ptr<NativeHandler>( new extensions::PageCaptureCustomBindings(context))); module_system->RegisterNativeHandler( - "pepper_request_natives", - scoped_ptr<NativeHandler>(new extensions::PepperRequestNatives(context))); - module_system->RegisterNativeHandler( "tabs", scoped_ptr<NativeHandler>(new extensions::TabsCustomBindings(context))); module_system->RegisterNativeHandler( @@ -149,9 +145,6 @@ void ChromeExtensionsDispatcherDelegate::RegisterNativeHandlers( void ChromeExtensionsDispatcherDelegate::PopulateSourceMap( extensions::ResourceBundleSourceMap* source_map) { - // Libraries. - source_map->RegisterSource("pepper_request", IDR_PEPPER_REQUEST_JS); - // Custom bindings. source_map->RegisterSource("app", IDR_APP_CUSTOM_BINDINGS_JS); source_map->RegisterSource("app.window", IDR_APP_WINDOW_CUSTOM_BINDINGS_JS); diff --git a/chrome/renderer/extensions/chrome_v8_context.cc b/chrome/renderer/extensions/chrome_v8_context.cc index 8d58f70..ca68bb1 100644 --- a/chrome/renderer/extensions/chrome_v8_context.cc +++ b/chrome/renderer/extensions/chrome_v8_context.cc @@ -21,8 +21,7 @@ ChromeV8Context::ChromeV8Context(const v8::Handle<v8::Context>& v8_context, blink::WebFrame* web_frame, const Extension* extension, Feature::Context context_type) - : ScriptContext(v8_context, web_frame, extension, context_type), - pepper_request_proxy_(this) { + : ScriptContext(v8_context, web_frame, extension, context_type) { } } // namespace extensions diff --git a/chrome/renderer/extensions/chrome_v8_context.h b/chrome/renderer/extensions/chrome_v8_context.h index d4779db..1b74453 100644 --- a/chrome/renderer/extensions/chrome_v8_context.h +++ b/chrome/renderer/extensions/chrome_v8_context.h @@ -9,7 +9,6 @@ #include "base/basictypes.h" #include "base/compiler_specific.h" -#include "chrome/renderer/extensions/pepper_request_proxy.h" #include "extensions/common/features/feature.h" #include "extensions/renderer/module_system.h" #include "extensions/renderer/request_sender.h" @@ -37,14 +36,7 @@ class ChromeV8Context : public ScriptContext { const Extension* extension, Feature::Context context_type); - PepperRequestProxy* pepper_request_proxy() { - return &pepper_request_proxy_; - } - private: - // The proxy for this context for making API calls from Pepper via Javascript. - PepperRequestProxy pepper_request_proxy_; - DISALLOW_COPY_AND_ASSIGN(ChromeV8Context); }; diff --git a/chrome/renderer/extensions/pepper_request_natives.cc b/chrome/renderer/extensions/pepper_request_natives.cc deleted file mode 100644 index 75bc5b4..0000000 --- a/chrome/renderer/extensions/pepper_request_natives.cc +++ /dev/null @@ -1,50 +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 "chrome/renderer/extensions/pepper_request_natives.h" - -#include <string> - -#include "base/logging.h" -#include "base/values.h" -#include "chrome/renderer/extensions/chrome_v8_context.h" -#include "content/public/renderer/v8_value_converter.h" - -namespace extensions { - -PepperRequestNatives::PepperRequestNatives(ScriptContext* context) - : ObjectBackedNativeHandler(context) { - RouteFunction( - "SendResponse", - base::Bind(&PepperRequestNatives::SendResponse, base::Unretained(this))); -} - -void PepperRequestNatives::SendResponse( - const v8::FunctionCallbackInfo<v8::Value>& args) { - DCHECK_EQ(3, args.Length()); - DCHECK(args[0]->IsInt32()); - DCHECK(args[1]->IsArray()); - int request_id = args[0]->Int32Value(); - - // TODO(rockot): This downcast should be eliminated. - // See http://crbug.com/362616. - ChromeV8Context* chrome_context = static_cast<ChromeV8Context*>(context()); - if (args[2]->IsString()) { - chrome_context->pepper_request_proxy()->OnResponseReceived( - request_id, false, base::ListValue(), *v8::String::Utf8Value(args[2])); - return; - } - - scoped_ptr<content::V8ValueConverter> converter( - content::V8ValueConverter::create()); - scoped_ptr<const base::Value> result( - converter->FromV8Value(args[1], chrome_context->v8_context())); - DCHECK(result); - const base::ListValue* result_list = NULL; - CHECK(result->GetAsList(&result_list)); - chrome_context->pepper_request_proxy()->OnResponseReceived( - request_id, true, *result_list, ""); -} - -} // namespace extensions diff --git a/chrome/renderer/extensions/pepper_request_natives.h b/chrome/renderer/extensions/pepper_request_natives.h deleted file mode 100644 index c1b1add..0000000 --- a/chrome/renderer/extensions/pepper_request_natives.h +++ /dev/null @@ -1,36 +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 CHROME_RENDERER_EXTENSIONS_PEPPER_REQUEST_NATIVES_H_ -#define CHROME_RENDERER_EXTENSIONS_PEPPER_REQUEST_NATIVES_H_ - -#include "base/compiler_specific.h" -#include "extensions/renderer/object_backed_native_handler.h" - -namespace base { -class Value; -} - -namespace extensions { - -// Custom bindings for handling API calls from pepper plugins. -class PepperRequestNatives : public ObjectBackedNativeHandler { - public: - explicit PepperRequestNatives(ScriptContext* context); - - private: - // Sends a response to an API call to the pepper plugin which made the call. - // |args| should contain: - // |request_id|: An int containing the id of the request. - // |response|: An array containing the response. - // |error|: A string containing the error message if an error occurred or - // null if the call was successful. - void SendResponse(const v8::FunctionCallbackInfo<v8::Value>& args); - - DISALLOW_COPY_AND_ASSIGN(PepperRequestNatives); -}; - -} // namespace extensions - -#endif // CHROME_RENDERER_EXTENSIONS_PEPPER_REQUEST_NATIVES_H_ diff --git a/chrome/renderer/extensions/pepper_request_proxy.cc b/chrome/renderer/extensions/pepper_request_proxy.cc deleted file mode 100644 index c3936fd..0000000 --- a/chrome/renderer/extensions/pepper_request_proxy.cc +++ /dev/null @@ -1,63 +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 "chrome/renderer/extensions/pepper_request_proxy.h" - -#include "base/values.h" -#include "chrome/renderer/extensions/chrome_v8_context.h" -#include "content/public/renderer/v8_value_converter.h" - -namespace extensions { - -PepperRequestProxy::PepperRequestProxy(ChromeV8Context* context) - : context_(context), - isolate_(context->v8_context()->GetIsolate()), - next_request_id_(0) {} - -PepperRequestProxy::~PepperRequestProxy() {} - -bool PepperRequestProxy::StartRequest(const ResponseCallback& callback, - const std::string& request_name, - const base::ListValue& args, - std::string* error) { - int request_id = next_request_id_++; - pending_request_map_[request_id] = callback; - - // TODO(sammc): Converting from base::Value to v8::Value and then back to - // base::Value is not optimal. For most API calls the JS code doesn't do much. - // http://crbug.com/324115. - v8::HandleScope scope(isolate_); - scoped_ptr<content::V8ValueConverter> converter( - content::V8ValueConverter::create()); - std::vector<v8::Handle<v8::Value> > v8_args; - v8_args.push_back(v8::String::NewFromUtf8(isolate_, request_name.c_str())); - v8_args.push_back(v8::Integer::New(isolate_, request_id)); - for (base::ListValue::const_iterator it = args.begin(); it != args.end(); - ++it) { - v8_args.push_back(converter->ToV8Value(*it, context_->v8_context())); - } - v8::Handle<v8::Value> v8_error = context_->module_system()->CallModuleMethod( - "pepper_request", "startRequest", &v8_args); - if (v8_error->IsString()) { - if (error) { - *error = *v8::String::Utf8Value(v8_error); - pending_request_map_.erase(request_id); - } - return false; - } - - return true; -} - -void PepperRequestProxy::OnResponseReceived(int request_id, - bool success, - const base::ListValue& args, - const std::string& error) { - PendingRequestMap::iterator it = pending_request_map_.find(request_id); - DCHECK(it != pending_request_map_.end()); - it->second.Run(success, args, error); - pending_request_map_.erase(it); -} - -} // namespace extensions diff --git a/chrome/renderer/extensions/pepper_request_proxy.h b/chrome/renderer/extensions/pepper_request_proxy.h deleted file mode 100644 index 8c05c85..0000000 --- a/chrome/renderer/extensions/pepper_request_proxy.h +++ /dev/null @@ -1,65 +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 CHROME_RENDERER_EXTENSIONS_PEPPER_REQUEST_PROXY_H_ -#define CHROME_RENDERER_EXTENSIONS_PEPPER_REQUEST_PROXY_H_ - -#include <map> -#include <string> - -#include "base/callback.h" - -namespace base { -class ListValue; -} - -namespace v8 { -class Isolate; -} - -namespace extensions { - -class ChromeV8Context; - -// A proxy that forwards pepper apps API calls through the Javascript API -// bindings. -class PepperRequestProxy { - public: - // A callback to be called with the result of an API call. If |success| is - // true, |response| will contain the response value. Otherwise, |error| will - // contain the error message. - typedef base::Callback<void(bool success, - const base::ListValue& response, - const std::string& error)> ResponseCallback; - - explicit PepperRequestProxy(ChromeV8Context* context); - ~PepperRequestProxy(); - - // Starts an API request. Returns whether the call was successful. On failure, - // |error| will contain the error message. |callback| will only be called on - // success. - bool StartRequest(const ResponseCallback& callback, - const std::string& request_name, - const base::ListValue& args, - std::string* error); - - void OnResponseReceived(int request_id, - bool success, - const base::ListValue& args, - const std::string& error); - - private: - typedef std::map<int, ResponseCallback> PendingRequestMap; - - // Non-owning pointer. - ChromeV8Context* context_; - // Non-owning pointer. - v8::Isolate* isolate_; - PendingRequestMap pending_request_map_; - int next_request_id_; -}; - -} // namespace extensions - -#endif // CHROME_RENDERER_EXTENSIONS_PEPPER_REQUEST_PROXY_H_ diff --git a/chrome/renderer/pepper/chrome_renderer_pepper_host_factory.cc b/chrome/renderer/pepper/chrome_renderer_pepper_host_factory.cc index 447c4dd..789a86a 100644 --- a/chrome/renderer/pepper/chrome_renderer_pepper_host_factory.cc +++ b/chrome/renderer/pepper/chrome_renderer_pepper_host_factory.cc @@ -5,7 +5,6 @@ #include "chrome/renderer/pepper/chrome_renderer_pepper_host_factory.h" #include "base/logging.h" -#include "chrome/renderer/pepper/pepper_extensions_common_host.h" #include "chrome/renderer/pepper/pepper_flash_drm_renderer_host.h" #include "chrome/renderer/pepper/pepper_flash_font_file_host.h" #include "chrome/renderer/pepper/pepper_flash_fullscreen_host.h" @@ -39,17 +38,6 @@ scoped_ptr<ResourceHost> ChromeRendererPepperHostFactory::CreateResourceHost( if (!host_->IsValidInstance(instance)) return scoped_ptr<ResourceHost>(); - // Dev interfaces. - if (host_->GetPpapiHost()->permissions().HasPermission( - ppapi::PERMISSION_DEV)) { - switch (message.type()) { - case PpapiHostMsg_ExtensionsCommon_Create::ID: { - return scoped_ptr<ResourceHost>(PepperExtensionsCommonHost::Create( - host_, instance, params.pp_resource())); - } - } - } - if (host_->GetPpapiHost()->permissions().HasPermission( ppapi::PERMISSION_FLASH)) { switch (message.type()) { diff --git a/chrome/renderer/pepper/pepper_extensions_common_host.cc b/chrome/renderer/pepper/pepper_extensions_common_host.cc deleted file mode 100644 index d3a937c..0000000 --- a/chrome/renderer/pepper/pepper_extensions_common_host.cc +++ /dev/null @@ -1,122 +0,0 @@ -// Copyright (c) 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 "chrome/renderer/pepper/pepper_extensions_common_host.h" - -#include "base/logging.h" -#include "base/memory/scoped_ptr.h" -#include "base/values.h" -#include "chrome/renderer/extensions/chrome_v8_context.h" -#include "content/public/renderer/render_view.h" -#include "content/public/renderer/renderer_ppapi_host.h" -#include "extensions/renderer/dispatcher.h" -#include "extensions/renderer/extension_helper.h" -#include "ppapi/c/pp_errors.h" -#include "ppapi/host/dispatch_host_message.h" -#include "ppapi/host/host_message_context.h" -#include "ppapi/host/ppapi_host.h" -#include "ppapi/proxy/ppapi_messages.h" -#include "third_party/WebKit/public/web/WebDocument.h" -#include "third_party/WebKit/public/web/WebElement.h" -#include "third_party/WebKit/public/web/WebLocalFrame.h" -#include "third_party/WebKit/public/web/WebPluginContainer.h" - -namespace { -void DoNothing(bool success, - const base::ListValue& response, - const std::string& error) {} -} - -PepperExtensionsCommonHost::PepperExtensionsCommonHost( - content::RendererPpapiHost* host, - PP_Instance instance, - PP_Resource resource, - extensions::PepperRequestProxy* pepper_request_proxy) - : ResourceHost(host->GetPpapiHost(), instance, resource), - renderer_ppapi_host_(host), - pepper_request_proxy_(pepper_request_proxy), - weak_factory_(this) {} - -PepperExtensionsCommonHost::~PepperExtensionsCommonHost() {} - -// static -PepperExtensionsCommonHost* PepperExtensionsCommonHost::Create( - content::RendererPpapiHost* host, - PP_Instance instance, - PP_Resource resource) { - content::RenderView* render_view = host->GetRenderViewForInstance(instance); - if (!render_view) - return NULL; - extensions::ExtensionHelper* extension_helper = - extensions::ExtensionHelper::Get(render_view); - if (!extension_helper) - return NULL; - extensions::Dispatcher* dispatcher = extension_helper->dispatcher(); - if (!dispatcher) - return NULL; - blink::WebPluginContainer* container = - host->GetContainerForInstance(instance); - if (!container) - return NULL; - blink::WebLocalFrame* frame = container->element().document().frame(); - if (!frame) - return NULL; - v8::HandleScope scope(v8::Isolate::GetCurrent()); - // TODO(rockot): Remove this downcast. See http://crbug.com/362616. - extensions::ChromeV8Context* context = - static_cast<extensions::ChromeV8Context*>( - dispatcher->script_context_set().GetByV8Context( - frame->mainWorldScriptContext())); - if (!context) - return NULL; - - return new PepperExtensionsCommonHost( - host, instance, resource, context->pepper_request_proxy()); -} - -int32_t PepperExtensionsCommonHost::OnResourceMessageReceived( - const IPC::Message& msg, - ppapi::host::HostMessageContext* context) { - PPAPI_BEGIN_MESSAGE_MAP(PepperExtensionsCommonHost, msg) - PPAPI_DISPATCH_HOST_RESOURCE_CALL(PpapiHostMsg_ExtensionsCommon_Post, - OnPost) - PPAPI_DISPATCH_HOST_RESOURCE_CALL(PpapiHostMsg_ExtensionsCommon_Call, - OnCall) - PPAPI_END_MESSAGE_MAP() - return PP_ERROR_FAILED; -} - -void PepperExtensionsCommonHost::OnResponseReceived( - ppapi::host::ReplyMessageContext reply_context, - bool success, - const base::ListValue& response, - const std::string& /* error */) { - reply_context.params.set_result(success ? PP_OK : PP_ERROR_FAILED); - SendReply(reply_context, PpapiPluginMsg_ExtensionsCommon_CallReply(response)); -} - -int32_t PepperExtensionsCommonHost::OnPost( - ppapi::host::HostMessageContext* context, - const std::string& request_name, - const base::ListValue& args) { - std::string error; - bool success = pepper_request_proxy_->StartRequest( - base::Bind(&DoNothing), request_name, args, &error); - return success ? PP_OK : PP_ERROR_FAILED; -} - -int32_t PepperExtensionsCommonHost::OnCall( - ppapi::host::HostMessageContext* context, - const std::string& request_name, - const base::ListValue& args) { - std::string error; - bool success = pepper_request_proxy_->StartRequest( - base::Bind(&PepperExtensionsCommonHost::OnResponseReceived, - weak_factory_.GetWeakPtr(), - context->MakeReplyMessageContext()), - request_name, - args, - &error); - return success ? PP_OK_COMPLETIONPENDING : PP_ERROR_FAILED; -} diff --git a/chrome/renderer/pepper/pepper_extensions_common_host.h b/chrome/renderer/pepper/pepper_extensions_common_host.h deleted file mode 100644 index afe0658..0000000 --- a/chrome/renderer/pepper/pepper_extensions_common_host.h +++ /dev/null @@ -1,80 +0,0 @@ -// Copyright (c) 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 CHROME_RENDERER_PEPPER_PEPPER_EXTENSIONS_COMMON_HOST_H_ -#define CHROME_RENDERER_PEPPER_PEPPER_EXTENSIONS_COMMON_HOST_H_ - -#include <map> -#include <string> - -#include "base/basictypes.h" -#include "base/bind.h" -#include "base/compiler_specific.h" -#include "base/memory/linked_ptr.h" -#include "base/memory/weak_ptr.h" -#include "chrome/renderer/extensions/pepper_request_proxy.h" -#include "ppapi/host/resource_host.h" - -namespace base { -class ListValue; -} - -namespace content { -class RendererPpapiHost; -} - -namespace ppapi { -namespace host { -struct ReplyMessageContext; -} -} - -namespace extensions { -class Dispatcher; -} - -class PepperExtensionsCommonHost : public ppapi::host::ResourceHost { - public: - virtual ~PepperExtensionsCommonHost(); - - static PepperExtensionsCommonHost* Create(content::RendererPpapiHost* host, - PP_Instance instance, - PP_Resource resource); - - // ppapi::host::ResourceMessageHandler overrides. - virtual int32_t OnResourceMessageReceived( - const IPC::Message& msg, - ppapi::host::HostMessageContext* context) OVERRIDE; - - private: - PepperExtensionsCommonHost( - content::RendererPpapiHost* host, - PP_Instance instance, - PP_Resource resource, - extensions::PepperRequestProxy* pepper_request_proxy); - - int32_t OnPost(ppapi::host::HostMessageContext* context, - const std::string& request_name, - const base::ListValue& args); - - int32_t OnCall(ppapi::host::HostMessageContext* context, - const std::string& request_name, - const base::ListValue& args); - - void OnResponseReceived(ppapi::host::ReplyMessageContext reply_context, - bool success, - const base::ListValue& response, - const std::string& error); - - // Non-owning pointer. - content::RendererPpapiHost* renderer_ppapi_host_; - // Non-owning pointer. - extensions::PepperRequestProxy* pepper_request_proxy_; - - base::WeakPtrFactory<PepperExtensionsCommonHost> weak_factory_; - - DISALLOW_COPY_AND_ASSIGN(PepperExtensionsCommonHost); -}; - -#endif // CHROME_RENDERER_PEPPER_PEPPER_EXTENSIONS_COMMON_HOST_H_ diff --git a/chrome/renderer/resources/extensions/pepper_request.js b/chrome/renderer/resources/extensions/pepper_request.js deleted file mode 100644 index 310e638..0000000 --- a/chrome/renderer/resources/extensions/pepper_request.js +++ /dev/null @@ -1,54 +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. - -var SendResponse = requireNative('pepper_request_natives').SendResponse; -var GetAvailability = requireNative('v8_context').GetAvailability; -var utils = require('utils'); -var schemaRegistry = requireNative('schema_registry'); - -function takesCallback(targetName) { - var parts = $String.split(targetName, '.'); - var schemaName = $Array.join($Array.slice(parts, 0, parts.length - 1), '.'); - var functionName = parts[parts.length - 1]; - var functions = schemaRegistry.GetSchema(schemaName).functions; - var parameters = utils.lookup(functions, 'name', functionName).parameters; - return parameters.length > 0 && - parameters[parameters.length - 1].type == 'function'; -} - -function resolveName(name) { - var availability = GetAvailability(name); - if (!availability.is_available) - throw Error(availability.message); - var item = chrome; - var nameComponents = $String.split(name, '.'); - for (var i = 0; i < nameComponents.length; i++) { - item = item[nameComponents[i]]; - } - return item; -} - -function startRequest(targetName, requestId) { - var args = $Array.slice(arguments, 2); - try { - var hasCallback = takesCallback(targetName); - if (hasCallback) { - args.push(function() { - var error = null; - if (chrome.runtime.lastError) - error = chrome.runtime.lastError.message; - SendResponse(requestId, $Array.slice(arguments), error); - }); - } - var target = resolveName(targetName); - var result = $Function.apply(target, null, args); - if (!hasCallback) - SendResponse(requestId, [result], null); - } catch (e) { - // TODO(sammc): Catch this from C++. - return e.message; - } -} - -exports.startRequest = startRequest; diff --git a/chrome/renderer/resources/renderer_resources.grd b/chrome/renderer/resources/renderer_resources.grd index fe4f38a..58d1557 100644 --- a/chrome/renderer/resources/renderer_resources.grd +++ b/chrome/renderer/resources/renderer_resources.grd @@ -70,7 +70,6 @@ <include name="IDR_PAGE_ACTIONS_CUSTOM_BINDINGS_JS" file="extensions\page_actions_custom_bindings.js" type="BINDATA" /> <include name="IDR_PAGE_ACTION_CUSTOM_BINDINGS_JS" file="extensions\page_action_custom_bindings.js" type="BINDATA" /> <include name="IDR_PAGE_CAPTURE_CUSTOM_BINDINGS_JS" file="extensions\page_capture_custom_bindings.js" type="BINDATA" /> - <include name="IDR_PEPPER_REQUEST_JS" file="extensions\pepper_request.js" type="BINDATA" /> <include name="IDR_SYNC_FILE_SYSTEM_CUSTOM_BINDINGS_JS" file="extensions\sync_file_system_custom_bindings.js" type="BINDATA" /> <include name="IDR_SYSTEM_INDICATOR_CUSTOM_BINDINGS_JS" file="extensions\system_indicator_custom_bindings.js" type="BINDATA" /> <include name="IDR_TAB_CAPTURE_CUSTOM_BINDINGS_JS" file="extensions\tab_capture_custom_bindings.js" type="BINDATA" /> diff --git a/content/renderer/pepper/pepper_plugin_instance_impl.cc b/content/renderer/pepper/pepper_plugin_instance_impl.cc index 735a7b9..7db4c54 100644 --- a/content/renderer/pepper/pepper_plugin_instance_impl.cc +++ b/content/renderer/pepper/pepper_plugin_instance_impl.cc @@ -2573,7 +2573,6 @@ ppapi::Resource* PepperPluginInstanceImpl::GetSingletonResource( switch (id) { case ppapi::BROKER_SINGLETON_ID: case ppapi::BROWSER_FONT_SINGLETON_ID: - case ppapi::EXTENSIONS_COMMON_SINGLETON_ID: case ppapi::FILE_MAPPING_SINGLETON_ID: case ppapi::FLASH_CLIPBOARD_SINGLETON_ID: case ppapi::FLASH_FILE_SINGLETON_ID: diff --git a/content/renderer/pepper/plugin_module.cc b/content/renderer/pepper/plugin_module.cc index 04bdeae..48add88 100644 --- a/content/renderer/pepper/plugin_module.cc +++ b/content/renderer/pepper/plugin_module.cc @@ -29,7 +29,6 @@ #include "content/renderer/pepper/ppb_video_decoder_impl.h" #include "content/renderer/pepper/renderer_ppapi_host_impl.h" #include "content/renderer/render_view_impl.h" -#include "ppapi/c/dev/ppb_alarms_dev.h" #include "ppapi/c/dev/ppb_audio_input_dev.h" #include "ppapi/c/dev/ppb_buffer_dev.h" #include "ppapi/c/dev/ppb_char_set_dev.h" diff --git a/native_client_sdk/src/libraries/ppapi/library.dsc b/native_client_sdk/src/libraries/ppapi/library.dsc index 4fda210..b213395 100644 --- a/native_client_sdk/src/libraries/ppapi/library.dsc +++ b/native_client_sdk/src/libraries/ppapi/library.dsc @@ -96,7 +96,6 @@ { 'FILES': [ 'deprecated_bool.h', - 'ppb_alarms_dev.h', 'ppb_cursor_control_dev.h', 'ppb_file_chooser_dev.h', 'ppb_font_dev.h', @@ -109,7 +108,6 @@ 'ppb_view_dev.h', 'ppb_zoom_dev.h', 'pp_cursor_type_dev.h', - 'pp_optional_structs_dev.h', 'ppp_class_deprecated.h', 'ppp_network_state_dev.h', 'ppp_printing_dev.h', diff --git a/native_client_sdk/src/libraries/ppapi_cpp/library.dsc b/native_client_sdk/src/libraries/ppapi_cpp/library.dsc index a2166f9..bb3d032 100644 --- a/native_client_sdk/src/libraries/ppapi_cpp/library.dsc +++ b/native_client_sdk/src/libraries/ppapi_cpp/library.dsc @@ -63,7 +63,6 @@ 'websocket.cc', # ppapi/cpp/dev - 'alarms_dev.cc', 'cursor_control_dev.cc', 'file_chooser_dev.cc', 'font_dev.cc', @@ -71,7 +70,6 @@ 'printing_dev.cc', 'scriptable_object_deprecated.cc', 'selection_dev.cc', - 'string_wrapper_dev.cc', 'truetype_font_dev.cc', 'view_dev.cc', 'zoom_dev.cc', @@ -152,20 +150,13 @@ }, { 'FILES': [ - 'alarms_dev.h', - 'array_dev.h', 'cursor_control_dev.h', 'file_chooser_dev.h', 'font_dev.h', - 'may_own_ptr_dev.h', 'memory_dev.h', - 'optional_dev.h', 'printing_dev.h', 'scriptable_object_deprecated.h', 'selection_dev.h', - 'string_wrapper_dev.h', - 'struct_wrapper_output_traits_dev.h', - 'to_c_type_converter_dev.h', 'truetype_font_dev.h', 'video_capture_client_dev.h', 'video_decoder_client_dev.h', diff --git a/ppapi/BUILD.gn b/ppapi/BUILD.gn index 8a2f1bb..78d5ce9 100644 --- a/ppapi/BUILD.gn +++ b/ppapi/BUILD.gn @@ -189,8 +189,6 @@ component("ppapi_shared") { "shared_impl/var.h", "shared_impl/var_tracker.cc", "shared_impl/var_tracker.h", - "shared_impl/var_value_conversions.cc", - "shared_impl/var_value_conversions.h", # TODO(viettrungluu): Split these out; it won"t be used in NaCl. "shared_impl/private/net_address_private_impl.cc", "shared_impl/private/net_address_private_impl_constants.cc", @@ -201,8 +199,6 @@ component("ppapi_shared") { "thunk/enter.cc", "thunk/enter.h", - "thunk/extensions_common_api.h", - "thunk/ppb_alarms_dev_thunk.cc", "thunk/ppb_audio_api.h", "thunk/ppb_audio_config_api.h", "thunk/ppb_audio_config_thunk.cc", @@ -473,8 +469,6 @@ component("ppapi_proxy") { "proxy/enter_proxy.h", "proxy/error_conversion.cc", "proxy/error_conversion.h", - "proxy/extensions_common_resource.cc", - "proxy/extensions_common_resource.h", "proxy/file_chooser_resource.cc", "proxy/file_chooser_resource.h", "proxy/file_io_resource.cc", diff --git a/ppapi/api/dev/pp_optional_structs_dev.idl b/ppapi/api/dev/pp_optional_structs_dev.idl deleted file mode 100644 index 3e0829f..0000000 --- a/ppapi/api/dev/pp_optional_structs_dev.idl +++ /dev/null @@ -1,14 +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. - */ - -/** - * This file defines optional structs for primitive types. - */ - -struct PP_Optional_Double_Dev { - double_t value; - PP_Bool is_set; -}; - diff --git a/ppapi/api/dev/ppb_alarms_dev.idl b/ppapi/api/dev/ppb_alarms_dev.idl deleted file mode 100644 index b2345c4..0000000 --- a/ppapi/api/dev/ppb_alarms_dev.idl +++ /dev/null @@ -1,181 +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. - */ - -/** - * This file defines the Pepper equivalent of the <code>chrome.alarms</code> - * extension API. - */ - -label Chrome { - M33 = 0.1 -}; - -struct PP_Alarms_Alarm_Dev { - /** - * Name of this alarm. - */ - PP_Var name; - /** - * Time at which this alarm was scheduled to fire, in milliseconds past the - * epoch. For performance reasons, the alarm may have been delayed an - * arbitrary amount beyond this. - */ - double_t scheduled_time; - /** - * If set, the alarm is a repeating alarm and will fire again in - * <code>period_in_minutes</code> minutes. - */ - PP_Optional_Double_Dev period_in_minutes; -}; - -struct PP_Alarms_AlarmCreateInfo_Dev { - /** - * Time at which the alarm should fire, in milliseconds past the epoch. - */ - PP_Optional_Double_Dev when; - /** - * Length of time in minutes after which the - * <code>PP_Alarms_OnAlarm_Dev</code> event should fire. - */ - PP_Optional_Double_Dev delay_in_minutes; - /** - * If set, the <code>PP_Alarms_OnAlarm_Dev</code> event should fire every - * <code>period_in_minutes</code> minutes after the initial event specified by - * <code>when</code> or <code>delay_in_minutes</code>. If not set, the alarm - * will only fire once. - */ - PP_Optional_Double_Dev period_in_minutes; -}; - -struct PP_Alarms_Alarm_Array_Dev { - uint32_t size; - [size_is(count)] PP_Alarms_Alarm_Dev[] elements; -}; - -/** - * Fired when an alarm has elapsed. Useful for event pages. - * - * @param[in] listener_id The listener ID. - * @param[inout] user_data The opaque pointer that was used when registering the - * listener. - * @param[in] alarm The alarm that has elapsed. - */ -typedef void PP_Alarms_OnAlarm_Dev( - [in] uint32_t listener_id, - [inout] mem_t user_data, - [in] PP_Alarms_Alarm_Dev alarm); - -interface PPB_Alarms_Dev { - /** - * Creates an alarm. Near the time(s) specified by <code>alarm_info</code>, - * the <code>PP_Alarms_OnAlarm_Dev</code> event is fired. If there is another - * alarm with the same name (or no name if none is specified), it will be - * cancelled and replaced by this alarm. - * - * In order to reduce the load on the user's machine, Chrome limits alarms - * to at most once every 1 minute but may delay them an arbitrary amount more. - * That is, setting - * <code>PP_Alarms_AlarmCreateInfo_Dev.delay_in_minutes</code> or - * <code>PP_Alarms_AlarmCreateInfo_Dev.period_in_minutes</code> to less than - * <code>1</code> will not be honored and will cause a warning. - * <code>PP_Alarms_AlarmCreateInfo_Dev.when</code> can be set to less than 1 - * minute after "now" without warning but won't actually cause the alarm to - * fire for at least 1 minute. - * - * To help you debug your app or extension, when you've loaded it unpacked, - * there's no limit to how often the alarm can fire. - * - * @param[in] instance A <code>PP_Instance</code>. - * @param[in] name A string or undefined <code>PP_Var</code>. Optional name to - * identify this alarm. Defaults to the empty string. - * @param[in] alarm_info Describes when the alarm should fire. The initial - * time must be specified by either <code>when</code> or - * <code>delay_in_minutes</code> (but not both). If - * <code>period_in_minutes</code> is set, the alarm will repeat every - * <code>period_in_minutes</code> minutes after the initial event. If neither - * <code>when</code> or <code>delay_in_minutes</code> is set for a repeating - * alarm, <code>period_in_minutes</code> is used as the default for - * <code>delay_in_minutes</code>. - */ - void Create( - [in] PP_Instance instance, - [in] PP_Var name, - [in] PP_Alarms_AlarmCreateInfo_Dev alarm_info); - - /** - * Retrieves details about the specified alarm. - * - * @param[in] instance A <code>PP_Instance</code>. - * @param[in] name A string or undefined <code>PP_Var</code>. The name of the - * alarm to get. Defaults to the empty string. - * @param[out] alarm A <code>PP_Alarms_Alarm_Dev</code> struct to store the - * output result. - * @param[in] callback A <code>PP_CompletionCallback</code> to be called upon - * completion. - * - * @return An error code from <code>pp_errors.h</code> - */ - int32_t Get( - [in] PP_Instance instance, - [in] PP_Var name, - [out] PP_Alarms_Alarm_Dev alarm, - [in] PP_CompletionCallback callback); - - /** - * Gets an array of all the alarms. - * - * @param[in] instance A <code>PP_Instance</code>. - * @param[out] alarms A <code>PP_Alarms_Alarm_Array_Dev</code> to store the - * output result. - * @param[in] array_allocator A <code>PP_ArrayOutput</code> to allocate memory - * for <code>alarms</code>. - * @param[in] callback A <code>PP_CompletionCallback</code> to be called upon - * completion. - * - * @return An error code from <code>pp_errors.h</code> - */ - int32_t GetAll( - [in] PP_Instance instance, - [out] PP_Alarms_Alarm_Array_Dev alarms, - [in] PP_ArrayOutput array_allocator, - [in] PP_CompletionCallback callback); - - /** - * Clears the alarm with the given name. - * - * @param[in] instance A <code>PP_Instance</code>. - * @param[in] name A string or undefined <code>PP_Var</code>. The name of the - * alarm to clear. Defaults to the empty string. - */ - void Clear( - [in] PP_Instance instance, - [in] PP_Var name); - - /** - * Clears all alarms. - * - * @param[in] instance A <code>PP_Instance</code>. - */ - void ClearAll( - [in] PP_Instance instance); - - /** - * Registers <code>PP_Alarms_OnAlarm_Dev</code> event. - * - * @param[in] instance A <code>PP_Instance</code>. - * @param[in] callback The callback to receive notifications. - * @param[inout] user_data An opaque pointer that will be passed to - * <code>callback</code>. - * - * @return A listener ID, or 0 if failed. - * - * TODO(yzshen): add a PPB_Events_Dev interface for unregistering: - * void UnregisterListener(PP_instance instance, uint32_t listener_id); - */ - uint32_t AddOnAlarmListener( - [in] PP_Instance instance, - [in] PP_Alarms_OnAlarm_Dev callback, - [inout] mem_t user_data); -}; diff --git a/ppapi/c/dev/pp_optional_structs_dev.h b/ppapi/c/dev/pp_optional_structs_dev.h deleted file mode 100644 index 06608fe..0000000 --- a/ppapi/c/dev/pp_optional_structs_dev.h +++ /dev/null @@ -1,34 +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. - */ - -/* From dev/pp_optional_structs_dev.idl modified Tue Dec 10 17:39:38 2013. */ - -#ifndef PPAPI_C_DEV_PP_OPTIONAL_STRUCTS_DEV_H_ -#define PPAPI_C_DEV_PP_OPTIONAL_STRUCTS_DEV_H_ - -#include "ppapi/c/pp_bool.h" -#include "ppapi/c/pp_macros.h" -#include "ppapi/c/pp_stdint.h" - -/** - * @file - * This file defines optional structs for primitive types. - */ - - -/** - * @addtogroup Structs - * @{ - */ -struct PP_Optional_Double_Dev { - double value; - PP_Bool is_set; -}; -/** - * @} - */ - -#endif /* PPAPI_C_DEV_PP_OPTIONAL_STRUCTS_DEV_H_ */ - diff --git a/ppapi/c/dev/ppb_alarms_dev.h b/ppapi/c/dev/ppb_alarms_dev.h deleted file mode 100644 index 9661793..0000000 --- a/ppapi/c/dev/ppb_alarms_dev.h +++ /dev/null @@ -1,210 +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. - */ - -/* From dev/ppb_alarms_dev.idl modified Tue Dec 10 17:40:20 2013. */ - -#ifndef PPAPI_C_DEV_PPB_ALARMS_DEV_H_ -#define PPAPI_C_DEV_PPB_ALARMS_DEV_H_ - -#include "ppapi/c/dev/pp_optional_structs_dev.h" -#include "ppapi/c/pp_array_output.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_stdint.h" -#include "ppapi/c/pp_var.h" - -#define PPB_ALARMS_DEV_INTERFACE_0_1 "PPB_Alarms(Dev);0.1" -#define PPB_ALARMS_DEV_INTERFACE PPB_ALARMS_DEV_INTERFACE_0_1 - -/** - * @file - * This file defines the Pepper equivalent of the <code>chrome.alarms</code> - * extension API. - */ - - -/** - * @addtogroup Structs - * @{ - */ -struct PP_Alarms_Alarm_Dev { - /** - * Name of this alarm. - */ - struct PP_Var name; - /** - * Time at which this alarm was scheduled to fire, in milliseconds past the - * epoch. For performance reasons, the alarm may have been delayed an - * arbitrary amount beyond this. - */ - double scheduled_time; - /** - * If set, the alarm is a repeating alarm and will fire again in - * <code>period_in_minutes</code> minutes. - */ - struct PP_Optional_Double_Dev period_in_minutes; -}; - -struct PP_Alarms_AlarmCreateInfo_Dev { - /** - * Time at which the alarm should fire, in milliseconds past the epoch. - */ - struct PP_Optional_Double_Dev when; - /** - * Length of time in minutes after which the - * <code>PP_Alarms_OnAlarm_Dev</code> event should fire. - */ - struct PP_Optional_Double_Dev delay_in_minutes; - /** - * If set, the <code>PP_Alarms_OnAlarm_Dev</code> event should fire every - * <code>period_in_minutes</code> minutes after the initial event specified by - * <code>when</code> or <code>delay_in_minutes</code>. If not set, the alarm - * will only fire once. - */ - struct PP_Optional_Double_Dev period_in_minutes; -}; - -struct PP_Alarms_Alarm_Array_Dev { - uint32_t size; - struct PP_Alarms_Alarm_Dev *elements; -}; -/** - * @} - */ - -/** - * @addtogroup Typedefs - * @{ - */ -/** - * Fired when an alarm has elapsed. Useful for event pages. - * - * @param[in] listener_id The listener ID. - * @param[inout] user_data The opaque pointer that was used when registering the - * listener. - * @param[in] alarm The alarm that has elapsed. - */ -typedef void (*PP_Alarms_OnAlarm_Dev)( - uint32_t listener_id, - void* user_data, - const struct PP_Alarms_Alarm_Dev* alarm); -/** - * @} - */ - -/** - * @addtogroup Interfaces - * @{ - */ -struct PPB_Alarms_Dev_0_1 { - /** - * Creates an alarm. Near the time(s) specified by <code>alarm_info</code>, - * the <code>PP_Alarms_OnAlarm_Dev</code> event is fired. If there is another - * alarm with the same name (or no name if none is specified), it will be - * cancelled and replaced by this alarm. - * - * In order to reduce the load on the user's machine, Chrome limits alarms - * to at most once every 1 minute but may delay them an arbitrary amount more. - * That is, setting - * <code>PP_Alarms_AlarmCreateInfo_Dev.delay_in_minutes</code> or - * <code>PP_Alarms_AlarmCreateInfo_Dev.period_in_minutes</code> to less than - * <code>1</code> will not be honored and will cause a warning. - * <code>PP_Alarms_AlarmCreateInfo_Dev.when</code> can be set to less than 1 - * minute after "now" without warning but won't actually cause the alarm to - * fire for at least 1 minute. - * - * To help you debug your app or extension, when you've loaded it unpacked, - * there's no limit to how often the alarm can fire. - * - * @param[in] instance A <code>PP_Instance</code>. - * @param[in] name A string or undefined <code>PP_Var</code>. Optional name to - * identify this alarm. Defaults to the empty string. - * @param[in] alarm_info Describes when the alarm should fire. The initial - * time must be specified by either <code>when</code> or - * <code>delay_in_minutes</code> (but not both). If - * <code>period_in_minutes</code> is set, the alarm will repeat every - * <code>period_in_minutes</code> minutes after the initial event. If neither - * <code>when</code> or <code>delay_in_minutes</code> is set for a repeating - * alarm, <code>period_in_minutes</code> is used as the default for - * <code>delay_in_minutes</code>. - */ - void (*Create)(PP_Instance instance, - struct PP_Var name, - const struct PP_Alarms_AlarmCreateInfo_Dev* alarm_info); - /** - * Retrieves details about the specified alarm. - * - * @param[in] instance A <code>PP_Instance</code>. - * @param[in] name A string or undefined <code>PP_Var</code>. The name of the - * alarm to get. Defaults to the empty string. - * @param[out] alarm A <code>PP_Alarms_Alarm_Dev</code> struct to store the - * output result. - * @param[in] callback A <code>PP_CompletionCallback</code> to be called upon - * completion. - * - * @return An error code from <code>pp_errors.h</code> - */ - int32_t (*Get)(PP_Instance instance, - struct PP_Var name, - struct PP_Alarms_Alarm_Dev* alarm, - struct PP_CompletionCallback callback); - /** - * Gets an array of all the alarms. - * - * @param[in] instance A <code>PP_Instance</code>. - * @param[out] alarms A <code>PP_Alarms_Alarm_Array_Dev</code> to store the - * output result. - * @param[in] array_allocator A <code>PP_ArrayOutput</code> to allocate memory - * for <code>alarms</code>. - * @param[in] callback A <code>PP_CompletionCallback</code> to be called upon - * completion. - * - * @return An error code from <code>pp_errors.h</code> - */ - int32_t (*GetAll)(PP_Instance instance, - struct PP_Alarms_Alarm_Array_Dev* alarms, - struct PP_ArrayOutput array_allocator, - struct PP_CompletionCallback callback); - /** - * Clears the alarm with the given name. - * - * @param[in] instance A <code>PP_Instance</code>. - * @param[in] name A string or undefined <code>PP_Var</code>. The name of the - * alarm to clear. Defaults to the empty string. - */ - void (*Clear)(PP_Instance instance, struct PP_Var name); - /** - * Clears all alarms. - * - * @param[in] instance A <code>PP_Instance</code>. - */ - void (*ClearAll)(PP_Instance instance); - /** - * Registers <code>PP_Alarms_OnAlarm_Dev</code> event. - * - * @param[in] instance A <code>PP_Instance</code>. - * @param[in] callback The callback to receive notifications. - * @param[inout] user_data An opaque pointer that will be passed to - * <code>callback</code>. - * - * @return A listener ID, or 0 if failed. - * - * TODO(yzshen): add a PPB_Events_Dev interface for unregistering: - * void UnregisterListener(PP_instance instance, uint32_t listener_id); - */ - uint32_t (*AddOnAlarmListener)(PP_Instance instance, - PP_Alarms_OnAlarm_Dev callback, - void* user_data); -}; - -typedef struct PPB_Alarms_Dev_0_1 PPB_Alarms_Dev; -/** - * @} - */ - -#endif /* PPAPI_C_DEV_PPB_ALARMS_DEV_H_ */ - diff --git a/ppapi/cpp/dev/alarms_dev.cc b/ppapi/cpp/dev/alarms_dev.cc deleted file mode 100644 index 1030185..0000000 --- a/ppapi/cpp/dev/alarms_dev.cc +++ /dev/null @@ -1,295 +0,0 @@ -// Copyright 2014 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/dev/alarms_dev.h" - -#include "ppapi/cpp/completion_callback.h" -#include "ppapi/cpp/dev/array_dev.h" -#include "ppapi/cpp/dev/to_c_type_converter_dev.h" -#include "ppapi/cpp/module_impl.h" - -namespace pp { - -namespace { - -template <> const char* interface_name<PPB_Alarms_Dev_0_1>() { - return PPB_ALARMS_DEV_INTERFACE_0_1; -} - -} // namespace - -namespace alarms { - -Alarm_Dev::Alarm_Dev() - : name_wrapper_(&storage_->name, NOT_OWNED), - period_in_minutes_wrapper_(&storage_->period_in_minutes, NOT_OWNED) { -} - -Alarm_Dev::Alarm_Dev(const Alarm_Dev& other) - : name_wrapper_(&storage_->name, NOT_OWNED), - period_in_minutes_wrapper_(&storage_->period_in_minutes, NOT_OWNED) { - operator=(other); -} - -Alarm_Dev::Alarm_Dev(const PP_Alarms_Alarm_Dev& other) - : name_wrapper_(&storage_->name, NOT_OWNED), - period_in_minutes_wrapper_(&storage_->period_in_minutes, NOT_OWNED) { - operator=(other); -} - -Alarm_Dev::Alarm_Dev(PP_Alarms_Alarm_Dev* storage, NotOwned) - : storage_(storage, NOT_OWNED), - name_wrapper_(&storage_->name, NOT_OWNED), - period_in_minutes_wrapper_(&storage_->period_in_minutes, NOT_OWNED) { -} - -Alarm_Dev::~Alarm_Dev() { -} - -Alarm_Dev& Alarm_Dev::operator=(const Alarm_Dev& other) { - return operator=(*other.storage_); -} - -Alarm_Dev& Alarm_Dev::operator=(const PP_Alarms_Alarm_Dev& other) { - if (storage_.get() == &other) - return *this; - - name_wrapper_ = other.name; - storage_->scheduled_time = other.scheduled_time; - period_in_minutes_wrapper_ = other.period_in_minutes; - - return *this; -} - -std::string Alarm_Dev::name() const { - return name_wrapper_.get(); -} - -void Alarm_Dev::set_name(const std::string& value) { - name_wrapper_.set(value); -} - -double Alarm_Dev::scheduled_time() const { - return storage_->scheduled_time; -} - -void Alarm_Dev::set_scheduled_time(double value) { - storage_->scheduled_time = value; -} - -bool Alarm_Dev::is_period_in_minutes_set() const { - return period_in_minutes_wrapper_.is_set(); -} - -void Alarm_Dev::unset_period_in_minutes() { - period_in_minutes_wrapper_.unset(); -} - -double Alarm_Dev::period_in_minutes() const { - return period_in_minutes_wrapper_.get(); -} - -void Alarm_Dev::set_period_in_minutes(double value) { - period_in_minutes_wrapper_.set(value); -} - -const PP_Alarms_Alarm_Dev* Alarm_Dev::ToStruct() const { - return storage_.get(); -} - -PP_Alarms_Alarm_Dev* Alarm_Dev::StartRawUpdate() { - name_wrapper_.StartRawUpdate(); - period_in_minutes_wrapper_.StartRawUpdate(); - - return storage_.get(); -} - -void Alarm_Dev::EndRawUpdate() { - name_wrapper_.EndRawUpdate(); - period_in_minutes_wrapper_.EndRawUpdate(); -} - -AlarmCreateInfo_Dev::AlarmCreateInfo_Dev() - : when_wrapper_(&storage_->when, NOT_OWNED), - delay_in_minutes_wrapper_(&storage_->delay_in_minutes, NOT_OWNED), - period_in_minutes_wrapper_(&storage_->period_in_minutes, NOT_OWNED) { -} - -AlarmCreateInfo_Dev::AlarmCreateInfo_Dev(const AlarmCreateInfo_Dev& other) - : when_wrapper_(&storage_->when, NOT_OWNED), - delay_in_minutes_wrapper_(&storage_->delay_in_minutes, NOT_OWNED), - period_in_minutes_wrapper_(&storage_->period_in_minutes, NOT_OWNED) { - operator=(other); -} - -AlarmCreateInfo_Dev::AlarmCreateInfo_Dev( - const PP_Alarms_AlarmCreateInfo_Dev& other) - : when_wrapper_(&storage_->when, NOT_OWNED), - delay_in_minutes_wrapper_(&storage_->delay_in_minutes, NOT_OWNED), - period_in_minutes_wrapper_(&storage_->period_in_minutes, NOT_OWNED) { - operator=(other); -} - -AlarmCreateInfo_Dev::AlarmCreateInfo_Dev( - PP_Alarms_AlarmCreateInfo_Dev* storage, - NotOwned) - : storage_(storage, NOT_OWNED), - when_wrapper_(&storage_->when, NOT_OWNED), - delay_in_minutes_wrapper_(&storage_->delay_in_minutes, NOT_OWNED), - period_in_minutes_wrapper_(&storage_->period_in_minutes, NOT_OWNED) { -} - -AlarmCreateInfo_Dev::~AlarmCreateInfo_Dev() { -} - -AlarmCreateInfo_Dev& AlarmCreateInfo_Dev::operator=( - const AlarmCreateInfo_Dev& other) { - return operator=(*other.storage_); -} - -AlarmCreateInfo_Dev& AlarmCreateInfo_Dev::operator=( - const PP_Alarms_AlarmCreateInfo_Dev& other) { - if (storage_.get() == &other) - return *this; - - when_wrapper_ = other.when; - delay_in_minutes_wrapper_ = other.delay_in_minutes; - period_in_minutes_wrapper_ = other.period_in_minutes; - - return *this; -} - -bool AlarmCreateInfo_Dev::is_when_set() const { - return when_wrapper_.is_set(); -} - -void AlarmCreateInfo_Dev::unset_when() { - when_wrapper_.unset(); -} - -double AlarmCreateInfo_Dev::when() const { - return when_wrapper_.get(); -} - -void AlarmCreateInfo_Dev::set_when(double value) { - when_wrapper_.set(value); -} - -bool AlarmCreateInfo_Dev::is_delay_in_minutes_set() const { - return delay_in_minutes_wrapper_.is_set(); -} - -void AlarmCreateInfo_Dev::unset_delay_in_minutes() { - delay_in_minutes_wrapper_.unset(); -} - -double AlarmCreateInfo_Dev::delay_in_minutes() const { - return delay_in_minutes_wrapper_.get(); -} - -void AlarmCreateInfo_Dev::set_delay_in_minutes(double value) { - delay_in_minutes_wrapper_.set(value); -} - -bool AlarmCreateInfo_Dev::is_period_in_minutes_set() const { - return period_in_minutes_wrapper_.is_set(); -} - -void AlarmCreateInfo_Dev::unset_period_in_minutes() { - period_in_minutes_wrapper_.unset(); -} - -double AlarmCreateInfo_Dev::period_in_minutes() const { - return period_in_minutes_wrapper_.get(); -} - -void AlarmCreateInfo_Dev::set_period_in_minutes(double value) { - period_in_minutes_wrapper_.set(value); -} - -const PP_Alarms_AlarmCreateInfo_Dev* AlarmCreateInfo_Dev::ToStruct() const { - return storage_.get(); -} - -PP_Alarms_AlarmCreateInfo_Dev* AlarmCreateInfo_Dev::StartRawUpdate() { - when_wrapper_.StartRawUpdate(); - delay_in_minutes_wrapper_.StartRawUpdate(); - period_in_minutes_wrapper_.StartRawUpdate(); - - return storage_.get(); -} - -void AlarmCreateInfo_Dev::EndRawUpdate() { - when_wrapper_.EndRawUpdate(); - delay_in_minutes_wrapper_.EndRawUpdate(); - period_in_minutes_wrapper_.EndRawUpdate(); -} - -Alarms_Dev::Alarms_Dev(const InstanceHandle& instance) : instance_(instance) { -} - -Alarms_Dev::~Alarms_Dev() { -} - -void Alarms_Dev::Create(const Optional<std::string>& name, - const AlarmCreateInfo_Dev& alarm_info) { - if (!has_interface<PPB_Alarms_Dev_0_1>()) - return; - - internal::ToCTypeConverter<Optional<std::string> > name_converter(name); - internal::ToCTypeConverter<AlarmCreateInfo_Dev> alarm_info_converter( - alarm_info); - - return get_interface<PPB_Alarms_Dev_0_1>()->Create( - instance_.pp_instance(), - name_converter.ToCInput(), - alarm_info_converter.ToCInput()); -} - -int32_t Alarms_Dev::Get(const Optional<std::string>& name, - const GetCallback& callback) { - if (!has_interface<PPB_Alarms_Dev_0_1>()) - return callback.MayForce(PP_ERROR_NOINTERFACE); - - internal::ToCTypeConverter<Optional<std::string> > name_converter(name); - - return get_interface<PPB_Alarms_Dev_0_1>()->Get( - instance_.pp_instance(), - name_converter.ToCInput(), - callback.output(), - callback.pp_completion_callback()); -} - -int32_t Alarms_Dev::GetAll(const GetAllCallback& callback) { - if (!has_interface<PPB_Alarms_Dev_0_1>()) - return callback.MayForce(PP_ERROR_NOINTERFACE); - - return get_interface<PPB_Alarms_Dev_0_1>()->GetAll( - instance_.pp_instance(), - callback.output(), - internal::ArrayAllocator::Get(), - callback.pp_completion_callback()); -} - -void Alarms_Dev::Clear(const Optional<std::string>& name) { - if (!has_interface<PPB_Alarms_Dev_0_1>()) - return; - - internal::ToCTypeConverter<Optional<std::string> > name_converter(name); - - return get_interface<PPB_Alarms_Dev_0_1>()->Clear( - instance_.pp_instance(), - name_converter.ToCInput()); -} - -void Alarms_Dev::ClearAll() { - if (!has_interface<PPB_Alarms_Dev_0_1>()) - return; - - return get_interface<PPB_Alarms_Dev_0_1>()->ClearAll( - instance_.pp_instance()); -} - -} // namespace alarms -} // namespace pp diff --git a/ppapi/cpp/dev/alarms_dev.h b/ppapi/cpp/dev/alarms_dev.h deleted file mode 100644 index fe966e8..0000000 --- a/ppapi/cpp/dev/alarms_dev.h +++ /dev/null @@ -1,170 +0,0 @@ -// Copyright 2014 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_DEV_ALARMS_DEV_H_ -#define PPAPI_CPP_DEV_ALARMS_DEV_H_ - -#include <string> - -#include "ppapi/c/dev/ppb_alarms_dev.h" -#include "ppapi/cpp/dev/may_own_ptr_dev.h" -#include "ppapi/cpp/dev/optional_dev.h" -#include "ppapi/cpp/dev/string_wrapper_dev.h" -#include "ppapi/cpp/dev/struct_wrapper_output_traits_dev.h" -#include "ppapi/cpp/instance_handle.h" -#include "ppapi/cpp/output_traits.h" - -namespace pp { - -template <typename T> -class CompletionCallbackWithOutput; - -template <typename T> -class Array; - -namespace alarms { - -// Data types ------------------------------------------------------------------ -class Alarm_Dev { - public: - typedef PP_Alarms_Alarm_Dev CType; - typedef PP_Alarms_Alarm_Array_Dev CArrayType; - - Alarm_Dev(); - - Alarm_Dev(const Alarm_Dev& other); - - explicit Alarm_Dev(const PP_Alarms_Alarm_Dev& other); - - // Creates an accessor to |storage| but doesn't take ownership of the memory. - // |storage| must live longer than this object. The contents pointed to by - // |storage| is managed by this object. - // Used by Pepper internal implementation. - Alarm_Dev(PP_Alarms_Alarm_Dev* storage, NotOwned); - - ~Alarm_Dev(); - - Alarm_Dev& operator=(const Alarm_Dev& other); - Alarm_Dev& operator=(const PP_Alarms_Alarm_Dev& other); - - std::string name() const; - void set_name(const std::string& value); - - double scheduled_time() const; - void set_scheduled_time(double value); - - bool is_period_in_minutes_set() const; - void unset_period_in_minutes(); - double period_in_minutes() const; - void set_period_in_minutes(double value); - - const PP_Alarms_Alarm_Dev* ToStruct() const; - - // The returned pointer is still owned by this object. And after it is used, - // EndRawUpdate() must be called. - PP_Alarms_Alarm_Dev* StartRawUpdate(); - void EndRawUpdate(); - - private: - internal::MayOwnPtr<PP_Alarms_Alarm_Dev> storage_; - - internal::StringWrapper name_wrapper_; - Optional<double> period_in_minutes_wrapper_; -}; - -class AlarmCreateInfo_Dev { - public: - typedef PP_Alarms_AlarmCreateInfo_Dev CType; - - AlarmCreateInfo_Dev(); - - AlarmCreateInfo_Dev(const AlarmCreateInfo_Dev& other); - - explicit AlarmCreateInfo_Dev(const PP_Alarms_AlarmCreateInfo_Dev& other); - - // Creates an accessor to |storage| but doesn't take ownership of the memory. - // |storage| must live longer than this object. The contents pointed to by - // |storage| is managed by this object. - // Used by Pepper internal implementation. - AlarmCreateInfo_Dev(PP_Alarms_AlarmCreateInfo_Dev* storage, NotOwned); - - ~AlarmCreateInfo_Dev(); - - AlarmCreateInfo_Dev& operator=(const AlarmCreateInfo_Dev& other); - AlarmCreateInfo_Dev& operator=(const PP_Alarms_AlarmCreateInfo_Dev& other); - - bool is_when_set() const; - void unset_when(); - double when() const; - void set_when(double value); - - bool is_delay_in_minutes_set() const; - void unset_delay_in_minutes(); - double delay_in_minutes() const; - void set_delay_in_minutes(double value); - - bool is_period_in_minutes_set() const; - void unset_period_in_minutes(); - double period_in_minutes() const; - void set_period_in_minutes(double value); - - const PP_Alarms_AlarmCreateInfo_Dev* ToStruct() const; - - // The returned pointer is still owned by this object. And after it is used, - // EndRawUpdate() must be called. - PP_Alarms_AlarmCreateInfo_Dev* StartRawUpdate(); - void EndRawUpdate(); - - private: - internal::MayOwnPtr<PP_Alarms_AlarmCreateInfo_Dev> storage_; - - Optional<double> when_wrapper_; - Optional<double> delay_in_minutes_wrapper_; - Optional<double> period_in_minutes_wrapper_; -}; - -// Functions ------------------------------------------------------------------- -class Alarms_Dev { - public: - explicit Alarms_Dev(const InstanceHandle& instance); - ~Alarms_Dev(); - - void Create(const Optional<std::string>& name, - const AlarmCreateInfo_Dev& alarm_info); - - typedef CompletionCallbackWithOutput<Alarm_Dev> GetCallback; - int32_t Get(const Optional<std::string>& name, const GetCallback& callback); - - typedef CompletionCallbackWithOutput<Array<Alarm_Dev> > GetAllCallback; - int32_t GetAll(const GetAllCallback& callback); - - void Clear(const Optional<std::string>& name); - - void ClearAll(); - - private: - InstanceHandle instance_; -}; - -// Events ---------------------------------------------------------------------- -// TODO(yzshen): add onAlarm event. - -} // namespace alarms - -namespace internal { - -template <> -struct CallbackOutputTraits<alarms::Alarm_Dev> - : public internal::StructWrapperOutputTraits<alarms::Alarm_Dev> { -}; - -template <> -struct CallbackOutputTraits<alarms::AlarmCreateInfo_Dev> - : public internal::StructWrapperOutputTraits<alarms::AlarmCreateInfo_Dev> { -}; - -} // namespace internal -} // namespace pp - -#endif // PPAPI_CPP_DEV_ALARMS_DEV_H_ diff --git a/ppapi/cpp/dev/array_dev.h b/ppapi/cpp/dev/array_dev.h deleted file mode 100644 index 5d08190..0000000 --- a/ppapi/cpp/dev/array_dev.h +++ /dev/null @@ -1,196 +0,0 @@ -// Copyright 2014 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_DEV_ARRAY_DEV_H_ -#define PPAPI_CPP_DEV_ARRAY_DEV_H_ - -#include <cstdlib> - -#include <vector> - -#include "ppapi/cpp/dev/may_own_ptr_dev.h" -#include "ppapi/cpp/logging.h" -#include "ppapi/cpp/output_traits.h" - -namespace pp { - -template <typename T> -class Array; - -namespace internal { - -class ArrayAllocator { - public: - // Allocates memory and zero-fills it. - static void* Alloc(uint32_t count, uint32_t size) { - if (count == 0 || size == 0) - return NULL; - - return calloc(count, size); - } - - static void Free(void* mem) { free(mem); } - - static PP_ArrayOutput Get() { - PP_ArrayOutput array_output = { &ArrayAllocator::GetDataBuffer, NULL }; - return array_output; - } - - private: - static void* GetDataBuffer(void* /* user_data */, - uint32_t element_count, - uint32_t element_size) { - return Alloc(element_count, element_size); - } -}; - -// A specialization of CallbackOutputTraits for pp::Array parameters. -template <typename T> -struct CallbackOutputTraits<Array<T> > { - typedef typename Array<T>::CArrayType* APIArgType; - typedef Array<T> StorageType; - - // Returns the underlying C struct of |t|, which can be passed to the browser - // as an output parameter. - static inline APIArgType StorageToAPIArg(StorageType& t) { - return t.StartRawUpdate(); - } - - // For each |t| passed into StorageToAPIArg(), this method must be called - // exactly once in order to match StartRawUpdate() and EndRawUpdate(). - static inline Array<T>& StorageToPluginArg(StorageType& t) { - t.EndRawUpdate(); - return t; - } - - static inline void Initialize(StorageType* /* t */) {} -}; - -} // namespace internal - -// Generic array for struct wrappers. -template <class T> -class Array { - public: - typedef typename T::CArrayType CArrayType; - typedef typename T::CType CType; - - Array() {} - - explicit Array(uint32_t size) { Reset(size); } - - // Creates an accessor to |storage| but doesn't take ownership of the memory. - // |storage| must live longer than this object. - // - // Although this object doesn't own the memory of |storage|, it manages the - // memory pointed to by |storage->elements| and resets |storage| to empty when - // destructed. - Array(CArrayType* storage, NotOwned) : storage_(storage, NOT_OWNED) { - CreateWrappers(); - } - - Array(const Array<T>& other) { DeepCopy(*other.storage_); } - - ~Array() { Reset(0); } - - Array<T>& operator=(const Array<T>& other) { - return operator=(*other.storage_); - } - - Array<T>& operator=(const CArrayType& other) { - if (storage_.get() == &other) - return *this; - - Reset(0); - DeepCopy(other); - - return *this; - } - - uint32_t size() const { return storage_->size; } - - T& operator[](uint32_t index) { - PP_DCHECK(storage_->size == wrappers_.size()); - PP_DCHECK(index < storage_->size); - PP_DCHECK(wrappers_[index]->ToStruct() == storage_->elements + index); - return *wrappers_[index]; - } - - const T& operator[](uint32_t index) const { - PP_DCHECK(storage_->size == wrappers_.size()); - PP_DCHECK(index < storage_->size); - PP_DCHECK(wrappers_[index]->ToStruct() == storage_->elements + index); - return *wrappers_[index]; - } - - // Clears the existing contents of the array, and resets it to |size| elements - // of default value. - void Reset(uint32_t size) { - // Wrappers must be destroyed before we free |storage_->elements|, because - // they may try to access the memory in their destructors. - DeleteWrappers(); - - internal::ArrayAllocator::Free(storage_->elements); - storage_->elements = NULL; - - storage_->size = size; - if (size > 0) { - storage_->elements = static_cast<CType*>( - internal::ArrayAllocator::Alloc(size, sizeof(CType))); - } - - CreateWrappers(); - } - - // Sets the underlying C array struct to empty before returning it. - CArrayType* StartRawUpdate() { - Reset(0); - return storage_.get(); - } - - void EndRawUpdate() { CreateWrappers(); } - - private: - void DeepCopy(const CArrayType& other) { - storage_->size = other.size; - - if (storage_->size > 0) { - storage_->elements = static_cast<CType*>( - internal::ArrayAllocator::Alloc(storage_->size, sizeof(CType))); - } - - CreateWrappers(); - - for (size_t i = 0; i < storage_->size; ++i) - wrappers_[i] = other.elements[i]; - } - - void DeleteWrappers() { - for (typename std::vector<T*>::iterator iter = wrappers_.begin(); - iter != wrappers_.end(); - ++iter) { - delete *iter; - } - wrappers_.clear(); - } - - void CreateWrappers() { - PP_DCHECK(wrappers_.empty()); - - uint32_t size = storage_->size; - if (size == 0) - return; - - wrappers_.reserve(size); - for (size_t i = 0; i < size; ++i) - wrappers_.push_back(new T(&storage_->elements[i], NOT_OWNED)); - } - - internal::MayOwnPtr<CArrayType> storage_; - std::vector<T*> wrappers_; -}; - -} // namespace pp - -#endif // PPAPI_CPP_DEV_ARRAY_DEV_H_ diff --git a/ppapi/cpp/dev/may_own_ptr_dev.h b/ppapi/cpp/dev/may_own_ptr_dev.h deleted file mode 100644 index f31d59d..0000000 --- a/ppapi/cpp/dev/may_own_ptr_dev.h +++ /dev/null @@ -1,61 +0,0 @@ -// Copyright 2014 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_DEV_MAY_OWN_PTR_DEV_H_ -#define PPAPI_CPP_DEV_MAY_OWN_PTR_DEV_H_ - -#include "ppapi/cpp/logging.h" - -namespace pp { - -// An annotation used along with a pointer parameter of a function to indicate -// that the function doesn't take ownership of the pointer. -enum NotOwned { - NOT_OWNED -}; - -namespace internal { - -// MayOwnPtr keeps track of whether it has ownership of the pointer it holds, -// and deletes the pointer on destruction if it does. -template <typename T> -class MayOwnPtr { - public: - // Creates and owns a T instance. - // NOTE: "()" after T is important to do zero-initialization for POD types. - MayOwnPtr() : value_(new T()), owned_(true) {} - - // It doesn't take ownership of |value|, therefore |value| must live longer - // than this object. - MayOwnPtr(T* value, NotOwned) : value_(value), owned_(false) { - PP_DCHECK(value); - } - - ~MayOwnPtr() { - if (owned_) - delete value_; - } - - const T* get() const { return value_; } - T* get() { return value_; } - - const T& operator*() const { return *value_; } - T& operator*() { return *value_; } - - const T* operator->() const { return value_; } - T* operator->() { return value_; } - - private: - // Disallow copying and assignment. - MayOwnPtr(const MayOwnPtr<T>&); - MayOwnPtr<T>& operator=(const MayOwnPtr<T>&); - - T* value_; - bool owned_; -}; - -} // namespace internal -} // namespace pp - -#endif // PPAPI_CPP_DEV_MAY_OWN_PTR_DEV_H_ diff --git a/ppapi/cpp/dev/optional_dev.h b/ppapi/cpp/dev/optional_dev.h deleted file mode 100644 index caf364d..0000000 --- a/ppapi/cpp/dev/optional_dev.h +++ /dev/null @@ -1,117 +0,0 @@ -// Copyright 2014 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_DEV_OPTIONAL_DEV_H_ -#define PPAPI_CPP_DEV_OPTIONAL_DEV_H_ - -#include "ppapi/c/dev/pp_optional_structs_dev.h" -#include "ppapi/c/pp_bool.h" -#include "ppapi/cpp/dev/may_own_ptr_dev.h" -#include "ppapi/cpp/dev/string_wrapper_dev.h" -#include "ppapi/cpp/logging.h" -#include "ppapi/cpp/var.h" - -namespace pp { - -template <typename T> -class Optional; - -template <> -class Optional<double> { - public: - typedef const PP_Optional_Double_Dev* CInputType; - - Optional() {} - - Optional(double value) { set(value); } - - // Creates an accessor to |storage| but doesn't take ownership of the memory. - // |storage| must live longer than this object. - Optional(PP_Optional_Double_Dev* storage, NotOwned) - : storage_(storage, NOT_OWNED) { - } - - Optional(const Optional<double>& other) { *storage_ = *other.storage_; } - - Optional<double>& operator=(const Optional<double>& other) { - return operator=(*other.storage_); - } - - Optional<double>& operator=(const PP_Optional_Double_Dev& other) { - if (storage_.get() == &other) - return *this; - - *storage_ = other; - return *this; - } - - bool is_set() const { return PP_ToBool(storage_->is_set); } - void unset() { storage_->is_set = PP_FALSE; } - - double get() const { - PP_DCHECK(is_set()); - return storage_->value; - } - - void set(double value) { - storage_->value = value; - storage_->is_set = PP_TRUE; - } - - const PP_Optional_Double_Dev* ToCInput() const { return storage_.get(); } - - PP_Optional_Double_Dev* StartRawUpdate() { return storage_.get(); } - void EndRawUpdate() {} - - private: - internal::MayOwnPtr<PP_Optional_Double_Dev> storage_; -}; - -template <> -class Optional<std::string> { - public: - typedef const PP_Var& CInputType; - - Optional() {} - - Optional(const std::string& value) : wrapper_(value) {} - - Optional(const char* value) : wrapper_(value) {} - - // Creates an accessor to |storage| but doesn't take ownership of the memory. - // |storage| must live longer than this object. - // - // Although this object doesn't own the memory of |storage|, it manages the - // ref count and sets the var to undefined when destructed. - Optional(PP_Var* storage, NotOwned) : wrapper_(storage, NOT_OWNED) {} - - Optional(const Optional<std::string>& other) : wrapper_(other.wrapper_) {} - - Optional<std::string>& operator=(const Optional<std::string>& other) { - wrapper_ = other.wrapper_; - return *this; - } - - Optional<std::string>& operator=(const PP_Var& other) { - wrapper_ = other; - return *this; - } - - bool is_set() const { return wrapper_.is_set(); } - void unset() { wrapper_.unset(); } - std::string get() const { return wrapper_.get(); } - void set(const std::string& value) { wrapper_.set(value); } - - const PP_Var& ToCInput() const { return wrapper_.ToVar(); } - - PP_Var* StartRawUpdate() { return wrapper_.StartRawUpdate(); } - void EndRawUpdate() { wrapper_.EndRawUpdate(); } - - private: - internal::OptionalStringWrapper wrapper_; -}; - -} // namespace pp - -#endif // PPAPI_CPP_DEV_OPTIONAL_DEV_H_ diff --git a/ppapi/cpp/dev/string_wrapper_dev.cc b/ppapi/cpp/dev/string_wrapper_dev.cc deleted file mode 100644 index 7f0976c..0000000 --- a/ppapi/cpp/dev/string_wrapper_dev.cc +++ /dev/null @@ -1,129 +0,0 @@ -// Copyright 2014 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/dev/string_wrapper_dev.h" - -#include "ppapi/cpp/logging.h" -#include "ppapi/cpp/var.h" - -namespace pp { -namespace internal { - -OptionalStringWrapper::OptionalStringWrapper() { -} - -OptionalStringWrapper::OptionalStringWrapper(const std::string& value) { - *storage_ = Var(value).Detach(); -} - -OptionalStringWrapper::OptionalStringWrapper(PP_Var* storage, NotOwned) - : storage_(storage, NOT_OWNED) { - PP_DCHECK(storage_->type == PP_VARTYPE_STRING || - storage_->type == PP_VARTYPE_UNDEFINED); -} - -OptionalStringWrapper::OptionalStringWrapper( - const OptionalStringWrapper& other) { - // Add one ref. - *storage_ = Var(*other.storage_).Detach(); -} - -OptionalStringWrapper::~OptionalStringWrapper() { - unset(); -} - -OptionalStringWrapper& OptionalStringWrapper::operator=( - const OptionalStringWrapper& other) { - return operator=(*other.storage_); -} - -OptionalStringWrapper& OptionalStringWrapper::operator=(const PP_Var& other) { - if (storage_.get() == &other) - return *this; - - Var auto_release(PASS_REF, *storage_); - // Add one ref. - *storage_ = Var(other).Detach(); - return *this; -} - -bool OptionalStringWrapper::is_set() const { - PP_DCHECK(storage_->type == PP_VARTYPE_STRING || - storage_->type == PP_VARTYPE_UNDEFINED); - return storage_->type == PP_VARTYPE_STRING; -} - -void OptionalStringWrapper::unset() { - Var auto_release(PASS_REF, *storage_); - *storage_ = PP_MakeUndefined(); -} - -std::string OptionalStringWrapper::get() const { - // TODO(yzshen): consider adding a cache. - Var var(*storage_); - if (var.is_string()) { - return var.AsString(); - } else { - PP_NOTREACHED(); - return std::string(); - } -} - -void OptionalStringWrapper::set(const std::string& value) { - Var auto_release(PASS_REF, *storage_); - *storage_ = Var(value).Detach(); -} - -PP_Var* OptionalStringWrapper::StartRawUpdate() { - unset(); - return storage_.get(); -} - -void OptionalStringWrapper::EndRawUpdate() { - PP_DCHECK(storage_->type == PP_VARTYPE_STRING || - storage_->type == PP_VARTYPE_UNDEFINED); -} - -StringWrapper::StringWrapper() : storage_(std::string()) { -} - -StringWrapper::StringWrapper(const std::string& value) : storage_(value) { -} - -StringWrapper::StringWrapper(PP_Var* storage, NotOwned) - : storage_(storage, NOT_OWNED) { - if (!storage_.is_set()) - storage_.set(std::string()); -} - -StringWrapper::StringWrapper(const StringWrapper& other) - : storage_(other.storage_) { -} - -StringWrapper::~StringWrapper() { -} - -StringWrapper& StringWrapper::operator=(const StringWrapper& other) { - storage_ = other.storage_; - return *this; -} - -StringWrapper& StringWrapper::operator=(const PP_Var& other) { - PP_DCHECK(other.type == PP_VARTYPE_STRING); - storage_ = other; - return *this; -} - -PP_Var* StringWrapper::StartRawUpdate() { - return storage_.StartRawUpdate(); -} - -void StringWrapper::EndRawUpdate() { - storage_.EndRawUpdate(); - if (!storage_.is_set()) - storage_.set(std::string()); -} - -} // namespace internal -} // namespace pp diff --git a/ppapi/cpp/dev/string_wrapper_dev.h b/ppapi/cpp/dev/string_wrapper_dev.h deleted file mode 100644 index 5ac946d..0000000 --- a/ppapi/cpp/dev/string_wrapper_dev.h +++ /dev/null @@ -1,93 +0,0 @@ -// Copyright 2014 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_DEV_STRING_WRAPPER_DEV_H_ -#define PPAPI_CPP_DEV_STRING_WRAPPER_DEV_H_ - -#include <string> - -#include "ppapi/c/pp_var.h" -#include "ppapi/cpp/dev/may_own_ptr_dev.h" - -namespace pp { -namespace internal { - -// An optional string backed by a PP_Var. When the string is not set, the type -// of the PP_Var is set to PP_VARTYPE_UNDEFINED; otherwise, it is set to -// PP_VARTYPE_STRING. -class OptionalStringWrapper { - public: - OptionalStringWrapper(); - - explicit OptionalStringWrapper(const std::string& value); - - // Creates an accessor to |storage| but doesn't take ownership of the memory. - // |storage| must live longer than this object. - // - // Although this object doesn't own the memory of |storage|, it manages the - // ref count and sets the var to undefined when destructed. - OptionalStringWrapper(PP_Var* storage, NotOwned); - - OptionalStringWrapper(const OptionalStringWrapper& other); - - ~OptionalStringWrapper(); - - OptionalStringWrapper& operator=(const OptionalStringWrapper& other); - OptionalStringWrapper& operator=(const PP_Var& other); - - bool is_set() const; - void unset(); - std::string get() const; - void set(const std::string& value); - - const PP_Var& ToVar() const { return *storage_; } - - // Sets the underlying PP_Var to undefined before returning it. - PP_Var* StartRawUpdate(); - void EndRawUpdate(); - - private: - MayOwnPtr<PP_Var> storage_; -}; - -// A string backed by a PP_Var whose type is PP_VARTYPE_STRING. -class StringWrapper { - public: - StringWrapper(); - - explicit StringWrapper(const std::string& value); - - // Creates an accessor to |storage| but doesn't take ownership of the memory. - // |storage| must live longer than this object. - // - // Although this object doesn't own the memory of |storage|, it manages the - // ref count and sets the var to undefined when destructed. - StringWrapper(PP_Var* storage, NotOwned); - - StringWrapper(const StringWrapper& other); - - ~StringWrapper(); - - StringWrapper& operator=(const StringWrapper& other); - StringWrapper& operator=(const PP_Var& other); - - std::string get() const { return storage_.get(); } - void set(const std::string& value) { return storage_.set(value); } - - const PP_Var& ToVar() const { return storage_.ToVar(); } - - // Sets the underlying PP_Var to undefined before returning it. - PP_Var* StartRawUpdate(); - // If the underlying PP_Var wasn't updated to a valid string, sets it to an - // empty string. - void EndRawUpdate(); - - private: - OptionalStringWrapper storage_; -}; - -} // namespace internal -} // namespace pp - -#endif // PPAPI_CPP_DEV_STRING_WRAPPER_DEV_H_ diff --git a/ppapi/cpp/dev/struct_wrapper_output_traits_dev.h b/ppapi/cpp/dev/struct_wrapper_output_traits_dev.h deleted file mode 100644 index 0c0762e..0000000 --- a/ppapi/cpp/dev/struct_wrapper_output_traits_dev.h +++ /dev/null @@ -1,37 +0,0 @@ -// Copyright 2014 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_DEV_STRUCT_WRAPPER_OUTPUT_TRAITS_DEV_ -#define PPAPI_CPP_DEV_STRUCT_WRAPPER_OUTPUT_TRAITS_DEV_ - -namespace pp { -namespace internal { - -// This class is used as the base class for CallbackOutputTraits specialized for -// C struct wrappers. -template <typename T> -struct StructWrapperOutputTraits { - typedef typename T::CType* APIArgType; - typedef T StorageType; - - // Returns the underlying C struct of |t|, which can be passed to the browser - // as an output parameter. - static inline APIArgType StorageToAPIArg(StorageType& t) { - return t.StartRawUpdate(); - } - - // For each |t| passed into StorageToAPIArg(), this method must be called - // exactly once in order to match StartRawUpdate() and EndRawUpdate(). - static inline T& StorageToPluginArg(StorageType& t) { - t.EndRawUpdate(); - return t; - } - - static inline void Initialize(StorageType* /* t */) {} -}; - -} // namespace internal -} // namespace pp - -#endif // PPAPI_CPP_DEV_STRUCT_WRAPPER_OUTPUT_TRAITS_DEV_ diff --git a/ppapi/cpp/dev/to_c_type_converter_dev.h b/ppapi/cpp/dev/to_c_type_converter_dev.h deleted file mode 100644 index ffe5ddf..0000000 --- a/ppapi/cpp/dev/to_c_type_converter_dev.h +++ /dev/null @@ -1,96 +0,0 @@ -// Copyright 2014 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_DEV_TO_C_TYPE_CONVERTER_DEV_H_ -#define PPAPI_CPP_DEV_TO_C_TYPE_CONVERTER_DEV_H_ - -#include <string> - -#include "ppapi/c/pp_var.h" -#include "ppapi/cpp/dev/optional_dev.h" -#include "ppapi/cpp/dev/string_wrapper_dev.h" - -namespace pp { -namespace internal { - -// ToCTypeConverter is used to convert C++ API input parameters into C API input -// parameters. - -// Generic converter for C struct wrappers. -template <typename T> -class ToCTypeConverter { - public: - explicit ToCTypeConverter(const T& object) : wrapper_(object) {} - - ~ToCTypeConverter() {} - - const typename T::CType* ToCInput() const { return wrapper_.ToStruct(); } - - private: - // Disallow copying and assignment. - ToCTypeConverter(const ToCTypeConverter<T>&); - ToCTypeConverter<T>& operator=(const ToCTypeConverter<T>&); - - const T& wrapper_; -}; - -template <> -class ToCTypeConverter<std::string> { - public: - explicit ToCTypeConverter(const std::string& object) : wrapper_(object) {} - - ~ToCTypeConverter() {} - - const PP_Var& ToCInput() const { return wrapper_.ToVar(); } - - private: - // Disallow copying and assignment. - ToCTypeConverter(const ToCTypeConverter<std::string>&); - ToCTypeConverter<std::string>& operator=( - const ToCTypeConverter<std::string>&); - - StringWrapper wrapper_; -}; - -template <> -class ToCTypeConverter<double> { - public: - explicit ToCTypeConverter(double object) : storage_(object) {} - - ~ToCTypeConverter() {} - - double ToCInput() const { return storage_; } - - private: - // Disallow copying and assignment. - ToCTypeConverter(const ToCTypeConverter<double>&); - ToCTypeConverter<double>& operator=(const ToCTypeConverter<double>&); - - double storage_; -}; - -template <typename T> -class ToCTypeConverter<Optional<T> > { - public: - explicit ToCTypeConverter(const Optional<T>& object) : wrapper_(object) {} - - ~ToCTypeConverter() {} - - typename Optional<T>::CInputType ToCInput() const { - return wrapper_.ToCInput(); - } - - private: - // Disallow copying and assignment. - ToCTypeConverter(const ToCTypeConverter<Optional<T> >&); - ToCTypeConverter<Optional<T> >& operator=( - const ToCTypeConverter<Optional<T> >&); - - const Optional<T>& wrapper_; -}; - -} // namespace internal -} // namespace pp - -#endif // PPAPI_CPP_DEV_TO_C_TYPE_CONVERTER_DEV_H_ 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 b632db2..d1a2c57 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 @@ -7,7 +7,6 @@ #include "ppapi/native_client/src/untrusted/pnacl_irt_shim/pnacl_shim.h" #include "ppapi/c/ppb.h" -#include "ppapi/c/dev/ppb_alarms_dev.h" #include "ppapi/c/dev/ppb_audio_input_dev.h" #include "ppapi/c/dev/ppb_device_ref_dev.h" #include "ppapi/c/dev/ppb_file_chooser_dev.h" @@ -145,7 +144,6 @@ static struct __PnaclWrapperInfo Pnacl_WrapperInfo_PPB_VarDictionary_1_0; static struct __PnaclWrapperInfo Pnacl_WrapperInfo_PPB_VideoDecoder_0_1; static struct __PnaclWrapperInfo Pnacl_WrapperInfo_PPB_WebSocket_1_0; static struct __PnaclWrapperInfo Pnacl_WrapperInfo_PPP_Messaging_1_0; -static struct __PnaclWrapperInfo Pnacl_WrapperInfo_PPB_Alarms_Dev_0_1; static struct __PnaclWrapperInfo Pnacl_WrapperInfo_PPB_AudioInput_Dev_0_3; static struct __PnaclWrapperInfo Pnacl_WrapperInfo_PPB_AudioInput_Dev_0_4; static struct __PnaclWrapperInfo Pnacl_WrapperInfo_PPB_DeviceRef_Dev_0_1; @@ -2032,40 +2030,6 @@ static void Pnacl_M14_PPP_Messaging_HandleMessage(PP_Instance instance, struct P /* Not generating wrapper methods for PPB_URLLoaderTrusted_0_3 */ -/* Begin wrapper methods for PPB_Alarms_Dev_0_1 */ - -static void Pnacl_M33_PPB_Alarms_Dev_Create(PP_Instance instance, struct PP_Var* name, const struct PP_Alarms_AlarmCreateInfo_Dev* alarm_info) { - const struct PPB_Alarms_Dev_0_1 *iface = Pnacl_WrapperInfo_PPB_Alarms_Dev_0_1.real_iface; - iface->Create(instance, *name, alarm_info); -} - -static int32_t Pnacl_M33_PPB_Alarms_Dev_Get(PP_Instance instance, struct PP_Var* name, struct PP_Alarms_Alarm_Dev* alarm, struct PP_CompletionCallback* callback) { - const struct PPB_Alarms_Dev_0_1 *iface = Pnacl_WrapperInfo_PPB_Alarms_Dev_0_1.real_iface; - return iface->Get(instance, *name, alarm, *callback); -} - -static int32_t Pnacl_M33_PPB_Alarms_Dev_GetAll(PP_Instance instance, struct PP_Alarms_Alarm_Array_Dev* alarms, struct PP_ArrayOutput* array_allocator, struct PP_CompletionCallback* callback) { - const struct PPB_Alarms_Dev_0_1 *iface = Pnacl_WrapperInfo_PPB_Alarms_Dev_0_1.real_iface; - return iface->GetAll(instance, alarms, *array_allocator, *callback); -} - -static void Pnacl_M33_PPB_Alarms_Dev_Clear(PP_Instance instance, struct PP_Var* name) { - const struct PPB_Alarms_Dev_0_1 *iface = Pnacl_WrapperInfo_PPB_Alarms_Dev_0_1.real_iface; - iface->Clear(instance, *name); -} - -static void Pnacl_M33_PPB_Alarms_Dev_ClearAll(PP_Instance instance) { - const struct PPB_Alarms_Dev_0_1 *iface = Pnacl_WrapperInfo_PPB_Alarms_Dev_0_1.real_iface; - iface->ClearAll(instance); -} - -static uint32_t Pnacl_M33_PPB_Alarms_Dev_AddOnAlarmListener(PP_Instance instance, PP_Alarms_OnAlarm_Dev callback, void* user_data) { - const struct PPB_Alarms_Dev_0_1 *iface = Pnacl_WrapperInfo_PPB_Alarms_Dev_0_1.real_iface; - return iface->AddOnAlarmListener(instance, callback, user_data); -} - -/* End wrapper methods for PPB_Alarms_Dev_0_1 */ - /* Begin wrapper methods for PPB_AudioInput_Dev_0_3 */ static PP_Resource Pnacl_M25_PPB_AudioInput_Dev_Create(PP_Instance instance) { @@ -4883,15 +4847,6 @@ static const struct PPP_Messaging_1_0 Pnacl_Wrappers_PPP_Messaging_1_0 = { /* Not generating wrapper interface for PPB_URLLoaderTrusted_0_3 */ -static const struct PPB_Alarms_Dev_0_1 Pnacl_Wrappers_PPB_Alarms_Dev_0_1 = { - .Create = (void (*)(PP_Instance instance, struct PP_Var name, const struct PP_Alarms_AlarmCreateInfo_Dev* alarm_info))&Pnacl_M33_PPB_Alarms_Dev_Create, - .Get = (int32_t (*)(PP_Instance instance, struct PP_Var name, struct PP_Alarms_Alarm_Dev* alarm, struct PP_CompletionCallback callback))&Pnacl_M33_PPB_Alarms_Dev_Get, - .GetAll = (int32_t (*)(PP_Instance instance, struct PP_Alarms_Alarm_Array_Dev* alarms, struct PP_ArrayOutput array_allocator, struct PP_CompletionCallback callback))&Pnacl_M33_PPB_Alarms_Dev_GetAll, - .Clear = (void (*)(PP_Instance instance, struct PP_Var name))&Pnacl_M33_PPB_Alarms_Dev_Clear, - .ClearAll = (void (*)(PP_Instance instance))&Pnacl_M33_PPB_Alarms_Dev_ClearAll, - .AddOnAlarmListener = (uint32_t (*)(PP_Instance instance, PP_Alarms_OnAlarm_Dev callback, void* user_data))&Pnacl_M33_PPB_Alarms_Dev_AddOnAlarmListener -}; - static const struct PPB_AudioInput_Dev_0_3 Pnacl_Wrappers_PPB_AudioInput_Dev_0_3 = { .Create = (PP_Resource (*)(PP_Instance instance))&Pnacl_M25_PPB_AudioInput_Dev_Create, .IsAudioInput = (PP_Bool (*)(PP_Resource resource))&Pnacl_M25_PPB_AudioInput_Dev_IsAudioInput, @@ -5820,12 +5775,6 @@ static struct __PnaclWrapperInfo Pnacl_WrapperInfo_PPP_Messaging_1_0 = { .real_iface = NULL }; -static struct __PnaclWrapperInfo Pnacl_WrapperInfo_PPB_Alarms_Dev_0_1 = { - .iface_macro = PPB_ALARMS_DEV_INTERFACE_0_1, - .wrapped_iface = (const void *) &Pnacl_Wrappers_PPB_Alarms_Dev_0_1, - .real_iface = NULL -}; - static struct __PnaclWrapperInfo Pnacl_WrapperInfo_PPB_AudioInput_Dev_0_3 = { .iface_macro = PPB_AUDIO_INPUT_DEV_INTERFACE_0_3, .wrapped_iface = (const void *) &Pnacl_Wrappers_PPB_AudioInput_Dev_0_3, @@ -6217,7 +6166,6 @@ static struct __PnaclWrapperInfo *s_ppb_wrappers[] = { &Pnacl_WrapperInfo_PPB_VarDictionary_1_0, &Pnacl_WrapperInfo_PPB_VideoDecoder_0_1, &Pnacl_WrapperInfo_PPB_WebSocket_1_0, - &Pnacl_WrapperInfo_PPB_Alarms_Dev_0_1, &Pnacl_WrapperInfo_PPB_AudioInput_Dev_0_3, &Pnacl_WrapperInfo_PPB_AudioInput_Dev_0_4, &Pnacl_WrapperInfo_PPB_DeviceRef_Dev_0_1, diff --git a/ppapi/ppapi_proxy.gypi b/ppapi/ppapi_proxy.gypi index bd5adc4..117ede6 100644 --- a/ppapi/ppapi_proxy.gypi +++ b/ppapi/ppapi_proxy.gypi @@ -41,8 +41,6 @@ 'proxy/enter_proxy.h', 'proxy/error_conversion.cc', 'proxy/error_conversion.h', - 'proxy/extensions_common_resource.cc', - 'proxy/extensions_common_resource.h', 'proxy/file_chooser_resource.cc', 'proxy/file_chooser_resource.h', 'proxy/file_io_resource.cc', diff --git a/ppapi/ppapi_shared.gypi b/ppapi/ppapi_shared.gypi index 23b00de..78010bd 100644 --- a/ppapi/ppapi_shared.gypi +++ b/ppapi/ppapi_shared.gypi @@ -128,8 +128,6 @@ 'shared_impl/var.h', 'shared_impl/var_tracker.cc', 'shared_impl/var_tracker.h', - 'shared_impl/var_value_conversions.cc', - 'shared_impl/var_value_conversions.h', # TODO(viettrungluu): Split these out; it won't be used in NaCl. 'shared_impl/private/net_address_private_impl.cc', 'shared_impl/private/net_address_private_impl_constants.cc', @@ -142,8 +140,6 @@ 'thunk/enter.cc', 'thunk/enter.h', - 'thunk/extensions_common_api.h', - 'thunk/ppb_alarms_dev_thunk.cc', 'thunk/ppb_audio_api.h', 'thunk/ppb_audio_config_api.h', 'thunk/ppb_audio_config_thunk.cc', diff --git a/ppapi/ppapi_sources.gypi b/ppapi/ppapi_sources.gypi index 03609b0..50e84c3 100644 --- a/ppapi/ppapi_sources.gypi +++ b/ppapi/ppapi_sources.gypi @@ -77,9 +77,7 @@ # Dev interfaces. 'c/dev/pp_cursor_type_dev.h', - 'c/dev/pp_optional_structs_dev.h', 'c/dev/pp_video_dev.h', - 'c/dev/ppb_alarms_dev.h', 'c/dev/ppb_buffer_dev.h', 'c/dev/ppb_char_set_dev.h', 'c/dev/ppb_cursor_control_dev.h', @@ -254,9 +252,6 @@ 'cpp/websocket.h', # Dev interfaces. - 'cpp/dev/alarms_dev.cc', - 'cpp/dev/alarms_dev.h', - 'cpp/dev/array_dev.h', 'cpp/dev/audio_input_dev.cc', 'cpp/dev/audio_input_dev.h', 'cpp/dev/buffer_dev.cc', @@ -273,22 +268,16 @@ 'cpp/dev/font_dev.h', 'cpp/dev/ime_input_event_dev.cc', 'cpp/dev/ime_input_event_dev.h', - 'cpp/dev/may_own_ptr_dev.h', 'cpp/dev/memory_dev.cc', 'cpp/dev/memory_dev.h', - 'cpp/dev/optional_dev.h', 'cpp/dev/printing_dev.cc', 'cpp/dev/printing_dev.h', 'cpp/dev/scrollbar_dev.cc', 'cpp/dev/scrollbar_dev.h', 'cpp/dev/selection_dev.cc', 'cpp/dev/selection_dev.h', - 'cpp/dev/string_wrapper_dev.cc', - 'cpp/dev/string_wrapper_dev.h', - 'cpp/dev/struct_wrapper_output_traits_dev.h', 'cpp/dev/text_input_dev.cc', 'cpp/dev/text_input_dev.h', - 'cpp/dev/to_c_type_converter_dev.h', 'cpp/dev/truetype_font_dev.cc', 'cpp/dev/truetype_font_dev.h', 'cpp/dev/url_util_dev.cc', diff --git a/ppapi/ppapi_tests.gypi b/ppapi/ppapi_tests.gypi index bc02aa1..df51b73 100644 --- a/ppapi/ppapi_tests.gypi +++ b/ppapi/ppapi_tests.gypi @@ -186,7 +186,6 @@ 'shared_impl/time_conversion_unittest.cc', 'shared_impl/tracked_callback_unittest.cc', 'shared_impl/var_tracker_unittest.cc', - 'shared_impl/var_value_conversions_unittest.cc', ], 'conditions': [ [ 'os_posix == 1 and OS != "mac" and OS != "android" and OS != "ios"', { diff --git a/ppapi/proxy/extensions_common_resource.cc b/ppapi/proxy/extensions_common_resource.cc deleted file mode 100644 index 40d03f9..0000000 --- a/ppapi/proxy/extensions_common_resource.cc +++ /dev/null @@ -1,139 +0,0 @@ -// Copyright (c) 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/extensions_common_resource.h" - -#include "base/bind.h" -#include "base/bind_helpers.h" -#include "base/logging.h" -#include "base/memory/scoped_ptr.h" -#include "base/values.h" -#include "ppapi/c/pp_errors.h" -#include "ppapi/proxy/ppapi_messages.h" -#include "ppapi/proxy/resource_message_params.h" -#include "ppapi/shared_impl/tracked_callback.h" -#include "ppapi/shared_impl/var_value_conversions.h" - -namespace ppapi { -namespace proxy { - -ExtensionsCommonResource::ExtensionsCommonResource(Connection connection, - PP_Instance instance) - : PluginResource(connection, instance) { - SendCreate(RENDERER, PpapiHostMsg_ExtensionsCommon_Create()); - SendCreate(BROWSER, PpapiHostMsg_ExtensionsCommon_Create()); -} - -ExtensionsCommonResource::~ExtensionsCommonResource() { -} - -thunk::ExtensionsCommon_API* -ExtensionsCommonResource::AsExtensionsCommon_API() { - return this; -} - -int32_t ExtensionsCommonResource::CallRenderer( - const std::string& request_name, - const std::vector<PP_Var>& input_args, - const std::vector<PP_Var*>& output_args, - scoped_refptr<TrackedCallback> callback) { - return CommonCall(RENDERER, request_name, input_args, output_args, callback); -} - -void ExtensionsCommonResource::PostRenderer(const std::string& request_name, - const std::vector<PP_Var>& args) { - CommonPost(RENDERER, request_name, args); -} - -int32_t ExtensionsCommonResource::CallBrowser( - const std::string& request_name, - const std::vector<PP_Var>& input_args, - const std::vector<PP_Var*>& output_args, - scoped_refptr<TrackedCallback> callback) { - return CommonCall(BROWSER, request_name, input_args, output_args, callback); -} - -void ExtensionsCommonResource::PostBrowser(const std::string& request_name, - const std::vector<PP_Var>& args) { - CommonPost(BROWSER, request_name, args); -} - -int32_t ExtensionsCommonResource::CommonCall( - Destination dest, - const std::string& request_name, - const std::vector<PP_Var>& input_args, - const std::vector<PP_Var*>& output_args, - scoped_refptr<TrackedCallback> callback) { - // TODO(yzshen): CreateValueFromVar() doesn't generate null fields for - // dictionary values. That is the expected behavior for most APIs. If later we - // want to support APIs that require to preserve null fields in dictionaries, - // we should change the behavior to always preserve null fields at the plugin - // side, and figure out whether they should be stripped at the renderer side. - scoped_ptr<base::ListValue> input_args_value( - CreateListValueFromVarVector(input_args)); - if (!input_args_value.get()) { - LOG(WARNING) << "Failed to convert PP_Var input arguments."; - return PP_ERROR_BADARGUMENT; - } - - PluginResource::Call<PpapiPluginMsg_ExtensionsCommon_CallReply>( - dest, - PpapiHostMsg_ExtensionsCommon_Call(request_name, *input_args_value), - base::Bind(&ExtensionsCommonResource::OnPluginMsgCallReply, - base::Unretained(this), output_args, callback)); - return PP_OK_COMPLETIONPENDING; -} - -void ExtensionsCommonResource::CommonPost(Destination dest, - const std::string& request_name, - const std::vector<PP_Var>& args) { - scoped_ptr<base::ListValue> args_value(CreateListValueFromVarVector(args)); - if (!args_value.get()) { - LOG(WARNING) << "Failed to convert PP_Var input arguments."; - return; - } - - PluginResource::Post( - dest, PpapiHostMsg_ExtensionsCommon_Post(request_name, *args_value)); -} - -void ExtensionsCommonResource::OnPluginMsgCallReply( - const std::vector<PP_Var*>& output_args, - scoped_refptr<TrackedCallback> callback, - const ResourceMessageReplyParams& params, - const base::ListValue& output) { - // |output_args| may be invalid and shouldn't be accessed if the callback has - // been called. - if (!TrackedCallback::IsPending(callback)) - return; - - int32_t result = params.result(); - - // If the size doesn't match, something must be really wrong. - CHECK_EQ(output_args.size(), output.GetSize()); - - std::vector<PP_Var> output_vars; - if (CreateVarVectorFromListValue(output, &output_vars)) { - DCHECK_EQ(output_args.size(), output_vars.size()); - std::vector<PP_Var>::const_iterator src_iter = output_vars.begin(); - std::vector<PP_Var*>::const_iterator dest_iter = output_args.begin(); - for (; src_iter != output_vars.end() && dest_iter != output_args.end(); - ++src_iter, ++dest_iter) { - **dest_iter = *src_iter; - } - } else { - NOTREACHED(); - result = PP_ERROR_FAILED; - for (std::vector<PP_Var*>::const_iterator dest_iter = output_args.begin(); - dest_iter != output_args.end(); - ++dest_iter) { - **dest_iter = PP_MakeUndefined(); - } - } - - callback->Run(result); -} - -} // namespace proxy -} // namespace ppapi diff --git a/ppapi/proxy/extensions_common_resource.h b/ppapi/proxy/extensions_common_resource.h deleted file mode 100644 index b3ec366..0000000 --- a/ppapi/proxy/extensions_common_resource.h +++ /dev/null @@ -1,68 +0,0 @@ -// Copyright (c) 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_EXTENSIONS_COMMON_RESOURCE_H_ -#define PPAPI_PROXY_EXTENSIONS_COMMON_RESOURCE_H_ - -#include "base/basictypes.h" -#include "base/compiler_specific.h" -#include "ppapi/proxy/connection.h" -#include "ppapi/proxy/plugin_resource.h" -#include "ppapi/thunk/extensions_common_api.h" - -namespace base { -class ListValue; -} - -namespace ppapi { -namespace proxy { - -class ResourceMessageReplyParams; - -class ExtensionsCommonResource : public PluginResource, - public thunk::ExtensionsCommon_API { - public: - ExtensionsCommonResource(Connection connection, PP_Instance instance); - virtual ~ExtensionsCommonResource(); - - // Resource overrides. - virtual thunk::ExtensionsCommon_API* AsExtensionsCommon_API() OVERRIDE; - - // ExtensionsCommon_API implementation. - virtual int32_t CallRenderer( - const std::string& request_name, - const std::vector<PP_Var>& input_args, - const std::vector<PP_Var*>& output_args, - scoped_refptr<TrackedCallback> callback) OVERRIDE; - virtual void PostRenderer(const std::string& request_name, - const std::vector<PP_Var>& args) OVERRIDE; - virtual int32_t CallBrowser(const std::string& request_name, - const std::vector<PP_Var>& input_args, - const std::vector<PP_Var*>& output_args, - scoped_refptr<TrackedCallback> callback) OVERRIDE; - virtual void PostBrowser(const std::string& request_name, - const std::vector<PP_Var>& args) OVERRIDE; - - private: - int32_t CommonCall(Destination dest, - const std::string& request_name, - const std::vector<PP_Var>& input_args, - const std::vector<PP_Var*>& output_args, - scoped_refptr<TrackedCallback> callback); - void CommonPost(Destination dest, - const std::string& request_name, - const std::vector<PP_Var>& args); - - void OnPluginMsgCallReply(const std::vector<PP_Var*>& output_args, - scoped_refptr<TrackedCallback> callback, - const ResourceMessageReplyParams& params, - const base::ListValue& output); - - DISALLOW_COPY_AND_ASSIGN(ExtensionsCommonResource); -}; - -} // namespace proxy -} // namespace ppapi - -#endif // PPAPI_PROXY_EXTENSIONS_COMMON_RESOURCE_H_ diff --git a/ppapi/proxy/interface_list.cc b/ppapi/proxy/interface_list.cc index 61e1f17..7e5125d 100644 --- a/ppapi/proxy/interface_list.cc +++ b/ppapi/proxy/interface_list.cc @@ -7,7 +7,6 @@ #include "base/hash.h" #include "base/lazy_instance.h" #include "base/memory/singleton.h" -#include "ppapi/c/dev/ppb_alarms_dev.h" #include "ppapi/c/dev/ppb_audio_input_dev.h" #include "ppapi/c/dev/ppb_buffer_dev.h" #include "ppapi/c/dev/ppb_char_set_dev.h" diff --git a/ppapi/proxy/ppapi_messages.h b/ppapi/proxy/ppapi_messages.h index a1ef6d6..255cc9c 100644 --- a/ppapi/proxy/ppapi_messages.h +++ b/ppapi/proxy/ppapi_messages.h @@ -13,7 +13,6 @@ #include "base/process/process.h" #include "base/strings/string16.h" #include "base/sync_socket.h" -#include "base/values.h" #include "gpu/command_buffer/common/command_buffer.h" #include "gpu/command_buffer/common/mailbox.h" #include "gpu/ipc/gpu_command_buffer_traits.h" @@ -1307,25 +1306,6 @@ IPC_MESSAGE_CONTROL0(PpapiHostMsg_Broker_Create) // ResourceMessageReplyParams in the reply message. IPC_MESSAGE_CONTROL0(PpapiHostMsg_Broker_IsAllowed) -// Extensions common ----------------------------------------------------------- -IPC_MESSAGE_CONTROL0(PpapiHostMsg_ExtensionsCommon_Create) - -// Starts an extension API request which doesn't expect a response. -// |request_name| is an API function name. |args| is a list of input arguments. -IPC_MESSAGE_CONTROL2(PpapiHostMsg_ExtensionsCommon_Post, - std::string /* request_name */, - base::ListValue /* args */) - -// Starts an extension API request which expects a response sent back using a -// PpapiPluginMsg_ExtensionsCommon_CallReply message. -// |request_name| is an API function name. |args| is a list of input arguments. -// |output| is a list of output results. -IPC_MESSAGE_CONTROL2(PpapiHostMsg_ExtensionsCommon_Call, - std::string /* request_name */, - base::ListValue /* args */) -IPC_MESSAGE_CONTROL1(PpapiPluginMsg_ExtensionsCommon_CallReply, - base::ListValue /* output */) - // UMA IPC_MESSAGE_CONTROL0(PpapiHostMsg_UMA_Create) IPC_MESSAGE_CONTROL5(PpapiHostMsg_UMA_HistogramCustomTimes, diff --git a/ppapi/proxy/ppb_instance_proxy.cc b/ppapi/proxy/ppb_instance_proxy.cc index 48f4378..2b1a988 100644 --- a/ppapi/proxy/ppb_instance_proxy.cc +++ b/ppapi/proxy/ppb_instance_proxy.cc @@ -18,7 +18,6 @@ #include "ppapi/proxy/browser_font_singleton_resource.h" #include "ppapi/proxy/content_decryptor_private_serializer.h" #include "ppapi/proxy/enter_proxy.h" -#include "ppapi/proxy/extensions_common_resource.h" #include "ppapi/proxy/file_mapping_resource.h" #include "ppapi/proxy/flash_clipboard_resource.h" #include "ppapi/proxy/flash_file_resource.h" @@ -395,9 +394,6 @@ Resource* PPB_Instance_Proxy::GetSingletonResource(PP_Instance instance, case BROKER_SINGLETON_ID: new_singleton = new BrokerResource(connection, instance); break; - case EXTENSIONS_COMMON_SINGLETON_ID: - new_singleton = new ExtensionsCommonResource(connection, instance); - break; case FILE_MAPPING_SINGLETON_ID: new_singleton = new FileMappingResource(connection, instance); break; diff --git a/ppapi/shared_impl/resource.h b/ppapi/shared_impl/resource.h index 632520a..fdcf4fc 100644 --- a/ppapi/shared_impl/resource.h +++ b/ppapi/shared_impl/resource.h @@ -19,7 +19,6 @@ // All resource types should be added here. This implements our hand-rolled // RTTI system since we don't compile with "real" RTTI. #define FOR_ALL_PPAPI_RESOURCE_APIS(F) \ - F(ExtensionsCommon_API) \ F(PPB_Audio_API) \ F(PPB_AudioBuffer_API) \ F(PPB_AudioConfig_API) \ diff --git a/ppapi/shared_impl/singleton_resource_id.h b/ppapi/shared_impl/singleton_resource_id.h index 6441a2b..4d34fd6 100644 --- a/ppapi/shared_impl/singleton_resource_id.h +++ b/ppapi/shared_impl/singleton_resource_id.h @@ -15,7 +15,6 @@ enum SingletonResourceID { // resource model. BROKER_SINGLETON_ID, BROWSER_FONT_SINGLETON_ID, - EXTENSIONS_COMMON_SINGLETON_ID, FILE_MAPPING_SINGLETON_ID, FLASH_CLIPBOARD_SINGLETON_ID, FLASH_FILE_SINGLETON_ID, diff --git a/ppapi/shared_impl/var_value_conversions.cc b/ppapi/shared_impl/var_value_conversions.cc deleted file mode 100644 index d5aad57..0000000 --- a/ppapi/shared_impl/var_value_conversions.cc +++ /dev/null @@ -1,381 +0,0 @@ -// Copyright (c) 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/var_value_conversions.h" - -#include <limits> -#include <set> -#include <stack> - -#include "base/logging.h" -#include "base/memory/ref_counted.h" -#include "base/memory/scoped_ptr.h" -#include "base/stl_util.h" -#include "base/values.h" -#include "ppapi/c/pp_bool.h" -#include "ppapi/c/pp_stdint.h" -#include "ppapi/shared_impl/array_var.h" -#include "ppapi/shared_impl/dictionary_var.h" -#include "ppapi/shared_impl/ppapi_globals.h" -#include "ppapi/shared_impl/scoped_pp_var.h" -#include "ppapi/shared_impl/var.h" -#include "ppapi/shared_impl/var_tracker.h" - -namespace ppapi { - -namespace { - -// In CreateValueFromVar(), a stack is used to keep track of conversion progress -// of array and dictionary vars. VarNode represents elements of that stack. -struct VarNode { - VarNode(const PP_Var& in_var, base::Value* in_value) - : var(in_var), value(in_value), sentinel(false) {} - - // This object doesn't hold a reference to it. - PP_Var var; - // It is not owned by this object. - base::Value* value; - // When this is set to true for a node in the stack, it means that we have - // finished processing the node itself. However, we keep it in the stack as - // a sentinel. When it becomes the top element of the stack again, we know - // that we have processed all the descendants of this node. - bool sentinel; -}; - -// In CreateVarFromValue(), a stack is used to keep track of conversion progress -// of list and dictionary values. ValueNode represents elements of that stack. -struct ValueNode { - ValueNode(const PP_Var& in_var, const base::Value* in_value) - : var(in_var), value(in_value) {} - - // This object doesn't hold a reference to it. - PP_Var var; - // It is not owned by this object. - const base::Value* value; -}; - -// Helper function for CreateValueFromVar(). It only looks at |var| but not its -// descendants. The conversion result is stored in |value|. If |var| is array or -// dictionary, a new node is pushed onto |state|. -// -// Returns false on failure. -bool CreateValueFromVarHelper(const std::set<int64_t>& parent_ids, - const PP_Var& var, - scoped_ptr<base::Value>* value, - std::stack<VarNode>* state) { - switch (var.type) { - case PP_VARTYPE_UNDEFINED: - case PP_VARTYPE_NULL: { - value->reset(base::Value::CreateNullValue()); - return true; - } - case PP_VARTYPE_BOOL: { - value->reset(new base::FundamentalValue(PP_ToBool(var.value.as_bool))); - return true; - } - case PP_VARTYPE_INT32: { - value->reset(new base::FundamentalValue(var.value.as_int)); - return true; - } - case PP_VARTYPE_DOUBLE: { - value->reset(new base::FundamentalValue(var.value.as_double)); - return true; - } - case PP_VARTYPE_STRING: { - StringVar* string_var = StringVar::FromPPVar(var); - if (!string_var) - return false; - - value->reset(new base::StringValue(string_var->value())); - return true; - } - case PP_VARTYPE_OBJECT: { return false; } - case PP_VARTYPE_ARRAY: { - if (ContainsKey(parent_ids, var.value.as_id)) { - // A circular reference is found. - return false; - } - - value->reset(new base::ListValue()); - state->push(VarNode(var, value->get())); - return true; - } - case PP_VARTYPE_DICTIONARY: { - if (ContainsKey(parent_ids, var.value.as_id)) { - // A circular reference is found. - return false; - } - - value->reset(new base::DictionaryValue()); - state->push(VarNode(var, value->get())); - return true; - } - case PP_VARTYPE_ARRAY_BUFFER: { - ArrayBufferVar* array_buffer = ArrayBufferVar::FromPPVar(var); - if (!array_buffer) - return false; - - base::BinaryValue* binary_value = - base::BinaryValue::CreateWithCopiedBuffer( - static_cast<const char*>(array_buffer->Map()), - array_buffer->ByteLength()); - array_buffer->Unmap(); - value->reset(binary_value); - return true; - } - case PP_VARTYPE_RESOURCE: { return false; } - } - NOTREACHED(); - return false; -} - -// Helper function for CreateVarFromValue(). It only looks at |value| but not -// its descendants. The conversion result is stored in |var|. If |value| is list -// or dictionary, a new node is pushed onto |state|. -// -// Returns false on failure. -bool CreateVarFromValueHelper(const base::Value& value, - ScopedPPVar* var, - std::stack<ValueNode>* state) { - switch (value.GetType()) { - case base::Value::TYPE_NULL: { - *var = PP_MakeNull(); - return true; - } - case base::Value::TYPE_BOOLEAN: { - bool result = false; - if (value.GetAsBoolean(&result)) { - *var = PP_MakeBool(PP_FromBool(result)); - return true; - } - return false; - } - case base::Value::TYPE_INTEGER: { - int result = 0; - if (value.GetAsInteger(&result)) { - *var = PP_MakeInt32(result); - return true; - } - return false; - } - case base::Value::TYPE_DOUBLE: { - double result = 0; - if (value.GetAsDouble(&result)) { - *var = PP_MakeDouble(result); - return true; - } - return false; - } - case base::Value::TYPE_STRING: { - std::string result; - if (value.GetAsString(&result)) { - *var = ScopedPPVar(ScopedPPVar::PassRef(), - StringVar::StringToPPVar(result)); - return true; - } - return false; - } - case base::Value::TYPE_BINARY: { - const base::BinaryValue& binary_value = - static_cast<const base::BinaryValue&>(value); - - size_t size = binary_value.GetSize(); - if (size > std::numeric_limits<uint32>::max()) - return false; - - ScopedPPVar temp( - ScopedPPVar::PassRef(), - PpapiGlobals::Get()->GetVarTracker()->MakeArrayBufferPPVar( - static_cast<uint32>(size), binary_value.GetBuffer())); - if (temp.get().type == PP_VARTYPE_ARRAY_BUFFER) { - *var = temp; - return true; - } - return false; - } - case base::Value::TYPE_DICTIONARY: { - scoped_refptr<DictionaryVar> dict_var(new DictionaryVar()); - *var = ScopedPPVar(ScopedPPVar::PassRef(), dict_var->GetPPVar()); - state->push(ValueNode(var->get(), &value)); - return true; - } - case base::Value::TYPE_LIST: { - scoped_refptr<ArrayVar> array_var(new ArrayVar()); - *var = ScopedPPVar(ScopedPPVar::PassRef(), array_var->GetPPVar()); - state->push(ValueNode(var->get(), &value)); - return true; - } - } - NOTREACHED(); - return false; -} - -} // namespace - -base::Value* CreateValueFromVar(const PP_Var& var) { - // Used to detect circular references. - std::set<int64_t> parent_ids; - std::stack<VarNode> state; - scoped_ptr<base::Value> root_value; - - if (!CreateValueFromVarHelper(parent_ids, var, &root_value, &state)) - return NULL; - - while (!state.empty()) { - VarNode& top = state.top(); - if (top.sentinel) { - parent_ids.erase(top.var.value.as_id); - state.pop(); - } else if (top.var.type == PP_VARTYPE_DICTIONARY) { - parent_ids.insert(top.var.value.as_id); - top.sentinel = true; - - DictionaryVar* dict_var = DictionaryVar::FromPPVar(top.var); - if (!dict_var) - return NULL; - - DCHECK(top.value->GetType() == base::Value::TYPE_DICTIONARY); - base::DictionaryValue* dict_value = - static_cast<base::DictionaryValue*>(top.value); - - for (DictionaryVar::KeyValueMap::const_iterator iter = - dict_var->key_value_map().begin(); - iter != dict_var->key_value_map().end(); - ++iter) { - // Skip the key-value pair if the value is undefined or null. - if (iter->second.get().type == PP_VARTYPE_UNDEFINED || - iter->second.get().type == PP_VARTYPE_NULL) { - continue; - } - - scoped_ptr<base::Value> child_value; - if (!CreateValueFromVarHelper( - parent_ids, iter->second.get(), &child_value, &state)) { - return NULL; - } - - dict_value->SetWithoutPathExpansion(iter->first, child_value.release()); - } - } else if (top.var.type == PP_VARTYPE_ARRAY) { - parent_ids.insert(top.var.value.as_id); - top.sentinel = true; - - ArrayVar* array_var = ArrayVar::FromPPVar(top.var); - if (!array_var) - return NULL; - - DCHECK(top.value->GetType() == base::Value::TYPE_LIST); - base::ListValue* list_value = static_cast<base::ListValue*>(top.value); - - for (ArrayVar::ElementVector::const_iterator iter = - array_var->elements().begin(); - iter != array_var->elements().end(); - ++iter) { - scoped_ptr<base::Value> child_value; - if (!CreateValueFromVarHelper( - parent_ids, iter->get(), &child_value, &state)) { - return NULL; - } - - list_value->Append(child_value.release()); - } - } else { - NOTREACHED(); - return NULL; - } - } - DCHECK(parent_ids.empty()); - return root_value.release(); -} - -PP_Var CreateVarFromValue(const base::Value& value) { - std::stack<ValueNode> state; - ScopedPPVar root_var; - - if (!CreateVarFromValueHelper(value, &root_var, &state)) - return PP_MakeUndefined(); - - while (!state.empty()) { - ValueNode top = state.top(); - state.pop(); - - if (top.value->GetType() == base::Value::TYPE_DICTIONARY) { - const base::DictionaryValue* dict_value = - static_cast<const base::DictionaryValue*>(top.value); - DictionaryVar* dict_var = DictionaryVar::FromPPVar(top.var); - DCHECK(dict_var); - for (base::DictionaryValue::Iterator iter(*dict_value); !iter.IsAtEnd(); - iter.Advance()) { - ScopedPPVar child_var; - if (!CreateVarFromValueHelper(iter.value(), &child_var, &state) || - !dict_var->SetWithStringKey(iter.key(), child_var.get())) { - return PP_MakeUndefined(); - } - } - } else if (top.value->GetType() == base::Value::TYPE_LIST) { - const base::ListValue* list_value = - static_cast<const base::ListValue*>(top.value); - ArrayVar* array_var = ArrayVar::FromPPVar(top.var); - DCHECK(array_var); - for (base::ListValue::const_iterator iter = list_value->begin(); - iter != list_value->end(); - ++iter) { - ScopedPPVar child_var; - if (!CreateVarFromValueHelper(**iter, &child_var, &state)) - return PP_MakeUndefined(); - - array_var->elements().push_back(child_var); - } - } else { - NOTREACHED(); - return PP_MakeUndefined(); - } - } - - return root_var.Release(); -} - -base::ListValue* CreateListValueFromVarVector(const std::vector<PP_Var>& vars) { - scoped_ptr<base::ListValue> list_value(new base::ListValue()); - - for (std::vector<PP_Var>::const_iterator iter = vars.begin(); - iter != vars.end(); - ++iter) { - base::Value* value = CreateValueFromVar(*iter); - if (!value) - return NULL; - list_value->Append(value); - } - return list_value.release(); -} - -bool CreateVarVectorFromListValue(const base::ListValue& list_value, - std::vector<PP_Var>* vars) { - if (!vars) - return false; - - std::vector<ScopedPPVar> result; - result.reserve(list_value.GetSize()); - for (base::ListValue::const_iterator iter = list_value.begin(); - iter != list_value.end(); - ++iter) { - ScopedPPVar child_var(ScopedPPVar::PassRef(), CreateVarFromValue(**iter)); - if (child_var.get().type == PP_VARTYPE_UNDEFINED) - return false; - - result.push_back(child_var); - } - - vars->clear(); - vars->reserve(result.size()); - for (std::vector<ScopedPPVar>::iterator iter = result.begin(); - iter != result.end(); - ++iter) { - vars->push_back(iter->Release()); - } - - return true; -} - -} // namespace ppapi diff --git a/ppapi/shared_impl/var_value_conversions.h b/ppapi/shared_impl/var_value_conversions.h deleted file mode 100644 index dfbda50..0000000 --- a/ppapi/shared_impl/var_value_conversions.h +++ /dev/null @@ -1,61 +0,0 @@ -// Copyright (c) 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_VAR_VALUE_CONVERSIONS_H_ -#define PPAPI_SHARED_IMPL_VAR_VALUE_CONVERSIONS_H_ - -#include <vector> - -#include "ppapi/c/pp_var.h" -#include "ppapi/shared_impl/ppapi_shared_export.h" - -namespace base { -class ListValue; -class Value; -} - -namespace ppapi { - -// Converts a PP_Var to a base::Value object. The caller takes ownership of the -// returned object. -// -// Both PP_VARTYPE_UNDEFINED and PP_VARTYPE_NULL are converted to -// base::Value::TYPE_NULL. In dictionary vars, key-value pairs whose value is -// undefined (PP_VARTYPE_UNDEFINED) or null (PP_VARTYPE_NULL) are ignored. If a -// node in |var| appears more than once, it is duplicated in the result. For -// example, if |var| is an array and it has two elements pointing to the same -// dictionary, the resulting list value will have two copies of the dictionary. -// -// The conversion fails and returns NULL if -// - |var| is object (PP_VARTYPE_OBJECT); or -// - |var| is an array or dictionary, and calling CreateValueFromVar() on any of -// the array elements or dictionary values fails; or -// - there exist circular references, i.e., an array or dictionary is its own -// ancestor/descendant. -PPAPI_SHARED_EXPORT base::Value* CreateValueFromVar(const PP_Var& var); - -// The returned var has had 1 ref added on behalf of the caller. -// Returns an undefined var if the conversion fails. -PPAPI_SHARED_EXPORT PP_Var CreateVarFromValue(const base::Value& value); - -// Calls CreateValueFromVar() on each element of |vars| and puts them in a -// base::ListValue. The caller takes ownership of the returned object. -// -// The conversion fails and returns NULL if any of the calls to -// CreateValueFromVar() fails. -PPAPI_SHARED_EXPORT base::ListValue* CreateListValueFromVarVector( - const std::vector<PP_Var>& vars); - -// Calls CreateVarFromValue() on each element of |list_value| and puts them in -// |vars|. The returned vars have had 1 ref added on behalf of the caller. -// -// The conversion fails and returns false if any of the calls to -// CreateVarFromValue() fails. In that case, |vars| is untouched. -PPAPI_SHARED_EXPORT bool CreateVarVectorFromListValue( - const base::ListValue& list_value, - std::vector<PP_Var>* vars); - -} // namespace ppapi - -#endif // PPAPI_SHARED_IMPL_VAR_VALUE_CONVERSIONS_H_ diff --git a/ppapi/shared_impl/var_value_conversions_unittest.cc b/ppapi/shared_impl/var_value_conversions_unittest.cc deleted file mode 100644 index 8a6fc19..0000000 --- a/ppapi/shared_impl/var_value_conversions_unittest.cc +++ /dev/null @@ -1,391 +0,0 @@ -// Copyright (c) 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/var_value_conversions.h" - -#include <cmath> -#include <cstring> - -#include "base/logging.h" -#include "base/memory/ref_counted.h" -#include "base/memory/scoped_ptr.h" -#include "base/values.h" -#include "ppapi/c/pp_bool.h" -#include "ppapi/c/pp_var.h" -#include "ppapi/shared_impl/array_var.h" -#include "ppapi/shared_impl/dictionary_var.h" -#include "ppapi/shared_impl/ppapi_globals.h" -#include "ppapi/shared_impl/proxy_lock.h" -#include "ppapi/shared_impl/scoped_pp_var.h" -#include "ppapi/shared_impl/test_globals.h" -#include "ppapi/shared_impl/var.h" -#include "ppapi/shared_impl/var_tracker.h" -#include "testing/gtest/include/gtest/gtest.h" - -namespace ppapi { -namespace { - -bool Equals(const base::Value& value, const PP_Var& var) { - switch (value.GetType()) { - case base::Value::TYPE_NULL: { - return var.type == PP_VARTYPE_NULL || var.type == PP_VARTYPE_UNDEFINED; - } - case base::Value::TYPE_BOOLEAN: { - bool result = false; - return var.type == PP_VARTYPE_BOOL && value.GetAsBoolean(&result) && - result == PP_ToBool(var.value.as_bool); - } - case base::Value::TYPE_INTEGER: { - int result = 0; - return var.type == PP_VARTYPE_INT32 && value.GetAsInteger(&result) && - result == var.value.as_int; - } - case base::Value::TYPE_DOUBLE: { - double result = 0; - return var.type == PP_VARTYPE_DOUBLE && value.GetAsDouble(&result) && - fabs(result - var.value.as_double) < 1.0e-4; - } - case base::Value::TYPE_STRING: { - std::string result; - StringVar* string_var = StringVar::FromPPVar(var); - return string_var && value.GetAsString(&result) && - result == string_var->value(); - } - case base::Value::TYPE_BINARY: { - const base::BinaryValue& binary_value = - static_cast<const base::BinaryValue&>(value); - ArrayBufferVar* array_buffer_var = ArrayBufferVar::FromPPVar(var); - if (!array_buffer_var || - binary_value.GetSize() != array_buffer_var->ByteLength()) { - return false; - } - - bool result = !memcmp(binary_value.GetBuffer(), - array_buffer_var->Map(), - binary_value.GetSize()); - array_buffer_var->Unmap(); - return result; - } - case base::Value::TYPE_DICTIONARY: { - const base::DictionaryValue& dict_value = - static_cast<const base::DictionaryValue&>(value); - DictionaryVar* dict_var = DictionaryVar::FromPPVar(var); - if (!dict_var) - return false; - - size_t count = 0; - for (DictionaryVar::KeyValueMap::const_iterator iter = - dict_var->key_value_map().begin(); - iter != dict_var->key_value_map().end(); - ++iter) { - if (iter->second.get().type == PP_VARTYPE_UNDEFINED || - iter->second.get().type == PP_VARTYPE_NULL) { - continue; - } - - ++count; - const base::Value* sub_value = NULL; - if (!dict_value.GetWithoutPathExpansion(iter->first, &sub_value) || - !Equals(*sub_value, iter->second.get())) { - return false; - } - } - return count == dict_value.size(); - } - case base::Value::TYPE_LIST: { - const base::ListValue& list_value = - static_cast<const base::ListValue&>(value); - ArrayVar* array_var = ArrayVar::FromPPVar(var); - if (!array_var || list_value.GetSize() != array_var->elements().size()) - return false; - - base::ListValue::const_iterator value_iter = list_value.begin(); - ArrayVar::ElementVector::const_iterator var_iter = - array_var->elements().begin(); - for (; value_iter != list_value.end() && - var_iter != array_var->elements().end(); - ++value_iter, ++var_iter) { - if (!Equals(**value_iter, var_iter->get())) - return false; - } - return true; - } - } - NOTREACHED(); - return false; -} - -bool ConvertVarAndVerify(const PP_Var& var) { - scoped_ptr<base::Value> value(CreateValueFromVar(var)); - if (value.get()) - return Equals(*value, var); - return false; -} - -bool ConvertValueAndVerify(const base::Value& value) { - ScopedPPVar var(ScopedPPVar::PassRef(), CreateVarFromValue(value)); - if (var.get().type != PP_VARTYPE_UNDEFINED) - return Equals(value, var.get()); - return false; -} - -class VarValueConversionsTest : public testing::Test { - public: - VarValueConversionsTest() {} - virtual ~VarValueConversionsTest() {} - - // testing::Test implementation. - virtual void SetUp() { - ProxyLock::EnableLockingOnThreadForTest(); - ProxyLock::Acquire(); - } - virtual void TearDown() { - ASSERT_TRUE(PpapiGlobals::Get()->GetVarTracker()->GetLiveVars().empty()); - ProxyLock::Release(); - } - - private: - TestGlobals globals_; -}; - -} // namespace - -TEST_F(VarValueConversionsTest, CreateValueFromVar) { - { - // Var holding a ref to itself is not a valid input. - scoped_refptr<DictionaryVar> dict_var(new DictionaryVar()); - ScopedPPVar var_1(ScopedPPVar::PassRef(), dict_var->GetPPVar()); - scoped_refptr<ArrayVar> array_var(new ArrayVar()); - ScopedPPVar var_2(ScopedPPVar::PassRef(), array_var->GetPPVar()); - - ASSERT_TRUE(dict_var->SetWithStringKey("key_1", var_2.get())); - ASSERT_TRUE(ConvertVarAndVerify(var_1.get())); - - ASSERT_TRUE(array_var->Set(0, var_1.get())); - scoped_ptr<base::Value> value(CreateValueFromVar(var_1.get())); - ASSERT_EQ(NULL, value.get()); - - // Make sure |var_1| doesn't indirectly hold a ref to itself, otherwise it - // is leaked. - dict_var->DeleteWithStringKey("key_1"); - } - - // Vars of null or undefined type are converted to null values. - { - ASSERT_TRUE(ConvertVarAndVerify(PP_MakeNull())); - ASSERT_TRUE(ConvertVarAndVerify(PP_MakeUndefined())); - } - - { - // Test empty dictionary. - scoped_refptr<DictionaryVar> dict_var(new DictionaryVar()); - ScopedPPVar var(ScopedPPVar::PassRef(), dict_var->GetPPVar()); - - ASSERT_TRUE(ConvertVarAndVerify(var.get())); - } - - { - // Key-value pairs whose value is undefined or null are ignored. - scoped_refptr<DictionaryVar> dict_var(new DictionaryVar()); - ASSERT_TRUE(dict_var->SetWithStringKey("key_1", PP_MakeUndefined())); - ASSERT_TRUE(dict_var->SetWithStringKey("key_2", PP_MakeInt32(1))); - ASSERT_TRUE(dict_var->SetWithStringKey("key_3", PP_MakeNull())); - ScopedPPVar var(ScopedPPVar::PassRef(), dict_var->GetPPVar()); - - ASSERT_TRUE(ConvertVarAndVerify(var.get())); - } - - { - // The same PP_Var is allowed to appear multiple times. - scoped_refptr<DictionaryVar> dict_var_1(new DictionaryVar()); - ScopedPPVar dict_pp_var_1(ScopedPPVar::PassRef(), dict_var_1->GetPPVar()); - scoped_refptr<DictionaryVar> dict_var_2(new DictionaryVar()); - ScopedPPVar dict_pp_var_2(ScopedPPVar::PassRef(), dict_var_2->GetPPVar()); - scoped_refptr<StringVar> string_var(new StringVar("string_value")); - ScopedPPVar string_pp_var(ScopedPPVar::PassRef(), string_var->GetPPVar()); - - ASSERT_TRUE(dict_var_1->SetWithStringKey("key_1", dict_pp_var_2.get())); - ASSERT_TRUE(dict_var_1->SetWithStringKey("key_2", dict_pp_var_2.get())); - ASSERT_TRUE(dict_var_1->SetWithStringKey("key_3", string_pp_var.get())); - ASSERT_TRUE(dict_var_2->SetWithStringKey("key_4", string_pp_var.get())); - - ASSERT_TRUE(ConvertVarAndVerify(dict_pp_var_1.get())); - } - - { - // Test basic cases for array. - scoped_refptr<ArrayVar> array_var(new ArrayVar()); - ScopedPPVar var(ScopedPPVar::PassRef(), array_var->GetPPVar()); - - ASSERT_TRUE(ConvertVarAndVerify(var.get())); - - ASSERT_TRUE(array_var->Set(0, PP_MakeDouble(1))); - - ASSERT_TRUE(ConvertVarAndVerify(var.get())); - } - - { - // Test more complex inputs. - scoped_refptr<DictionaryVar> dict_var_1(new DictionaryVar()); - ScopedPPVar dict_pp_var_1(ScopedPPVar::PassRef(), dict_var_1->GetPPVar()); - scoped_refptr<DictionaryVar> dict_var_2(new DictionaryVar()); - ScopedPPVar dict_pp_var_2(ScopedPPVar::PassRef(), dict_var_2->GetPPVar()); - scoped_refptr<ArrayVar> array_var(new ArrayVar()); - ScopedPPVar array_pp_var(ScopedPPVar::PassRef(), array_var->GetPPVar()); - scoped_refptr<StringVar> string_var(new StringVar("string_value")); - ScopedPPVar string_pp_var(ScopedPPVar::PassRef(), string_var->GetPPVar()); - - ASSERT_TRUE(dict_var_1->SetWithStringKey("null_key", PP_MakeNull())); - ASSERT_TRUE( - dict_var_1->SetWithStringKey("string_key", string_pp_var.get())); - ASSERT_TRUE(dict_var_1->SetWithStringKey("dict_key", dict_pp_var_2.get())); - - ASSERT_TRUE( - dict_var_2->SetWithStringKey("undefined_key", PP_MakeUndefined())); - ASSERT_TRUE(dict_var_2->SetWithStringKey("double_key", PP_MakeDouble(1))); - ASSERT_TRUE(dict_var_2->SetWithStringKey("array_key", array_pp_var.get())); - - ASSERT_TRUE(array_var->Set(0, PP_MakeInt32(2))); - ASSERT_TRUE(array_var->Set(1, PP_MakeBool(PP_TRUE))); - ASSERT_TRUE(array_var->SetLength(4)); - - ASSERT_TRUE(ConvertVarAndVerify(dict_pp_var_1.get())); - } - - { - // Test that dictionary keys containing '.' are handled correctly. - scoped_refptr<DictionaryVar> dict_var(new DictionaryVar()); - ScopedPPVar dict_pp_var(ScopedPPVar::PassRef(), dict_var->GetPPVar()); - - ASSERT_TRUE(dict_var->SetWithStringKey("double.key", PP_MakeDouble(1))); - ASSERT_TRUE(dict_var->SetWithStringKey("int.key..name", PP_MakeInt32(2))); - - ASSERT_TRUE(ConvertVarAndVerify(dict_pp_var.get())); - } -} - -TEST_F(VarValueConversionsTest, CreateVarFromValue) { - { - // Test basic cases for dictionary. - base::DictionaryValue dict_value; - ASSERT_TRUE(ConvertValueAndVerify(dict_value)); - - dict_value.SetInteger("int_key", 1); - ASSERT_TRUE(ConvertValueAndVerify(dict_value)); - } - - { - // Test basic cases for array. - base::ListValue list_value; - ASSERT_TRUE(ConvertValueAndVerify(list_value)); - - list_value.AppendInteger(1); - ASSERT_TRUE(ConvertValueAndVerify(list_value)); - } - - { - // Test more complex inputs. - base::DictionaryValue dict_value; - dict_value.SetString("string_key", "string_value"); - dict_value.SetDouble("dict_key.double_key", 1); - - scoped_ptr<base::ListValue> list_value(new base::ListValue()); - list_value->AppendInteger(2); - list_value->AppendBoolean(true); - list_value->Append(base::Value::CreateNullValue()); - - dict_value.Set("dict_key.array_key", list_value.release()); - - ASSERT_TRUE(ConvertValueAndVerify(dict_value)); - } -} - -TEST_F(VarValueConversionsTest, CreateListValueFromVarVector) { - { - // Test empty var vector. - scoped_ptr<base::ListValue> list_value( - CreateListValueFromVarVector(std::vector<PP_Var>())); - ASSERT_TRUE(list_value.get()); - ASSERT_EQ(0u, list_value->GetSize()); - } - - { - // Test more complex inputs. - scoped_refptr<StringVar> string_var(new StringVar("string_value")); - ScopedPPVar string_pp_var(ScopedPPVar::PassRef(), string_var->GetPPVar()); - - scoped_refptr<DictionaryVar> dict_var(new DictionaryVar()); - ScopedPPVar dict_pp_var(ScopedPPVar::PassRef(), dict_var->GetPPVar()); - ASSERT_TRUE(dict_var->SetWithStringKey("null_key", PP_MakeNull())); - ASSERT_TRUE(dict_var->SetWithStringKey("string_key", string_pp_var.get())); - - scoped_refptr<ArrayVar> array_var(new ArrayVar()); - ScopedPPVar array_pp_var(ScopedPPVar::PassRef(), array_var->GetPPVar()); - ASSERT_TRUE(array_var->Set(0, PP_MakeInt32(2))); - ASSERT_TRUE(array_var->Set(1, PP_MakeBool(PP_TRUE))); - ASSERT_TRUE(array_var->SetLength(4)); - - std::vector<PP_Var> vars; - vars.push_back(dict_pp_var.get()); - vars.push_back(string_pp_var.get()); - vars.push_back(array_pp_var.get()); - vars.push_back(PP_MakeDouble(1)); - vars.push_back(PP_MakeUndefined()); - vars.push_back(PP_MakeNull()); - - scoped_ptr<base::ListValue> list_value(CreateListValueFromVarVector(vars)); - - ASSERT_TRUE(list_value.get()); - ASSERT_EQ(vars.size(), list_value->GetSize()); - - for (size_t i = 0; i < list_value->GetSize(); ++i) { - const base::Value* value = NULL; - ASSERT_TRUE(list_value->Get(i, &value)); - ASSERT_TRUE(Equals(*value, vars[i])); - } - } -} - -TEST_F(VarValueConversionsTest, CreateVarVectorFromListValue) { - { - // Test empty list. - base::ListValue list_value; - std::vector<PP_Var> vars; - ASSERT_TRUE(CreateVarVectorFromListValue(list_value, &vars)); - ASSERT_EQ(0u, vars.size()); - } - - { - // Test more complex inputs. - base::ListValue list_value; - - scoped_ptr<base::DictionaryValue> dict_value(new base::DictionaryValue()); - dict_value->SetString("string_key", "string_value"); - - scoped_ptr<base::ListValue> sub_list_value(new base::ListValue()); - sub_list_value->AppendInteger(2); - sub_list_value->AppendBoolean(true); - - list_value.Append(dict_value.release()); - list_value.AppendString("string_value"); - list_value.Append(sub_list_value.release()); - list_value.AppendDouble(1); - list_value.Append(base::Value::CreateNullValue()); - - std::vector<PP_Var> vars; - ASSERT_TRUE(CreateVarVectorFromListValue(list_value, &vars)); - - ASSERT_EQ(list_value.GetSize(), vars.size()); - - for (size_t i = 0; i < list_value.GetSize(); ++i) { - const base::Value* value = NULL; - ASSERT_TRUE(list_value.Get(i, &value)); - ASSERT_TRUE(Equals(*value, vars[i])); - - PpapiGlobals::Get()->GetVarTracker()->ReleaseVar(vars[i]); - } - } -} - -} // namespace ppapi diff --git a/ppapi/tests/all_c_includes.h b/ppapi/tests/all_c_includes.h index 6d7cdf9..1e49d64 100644 --- a/ppapi/tests/all_c_includes.h +++ b/ppapi/tests/all_c_includes.h @@ -10,9 +10,7 @@ #include "ppapi/c/dev/deprecated_bool.h" #include "ppapi/c/dev/pp_cursor_type_dev.h" -#include "ppapi/c/dev/pp_optional_structs_dev.h" #include "ppapi/c/dev/pp_video_dev.h" -#include "ppapi/c/dev/ppb_alarms_dev.h" #include "ppapi/c/dev/ppb_buffer_dev.h" #include "ppapi/c/dev/ppb_char_set_dev.h" #include "ppapi/c/dev/ppb_crypto_dev.h" diff --git a/ppapi/tests/all_cpp_includes.h b/ppapi/tests/all_cpp_includes.h index fb72973..6477a76 100644 --- a/ppapi/tests/all_cpp_includes.h +++ b/ppapi/tests/all_cpp_includes.h @@ -15,24 +15,17 @@ #include "ppapi/cpp/compositor.h" #include "ppapi/cpp/compositor_layer.h" #include "ppapi/cpp/core.h" -#include "ppapi/cpp/dev/alarms_dev.h" -#include "ppapi/cpp/dev/array_dev.h" #include "ppapi/cpp/dev/buffer_dev.h" #include "ppapi/cpp/dev/device_ref_dev.h" #include "ppapi/cpp/dev/file_chooser_dev.h" #include "ppapi/cpp/dev/font_dev.h" #include "ppapi/cpp/dev/ime_input_event_dev.h" -#include "ppapi/cpp/dev/may_own_ptr_dev.h" #include "ppapi/cpp/dev/memory_dev.h" -#include "ppapi/cpp/dev/optional_dev.h" #include "ppapi/cpp/dev/printing_dev.h" #include "ppapi/cpp/dev/scriptable_object_deprecated.h" #include "ppapi/cpp/dev/scrollbar_dev.h" #include "ppapi/cpp/dev/selection_dev.h" -#include "ppapi/cpp/dev/string_wrapper_dev.h" -#include "ppapi/cpp/dev/struct_wrapper_output_traits_dev.h" #include "ppapi/cpp/dev/text_input_dev.h" -#include "ppapi/cpp/dev/to_c_type_converter_dev.h" #include "ppapi/cpp/dev/url_util_dev.h" #include "ppapi/cpp/dev/video_decoder_dev.h" #include "ppapi/cpp/dev/view_dev.h" diff --git a/ppapi/thunk/extensions_common_api.h b/ppapi/thunk/extensions_common_api.h deleted file mode 100644 index 5afb73f..0000000 --- a/ppapi/thunk/extensions_common_api.h +++ /dev/null @@ -1,44 +0,0 @@ -// Copyright (c) 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_EXTENSIONS_COMMON_API_H_ -#define PPAPI_THUNK_EXTENSIONS_COMMON_API_H_ - -#include <string> -#include <vector> - -#include "base/memory/ref_counted.h" -#include "ppapi/c/pp_var.h" -#include "ppapi/shared_impl/singleton_resource_id.h" -#include "ppapi/shared_impl/tracked_callback.h" -#include "ppapi/thunk/ppapi_thunk_export.h" - -namespace ppapi { -namespace thunk { - -class PPAPI_THUNK_EXPORT ExtensionsCommon_API { - public: - virtual ~ExtensionsCommon_API() {} - - virtual int32_t CallRenderer(const std::string& request_name, - const std::vector<PP_Var>& input_args, - const std::vector<PP_Var*>& output_args, - scoped_refptr<TrackedCallback> callback) = 0; - virtual void PostRenderer(const std::string& request_name, - const std::vector<PP_Var>& args) = 0; - virtual int32_t CallBrowser(const std::string& request_name, - const std::vector<PP_Var>& input_args, - const std::vector<PP_Var*>& output_args, - scoped_refptr<TrackedCallback> callback) = 0; - virtual void PostBrowser(const std::string& request_name, - const std::vector<PP_Var>& args) = 0; - - static const SingletonResourceID kSingletonResourceID = - EXTENSIONS_COMMON_SINGLETON_ID; -}; - -} // namespace thunk -} // namespace ppapi - -#endif // PPAPI_THUNK_EXTENSIONS_COMMON_API_H_ diff --git a/ppapi/thunk/interfaces_ppb_public_dev.h b/ppapi/thunk/interfaces_ppb_public_dev.h index fee736c..2a1612c 100644 --- a/ppapi/thunk/interfaces_ppb_public_dev.h +++ b/ppapi/thunk/interfaces_ppb_public_dev.h @@ -10,7 +10,6 @@ // Map the old dev console interface to the stable one (which is the same) to // keep Flash, etc. working. PROXIED_IFACE("PPB_Console(Dev);0.1", PPB_Console_1_0) -PROXIED_IFACE(PPB_ALARMS_DEV_INTERFACE_0_1, PPB_Alarms_Dev_0_1) PROXIED_IFACE(PPB_CURSOR_CONTROL_DEV_INTERFACE_0_4, PPB_CursorControl_Dev_0_4) PROXIED_IFACE(PPB_FILECHOOSER_DEV_INTERFACE_0_5, PPB_FileChooser_Dev_0_5) PROXIED_IFACE(PPB_FILECHOOSER_DEV_INTERFACE_0_6, PPB_FileChooser_Dev_0_6) diff --git a/ppapi/thunk/ppb_alarms_dev_thunk.cc b/ppapi/thunk/ppb_alarms_dev_thunk.cc deleted file mode 100644 index 2d2ae14..0000000 --- a/ppapi/thunk/ppb_alarms_dev_thunk.cc +++ /dev/null @@ -1,82 +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 "base/logging.h" -#include "ppapi/c/dev/ppb_alarms_dev.h" -#include "ppapi/shared_impl/tracked_callback.h" -#include "ppapi/thunk/enter.h" -#include "ppapi/thunk/extensions_common_api.h" -#include "ppapi/thunk/thunk.h" - -namespace ppapi { -namespace thunk { - -namespace { - -// TODO(yzshen): crbug.com/327197 Implement the thunk. - -void Create(PP_Instance instance, - PP_Var name, - const PP_Alarms_AlarmCreateInfo_Dev* alarm_info) { - NOTIMPLEMENTED(); -} - -int32_t Get(PP_Instance instance, - PP_Var name, - PP_Alarms_Alarm_Dev* alarm, - PP_CompletionCallback callback) { - EnterInstanceAPI<ExtensionsCommon_API> enter(instance, callback); - if (enter.failed()) - return enter.retval(); - - NOTIMPLEMENTED(); - - return enter.SetResult(PP_ERROR_FAILED); -} - -int32_t GetAll(PP_Instance instance, - PP_Alarms_Alarm_Array_Dev* alarms, - PP_ArrayOutput array_allocator, - PP_CompletionCallback callback) { - EnterInstanceAPI<ExtensionsCommon_API> enter(instance, callback); - if (enter.failed()) - return enter.retval(); - - NOTIMPLEMENTED(); - - return enter.SetResult(PP_ERROR_FAILED); -} - -void Clear(PP_Instance instance, PP_Var name) { - NOTIMPLEMENTED(); -} - -void ClearAll(PP_Instance instance) { - NOTIMPLEMENTED(); -} - -uint32_t AddOnAlarmListener(PP_Instance instance, - PP_Alarms_OnAlarm_Dev callback, - void* user_data) { - NOTIMPLEMENTED(); - return 0; -} - -const PPB_Alarms_Dev_0_1 g_ppb_alarms_dev_0_1_thunk = { - &Create, - &Get, - &GetAll, - &Clear, - &ClearAll, - &AddOnAlarmListener -}; - -} // namespace - -const PPB_Alarms_Dev_0_1* GetPPB_Alarms_Dev_0_1_Thunk() { - return &g_ppb_alarms_dev_0_1_thunk; -} - -} // namespace thunk -} // namespace ppapi |