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

Side by Side Diff: content/renderer/pepper/ppb_broker_impl.cc

Issue 20777009: A few more cleanups to the pepper code. Dispatch IPCs in the sockets implementations directly by ha… (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: fix browsertest Created 7 years, 4 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 | « content/renderer/pepper/ppb_audio_impl.cc ('k') | content/renderer/pepper/ppb_buffer_impl.cc » ('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) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 "content/renderer/pepper/ppb_broker_impl.h" 5 #include "content/renderer/pepper/ppb_broker_impl.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "content/renderer/pepper/common.h" 8 #include "content/renderer/pepper/common.h"
9 #include "content/renderer/pepper/host_globals.h"
9 #include "content/renderer/pepper/pepper_broker.h" 10 #include "content/renderer/pepper/pepper_broker.h"
10 #include "content/renderer/pepper/pepper_helper_impl.h" 11 #include "content/renderer/pepper/pepper_helper_impl.h"
11 #include "content/renderer/pepper/pepper_plugin_instance_impl.h" 12 #include "content/renderer/pepper/pepper_plugin_instance_impl.h"
12 #include "content/renderer/pepper/plugin_module.h" 13 #include "content/renderer/pepper/plugin_module.h"
13 #include "content/renderer/pepper/resource_helper.h"
14 #include "ppapi/c/pp_errors.h" 14 #include "ppapi/c/pp_errors.h"
15 #include "ppapi/shared_impl/platform_file.h" 15 #include "ppapi/shared_impl/platform_file.h"
16 #include "third_party/WebKit/public/web/WebDocument.h" 16 #include "third_party/WebKit/public/web/WebDocument.h"
17 #include "third_party/WebKit/public/web/WebElement.h" 17 #include "third_party/WebKit/public/web/WebElement.h"
18 #include "third_party/WebKit/public/web/WebPluginContainer.h" 18 #include "third_party/WebKit/public/web/WebPluginContainer.h"
19 19
20 using ppapi::PlatformFileToInt; 20 using ppapi::PlatformFileToInt;
21 using ppapi::thunk::PPB_Broker_API; 21 using ppapi::thunk::PPB_Broker_API;
22 using ppapi::TrackedCallback; 22 using ppapi::TrackedCallback;
23 23
(...skipping 25 matching lines...) Expand all
49 int32_t PPB_Broker_Impl::Connect( 49 int32_t PPB_Broker_Impl::Connect(
50 scoped_refptr<TrackedCallback> connect_callback) { 50 scoped_refptr<TrackedCallback> connect_callback) {
51 // TODO(ddorwin): Return PP_ERROR_FAILED if plugin is in-process. 51 // TODO(ddorwin): Return PP_ERROR_FAILED if plugin is in-process.
52 52
53 if (broker_) { 53 if (broker_) {
54 // May only be called once. 54 // May only be called once.
55 return PP_ERROR_FAILED; 55 return PP_ERROR_FAILED;
56 } 56 }
57 57
58 PepperPluginInstanceImpl* plugin_instance = 58 PepperPluginInstanceImpl* plugin_instance =
59 ResourceHelper::GetPluginInstance(this); 59 HostGlobals::Get()->GetInstance(pp_instance());
60 if (!plugin_instance) 60 if (!plugin_instance)
61 return PP_ERROR_FAILED; 61 return PP_ERROR_FAILED;
62 62
63 // The callback must be populated now in case we are connected to the broker 63 // The callback must be populated now in case we are connected to the broker
64 // and BrokerConnected is called before ConnectToBroker returns. 64 // and BrokerConnected is called before ConnectToBroker returns.
65 // Because it must be created now, it must be aborted and cleared if 65 // Because it must be created now, it must be aborted and cleared if
66 // ConnectToBroker fails. 66 // ConnectToBroker fails.
67 connect_callback_ = connect_callback; 67 connect_callback_ = connect_callback;
68 68
69 broker_ = plugin_instance->helper()->ConnectToBroker(this); 69 broker_ = plugin_instance->helper()->ConnectToBroker(this);
70 if (!broker_) { 70 if (!broker_) {
71 connect_callback_->Abort(); 71 connect_callback_->Abort();
72 return PP_ERROR_FAILED; 72 return PP_ERROR_FAILED;
73 } 73 }
74 74
75 return PP_OK_COMPLETIONPENDING; 75 return PP_OK_COMPLETIONPENDING;
76 } 76 }
77 77
78 int32_t PPB_Broker_Impl::GetHandle(int32_t* handle) { 78 int32_t PPB_Broker_Impl::GetHandle(int32_t* handle) {
79 if (pipe_handle_ == PlatformFileToInt(base::kInvalidPlatformFileValue)) 79 if (pipe_handle_ == PlatformFileToInt(base::kInvalidPlatformFileValue))
80 return PP_ERROR_FAILED; // Handle not set yet. 80 return PP_ERROR_FAILED; // Handle not set yet.
81 *handle = pipe_handle_; 81 *handle = pipe_handle_;
82 return PP_OK; 82 return PP_OK;
83 } 83 }
84 84
85 GURL PPB_Broker_Impl::GetDocumentUrl() { 85 GURL PPB_Broker_Impl::GetDocumentUrl() {
86 PepperPluginInstanceImpl* plugin_instance = 86 PepperPluginInstanceImpl* plugin_instance =
87 ResourceHelper::GetPluginInstance(this); 87 HostGlobals::Get()->GetInstance(pp_instance());
88 return plugin_instance->container()->element().document().url(); 88 return plugin_instance->container()->element().document().url();
89 } 89 }
90 90
91 // Transfers ownership of the handle to the plugin. 91 // Transfers ownership of the handle to the plugin.
92 void PPB_Broker_Impl::BrokerConnected(int32_t handle, int32_t result) { 92 void PPB_Broker_Impl::BrokerConnected(int32_t handle, int32_t result) {
93 DCHECK(pipe_handle_ == 93 DCHECK(pipe_handle_ ==
94 PlatformFileToInt(base::kInvalidPlatformFileValue)); 94 PlatformFileToInt(base::kInvalidPlatformFileValue));
95 DCHECK(result == PP_OK || 95 DCHECK(result == PP_OK ||
96 handle == PlatformFileToInt(base::kInvalidPlatformFileValue)); 96 handle == PlatformFileToInt(base::kInvalidPlatformFileValue));
97 97
98 pipe_handle_ = handle; 98 pipe_handle_ = handle;
99 99
100 // Synchronous calls are not supported. 100 // Synchronous calls are not supported.
101 DCHECK(TrackedCallback::IsPending(connect_callback_)); 101 DCHECK(TrackedCallback::IsPending(connect_callback_));
102 102
103 connect_callback_->Run(result); 103 connect_callback_->Run(result);
104 } 104 }
105 105
106 } // namespace content 106 } // namespace content
OLDNEW
« no previous file with comments | « content/renderer/pepper/ppb_audio_impl.cc ('k') | content/renderer/pepper/ppb_buffer_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698