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

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

Issue 8585013: Merge definitions of PlatformFileToInt and IntToPlatformFile to one place. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Add PPAPI_SHARED_EXPORT to make component build work. Created 9 years 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
« no previous file with comments | « ppapi/proxy/ppb_audio_proxy.cc ('k') | ppapi/shared_impl/platform_file.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) 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 "base/bind.h" 7 #include "base/bind.h"
8 #include "ppapi/c/pp_errors.h" 8 #include "ppapi/c/pp_errors.h"
9 #include "ppapi/c/trusted/ppb_broker_trusted.h" 9 #include "ppapi/c/trusted/ppb_broker_trusted.h"
10 #include "ppapi/proxy/enter_proxy.h" 10 #include "ppapi/proxy/enter_proxy.h"
11 #include "ppapi/proxy/plugin_dispatcher.h" 11 #include "ppapi/proxy/plugin_dispatcher.h"
12 #include "ppapi/proxy/ppapi_messages.h" 12 #include "ppapi/proxy/ppapi_messages.h"
13 #include "ppapi/shared_impl/platform_file.h"
13 #include "ppapi/thunk/ppb_broker_api.h" 14 #include "ppapi/thunk/ppb_broker_api.h"
14 #include "ppapi/thunk/enter.h" 15 #include "ppapi/thunk/enter.h"
15 #include "ppapi/thunk/resource_creation_api.h" 16 #include "ppapi/thunk/resource_creation_api.h"
16 #include "ppapi/thunk/thunk.h" 17 #include "ppapi/thunk/thunk.h"
17 18
19 using ppapi::IntToPlatformFile;
20 using ppapi::PlatformFileToInt;
18 using ppapi::thunk::PPB_Broker_API; 21 using ppapi::thunk::PPB_Broker_API;
19 22
20 namespace ppapi { 23 namespace ppapi {
21 namespace proxy { 24 namespace proxy {
22 25
23 namespace {
24
25 base::PlatformFile IntToPlatformFile(int32_t handle) {
26 #if defined(OS_WIN)
27 return reinterpret_cast<HANDLE>(static_cast<intptr_t>(handle));
28 #elif defined(OS_POSIX)
29 return handle;
30 #else
31 #error Not implemented.
32 #endif
33 }
34
35 int32_t PlatformFileToInt(base::PlatformFile handle) {
36 #if defined(OS_WIN)
37 return static_cast<int32_t>(reinterpret_cast<intptr_t>(handle));
38 #elif defined(OS_POSIX)
39 return handle;
40 #else
41 #error Not implemented.
42 #endif
43 }
44
45 } // namespace
46
47 class Broker : public PPB_Broker_API, public Resource { 26 class Broker : public PPB_Broker_API, public Resource {
48 public: 27 public:
49 explicit Broker(const HostResource& resource); 28 explicit Broker(const HostResource& resource);
50 virtual ~Broker(); 29 virtual ~Broker();
51 30
52 // Resource overries. 31 // Resource overrides.
53 virtual PPB_Broker_API* AsPPB_Broker_API() OVERRIDE; 32 virtual PPB_Broker_API* AsPPB_Broker_API() OVERRIDE;
54 33
55 // PPB_Broker_API implementation. 34 // PPB_Broker_API implementation.
56 virtual int32_t Connect(PP_CompletionCallback connect_callback) OVERRIDE; 35 virtual int32_t Connect(PP_CompletionCallback connect_callback) OVERRIDE;
57 virtual int32_t GetHandle(int32_t* handle) OVERRIDE; 36 virtual int32_t GetHandle(int32_t* handle) OVERRIDE;
58 37
59 // Called by the proxy when the host side has completed the request. 38 // Called by the proxy when the host side has completed the request.
60 void ConnectComplete(IPC::PlatformFileForTransit socket_handle, 39 void ConnectComplete(IPC::PlatformFileForTransit socket_handle,
61 int32_t result); 40 int32_t result);
62 41
(...skipping 192 matching lines...) Expand 10 before | Expand all | Expand 10 after
255 // The easiest way to clean it up is to just put it in an object 234 // The easiest way to clean it up is to just put it in an object
256 // and then close it. This failure case is not performance critical. 235 // and then close it. This failure case is not performance critical.
257 // The handle could still leak if Send succeeded but the IPC later failed. 236 // The handle could still leak if Send succeeded but the IPC later failed.
258 base::SyncSocket temp_socket( 237 base::SyncSocket temp_socket(
259 IPC::PlatformFileForTransitToPlatformFile(foreign_socket_handle)); 238 IPC::PlatformFileForTransitToPlatformFile(foreign_socket_handle));
260 } 239 }
261 } 240 }
262 241
263 } // namespace proxy 242 } // namespace proxy
264 } // namespace ppapi 243 } // namespace ppapi
OLDNEW
« no previous file with comments | « ppapi/proxy/ppb_audio_proxy.cc ('k') | ppapi/shared_impl/platform_file.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698