Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(256)

Side by Side Diff: ppapi/proxy/extensions_common_resource.cc

Issue 15039008: Add browser resource host for Apps v2 APIs in Pepper. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . Created 7 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « ppapi/proxy/extensions_common_resource.h ('k') | ppapi/thunk/extensions_common_api.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "ppapi/proxy/extensions_common_resource.h" 5 #include "ppapi/proxy/extensions_common_resource.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/bind_helpers.h" 8 #include "base/bind_helpers.h"
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "base/memory/scoped_ptr.h" 10 #include "base/memory/scoped_ptr.h"
11 #include "base/values.h" 11 #include "base/values.h"
12 #include "ppapi/c/pp_errors.h" 12 #include "ppapi/c/pp_errors.h"
13 #include "ppapi/proxy/ppapi_messages.h" 13 #include "ppapi/proxy/ppapi_messages.h"
14 #include "ppapi/proxy/resource_message_params.h" 14 #include "ppapi/proxy/resource_message_params.h"
15 #include "ppapi/shared_impl/tracked_callback.h" 15 #include "ppapi/shared_impl/tracked_callback.h"
16 #include "ppapi/shared_impl/var_value_conversions.h" 16 #include "ppapi/shared_impl/var_value_conversions.h"
17 17
18 namespace ppapi { 18 namespace ppapi {
19 namespace proxy { 19 namespace proxy {
20 20
21 ExtensionsCommonResource::ExtensionsCommonResource(Connection connection, 21 ExtensionsCommonResource::ExtensionsCommonResource(Connection connection,
22 PP_Instance instance) 22 PP_Instance instance)
23 : PluginResource(connection, instance) { 23 : PluginResource(connection, instance) {
24 SendCreate(RENDERER, PpapiHostMsg_ExtensionsCommon_Create()); 24 SendCreate(RENDERER, PpapiHostMsg_ExtensionsCommon_Create());
25 SendCreate(BROWSER, PpapiHostMsg_ExtensionsCommon_Create());
25 } 26 }
26 27
27 ExtensionsCommonResource::~ExtensionsCommonResource() { 28 ExtensionsCommonResource::~ExtensionsCommonResource() {
28 } 29 }
29 30
30 thunk::ExtensionsCommon_API* 31 thunk::ExtensionsCommon_API*
31 ExtensionsCommonResource::AsExtensionsCommon_API() { 32 ExtensionsCommonResource::AsExtensionsCommon_API() {
32 return this; 33 return this;
33 } 34 }
34 35
35 int32_t ExtensionsCommonResource::Call( 36 int32_t ExtensionsCommonResource::CallRenderer(
36 const std::string& request_name, 37 const std::string& request_name,
37 const std::vector<PP_Var>& input_args, 38 const std::vector<PP_Var>& input_args,
38 const std::vector<PP_Var*>& output_args, 39 const std::vector<PP_Var*>& output_args,
40 scoped_refptr<TrackedCallback> callback) {
41 return CommonCall(RENDERER, request_name, input_args, output_args, callback);
42 }
43
44 void ExtensionsCommonResource::PostRenderer(const std::string& request_name,
45 const std::vector<PP_Var>& args) {
46 CommonPost(RENDERER, request_name, args);
47 }
48
49 int32_t ExtensionsCommonResource::CallBrowser(
50 const std::string& request_name,
51 const std::vector<PP_Var>& input_args,
52 const std::vector<PP_Var*>& output_args,
53 scoped_refptr<TrackedCallback> callback) {
54 return CommonCall(BROWSER, request_name, input_args, output_args, callback);
55 }
56
57 void ExtensionsCommonResource::PostBrowser(const std::string& request_name,
58 const std::vector<PP_Var>& args) {
59 CommonPost(BROWSER, request_name, args);
60 }
61
62 int32_t ExtensionsCommonResource::CommonCall(
63 Destination dest,
64 const std::string& request_name,
65 const std::vector<PP_Var>& input_args,
66 const std::vector<PP_Var*>& output_args,
39 scoped_refptr<TrackedCallback> callback) { 67 scoped_refptr<TrackedCallback> callback) {
40 // TODO(yzshen): CreateValueFromVar() doesn't generate null fields for 68 // TODO(yzshen): CreateValueFromVar() doesn't generate null fields for
41 // dictionary values. That is the expected behavior for most APIs. If later we 69 // dictionary values. That is the expected behavior for most APIs. If later we
42 // want to support APIs that require to preserve null fields in dictionaries, 70 // want to support APIs that require to preserve null fields in dictionaries,
43 // we should change the behavior to always preserve null fields at the plugin 71 // we should change the behavior to always preserve null fields at the plugin
44 // side, and figure out whether they should be stripped at the renderer side. 72 // side, and figure out whether they should be stripped at the renderer side.
45 scoped_ptr<base::ListValue> input_args_value( 73 scoped_ptr<base::ListValue> input_args_value(
46 CreateListValueFromVarVector(input_args)); 74 CreateListValueFromVarVector(input_args));
47 if (!input_args_value.get()) { 75 if (!input_args_value.get()) {
48 LOG(WARNING) << "Failed to convert PP_Var input arguments."; 76 LOG(WARNING) << "Failed to convert PP_Var input arguments.";
49 return PP_ERROR_BADARGUMENT; 77 return PP_ERROR_BADARGUMENT;
50 } 78 }
51 79
52 PluginResource::Call<PpapiPluginMsg_ExtensionsCommon_CallReply>( 80 PluginResource::Call<PpapiPluginMsg_ExtensionsCommon_CallReply>(
53 RENDERER, 81 dest,
54 PpapiHostMsg_ExtensionsCommon_Call(request_name, *input_args_value), 82 PpapiHostMsg_ExtensionsCommon_Call(request_name, *input_args_value),
55 base::Bind(&ExtensionsCommonResource::OnPluginMsgCallReply, 83 base::Bind(&ExtensionsCommonResource::OnPluginMsgCallReply,
56 base::Unretained(this), output_args, callback)); 84 base::Unretained(this), output_args, callback));
57 return PP_OK_COMPLETIONPENDING; 85 return PP_OK_COMPLETIONPENDING;
58 } 86 }
59 87
60 void ExtensionsCommonResource::Post(const std::string& request_name, 88 void ExtensionsCommonResource::CommonPost(Destination dest,
61 const std::vector<PP_Var>& args) { 89 const std::string& request_name,
90 const std::vector<PP_Var>& args) {
62 scoped_ptr<base::ListValue> args_value(CreateListValueFromVarVector(args)); 91 scoped_ptr<base::ListValue> args_value(CreateListValueFromVarVector(args));
63 if (!args_value.get()) { 92 if (!args_value.get()) {
64 LOG(WARNING) << "Failed to convert PP_Var input arguments."; 93 LOG(WARNING) << "Failed to convert PP_Var input arguments.";
65 return; 94 return;
66 } 95 }
67 96
68 PluginResource::Post( 97 PluginResource::Post(
69 RENDERER, PpapiHostMsg_ExtensionsCommon_Post(request_name, *args_value)); 98 dest, PpapiHostMsg_ExtensionsCommon_Post(request_name, *args_value));
70 } 99 }
71 100
72 void ExtensionsCommonResource::OnPluginMsgCallReply( 101 void ExtensionsCommonResource::OnPluginMsgCallReply(
73 const std::vector<PP_Var*>& output_args, 102 const std::vector<PP_Var*>& output_args,
74 scoped_refptr<TrackedCallback> callback, 103 scoped_refptr<TrackedCallback> callback,
75 const ResourceMessageReplyParams& params, 104 const ResourceMessageReplyParams& params,
76 const base::ListValue& output) { 105 const base::ListValue& output) {
77 // |output_args| may be invalid and shouldn't be accessed if the callback has 106 // |output_args| may be invalid and shouldn't be accessed if the callback has
78 // been called. 107 // been called.
79 if (!TrackedCallback::IsPending(callback)) 108 if (!TrackedCallback::IsPending(callback))
(...skipping 16 matching lines...) Expand all
96 } else { 125 } else {
97 result = PP_ERROR_FAILED; 126 result = PP_ERROR_FAILED;
98 } 127 }
99 } 128 }
100 129
101 callback->Run(result); 130 callback->Run(result);
102 } 131 }
103 132
104 } // namespace proxy 133 } // namespace proxy
105 } // namespace ppapi 134 } // namespace ppapi
OLDNEW
« no previous file with comments | « ppapi/proxy/extensions_common_resource.h ('k') | ppapi/thunk/extensions_common_api.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698