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

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: Created 9 years, 1 month 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
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/thunk/ppb_broker_api.h" 13 #include "ppapi/thunk/ppb_broker_api.h"
14 #include "ppapi/thunk/enter.h" 14 #include "ppapi/thunk/enter.h"
15 #include "ppapi/thunk/resource_creation_api.h" 15 #include "ppapi/thunk/resource_creation_api.h"
16 #include "ppapi/thunk/thunk.h" 16 #include "ppapi/thunk/thunk.h"
17 17
18 using ppapi::thunk::PPB_Broker_API; 18 using ppapi::thunk::PPB_Broker_API;
19 19
20 namespace ppapi { 20 namespace ppapi {
21 namespace proxy { 21 namespace proxy {
22 22
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 { 23 class Broker : public PPB_Broker_API, public Resource {
48 public: 24 public:
49 explicit Broker(const HostResource& resource); 25 explicit Broker(const HostResource& resource);
50 virtual ~Broker(); 26 virtual ~Broker();
51 27
52 // Resource overries. 28 // Resource overries.
53 virtual PPB_Broker_API* AsPPB_Broker_API() OVERRIDE; 29 virtual PPB_Broker_API* AsPPB_Broker_API() OVERRIDE;
54 30
55 // PPB_Broker_API implementation. 31 // PPB_Broker_API implementation.
56 virtual int32_t Connect(PP_CompletionCallback connect_callback) OVERRIDE; 32 virtual int32_t Connect(PP_CompletionCallback connect_callback) OVERRIDE;
(...skipping 198 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 231 // 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. 232 // 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. 233 // The handle could still leak if Send succeeded but the IPC later failed.
258 base::SyncSocket temp_socket( 234 base::SyncSocket temp_socket(
259 IPC::PlatformFileForTransitToPlatformFile(foreign_socket_handle)); 235 IPC::PlatformFileForTransitToPlatformFile(foreign_socket_handle));
260 } 236 }
261 } 237 }
262 238
263 } // namespace proxy 239 } // namespace proxy
264 } // namespace ppapi 240 } // namespace ppapi
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698