| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/ppb_broker_proxy.h" | 5 #include "ppapi/proxy/ppb_broker_proxy.h" |
| 6 | 6 |
| 7 #include "ppapi/c/pp_errors.h" | 7 #include "ppapi/c/pp_errors.h" |
| 8 #include "ppapi/c/trusted/ppb_broker_trusted.h" | 8 #include "ppapi/c/trusted/ppb_broker_trusted.h" |
| 9 #include "ppapi/proxy/plugin_dispatcher.h" | 9 #include "ppapi/proxy/plugin_dispatcher.h" |
| 10 #include "ppapi/proxy/plugin_resource.h" | 10 #include "ppapi/proxy/plugin_resource.h" |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 45 | 45 |
| 46 } // namespace | 46 } // namespace |
| 47 | 47 |
| 48 class Broker : public ppapi::thunk::PPB_Broker_API, | 48 class Broker : public ppapi::thunk::PPB_Broker_API, |
| 49 public PluginResource { | 49 public PluginResource { |
| 50 public: | 50 public: |
| 51 explicit Broker(const HostResource& resource); | 51 explicit Broker(const HostResource& resource); |
| 52 virtual ~Broker(); | 52 virtual ~Broker(); |
| 53 | 53 |
| 54 // ResourceObjectBase overries. | 54 // ResourceObjectBase overries. |
| 55 virtual ppapi::thunk::PPB_Broker_API* AsPPB_Broker_API() OVERRIDE; | 55 virtual ppapi::thunk::PPB_Broker_API* AsBroker_API() OVERRIDE; |
| 56 | 56 |
| 57 // PPB_Broker_API implementation. | 57 // PPB_Broker_API implementation. |
| 58 virtual int32_t Connect(PP_CompletionCallback connect_callback) OVERRIDE; | 58 virtual int32_t Connect(PP_CompletionCallback connect_callback) OVERRIDE; |
| 59 virtual int32_t GetHandle(int32_t* handle) OVERRIDE; | 59 virtual int32_t GetHandle(int32_t* handle) OVERRIDE; |
| 60 | 60 |
| 61 // Called by the proxy when the host side has completed the request. | 61 // Called by the proxy when the host side has completed the request. |
| 62 void ConnectComplete(IPC::PlatformFileForTransit socket_handle, | 62 void ConnectComplete(IPC::PlatformFileForTransit socket_handle, |
| 63 int32_t result); | 63 int32_t result); |
| 64 | 64 |
| 65 private: | 65 private: |
| (...skipping 22 matching lines...) Expand all Loading... |
| 88 // TODO(brettw) the callbacks at this level should be refactored with a | 88 // TODO(brettw) the callbacks at this level should be refactored with a |
| 89 // more automatic tracking system like we have in the renderer. | 89 // more automatic tracking system like we have in the renderer. |
| 90 MessageLoop::current()->PostTask(FROM_HERE, NewRunnableFunction( | 90 MessageLoop::current()->PostTask(FROM_HERE, NewRunnableFunction( |
| 91 current_connect_callback_.func, current_connect_callback_.user_data, | 91 current_connect_callback_.func, current_connect_callback_.user_data, |
| 92 static_cast<int32_t>(PP_ERROR_ABORTED))); | 92 static_cast<int32_t>(PP_ERROR_ABORTED))); |
| 93 } | 93 } |
| 94 | 94 |
| 95 socket_handle_ = base::kInvalidPlatformFileValue; | 95 socket_handle_ = base::kInvalidPlatformFileValue; |
| 96 } | 96 } |
| 97 | 97 |
| 98 ppapi::thunk::PPB_Broker_API* Broker::AsPPB_Broker_API() { | 98 ppapi::thunk::PPB_Broker_API* Broker::AsBroker_API() { |
| 99 return this; | 99 return this; |
| 100 } | 100 } |
| 101 | 101 |
| 102 int32_t Broker::Connect(PP_CompletionCallback connect_callback) { | 102 int32_t Broker::Connect(PP_CompletionCallback connect_callback) { |
| 103 if (!connect_callback.func) { | 103 if (!connect_callback.func) { |
| 104 // Synchronous calls are not supported. | 104 // Synchronous calls are not supported. |
| 105 return PP_ERROR_BADARGUMENT; | 105 return PP_ERROR_BADARGUMENT; |
| 106 } | 106 } |
| 107 | 107 |
| 108 if (current_connect_callback_.func) | 108 if (current_connect_callback_.func) |
| (...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 272 // The easiest way to clean it up is to just put it in an object | 272 // The easiest way to clean it up is to just put it in an object |
| 273 // and then close it. This failure case is not performance critical. | 273 // and then close it. This failure case is not performance critical. |
| 274 // The handle could still leak if Send succeeded but the IPC later failed. | 274 // The handle could still leak if Send succeeded but the IPC later failed. |
| 275 base::SyncSocket temp_socket( | 275 base::SyncSocket temp_socket( |
| 276 IPC::PlatformFileForTransitToPlatformFile(foreign_socket_handle)); | 276 IPC::PlatformFileForTransitToPlatformFile(foreign_socket_handle)); |
| 277 } | 277 } |
| 278 } | 278 } |
| 279 | 279 |
| 280 } // namespace proxy | 280 } // namespace proxy |
| 281 } // namespace pp | 281 } // namespace pp |
| OLD | NEW |