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

Side by Side Diff: src/trusted/plugin/service_runtime.h

Issue 7216027: typesafe call-on-main-thread interface. no cast to/from void* required. (Closed) Base URL: svn://svn.chromium.org/native_client/trunk/src/native_client/
Patch Set: '' Created 9 years, 6 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 | « no previous file | src/trusted/plugin/service_runtime.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 /* 1 /*
2 * Copyright (c) 2011 The Native Client Authors. All rights reserved. 2 * Copyright (c) 2011 The Native Client Authors. All rights reserved.
3 * Use of this source code is governed by a BSD-style license that can be 3 * Use of this source code is governed by a BSD-style license that can be
4 * found in the LICENSE file. 4 * found in the LICENSE file.
5 */ 5 */
6 6
7 // A class containing information regarding a socket connection to a 7 // A class containing information regarding a socket connection to a
8 // service runtime instance. 8 // service runtime instance.
9 9
10 #ifndef NATIVE_CLIENT_SRC_TRUSTED_PLUGIN_SERVICE_RUNTIME_H_ 10 #ifndef NATIVE_CLIENT_SRC_TRUSTED_PLUGIN_SERVICE_RUNTIME_H_
11 #define NATIVE_CLIENT_SRC_TRUSTED_PLUGIN_SERVICE_RUNTIME_H_ 11 #define NATIVE_CLIENT_SRC_TRUSTED_PLUGIN_SERVICE_RUNTIME_H_
12 12
13 #include "native_client/src/include/nacl_macros.h" 13 #include "native_client/src/include/nacl_macros.h"
14 #include "native_client/src/include/nacl_string.h" 14 #include "native_client/src/include/nacl_string.h"
15 #include "native_client/src/shared/imc/nacl_imc.h" 15 #include "native_client/src/shared/imc/nacl_imc.h"
16 #include "native_client/src/trusted/reverse_service/reverse_service.h" 16 #include "native_client/src/trusted/reverse_service/reverse_service.h"
17 #include "native_client/src/trusted/plugin/utility.h" 17 #include "native_client/src/trusted/plugin/utility.h"
18 #include "native_client/src/trusted/desc/nacl_desc_wrapper.h" 18 #include "native_client/src/trusted/desc/nacl_desc_wrapper.h"
19 #include "native_client/src/trusted/weak_ref/weak_ref.h" 19 #include "native_client/src/trusted/weak_ref/weak_ref.h"
20 20
21 #include "ppapi/c/pp_errors.h" // for PP_OK
22 #include "ppapi/cpp/completion_callback.h" // for pp::CompletionCallback
23 #include "ppapi/cpp/core.h" // for pp::
24 #include "ppapi/cpp/module.h" // for pp::Module
25
26 namespace nacl { 21 namespace nacl {
27 class DescWrapper; 22 class DescWrapper;
28 struct SelLdrLauncher; 23 struct SelLdrLauncher;
29 } // namespace 24 } // namespace
30 25
31 namespace plugin { 26 namespace plugin {
32 27
33 class BrowserInterface; 28 class BrowserInterface;
34 class ConnectedSocket; 29 class ConnectedSocket;
35 class Plugin; 30 class Plugin;
36 class SocketAddress; 31 class SocketAddress;
37 class SrtSocket; 32 class SrtSocket;
38 class ScriptableHandle; 33 class ScriptableHandle;
39 class ServiceRuntime; 34 class ServiceRuntime;
40 35
41 // a typesafe utility to schedule a completion callback using weak
42 // references
43 template <typename R> bool WeakRefCompletionCallback(
44 nacl::WeakRefAnchor* anchor,
45 int32_t delay_in_milliseconds,
46 void callback_fn(nacl::WeakRef<R>* weak_data, int32_t err),
47 R* raw_data) {
48 nacl::WeakRef<R>* wp = anchor->MakeWeakRef<R>(raw_data);
49 if (wp == NULL) {
50 return false;
51 }
52 pp::CompletionCallback cc(reinterpret_cast<void (*)(void*, int32_t)>(
53 callback_fn),
54 reinterpret_cast<void*>(wp));
55 pp::Module::Get()->core()->CallOnMainThread(
56 delay_in_milliseconds,
57 cc,
58 PP_OK);
59 return true;
60 }
61
62 class PluginReverseInterface: public nacl::ReverseInterface { 36 class PluginReverseInterface: public nacl::ReverseInterface {
63 public: 37 public:
64 PluginReverseInterface(nacl::WeakRefAnchor* anchor, 38 PluginReverseInterface(nacl::WeakRefAnchor* anchor,
65 Plugin* plugin) 39 Plugin* plugin)
66 : anchor_(anchor), 40 : anchor_(anchor),
67 plugin_(plugin) { 41 plugin_(plugin) {
68 } 42 }
69 43
70 virtual ~PluginReverseInterface() {} 44 virtual ~PluginReverseInterface() {}
71 45
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
123 nacl::DescWrapper* async_send_desc_; 97 nacl::DescWrapper* async_send_desc_;
124 98
125 nacl::WeakRefAnchor *anchor_; 99 nacl::WeakRefAnchor *anchor_;
126 100
127 PluginReverseInterface* rev_interface_; 101 PluginReverseInterface* rev_interface_;
128 }; 102 };
129 103
130 } // namespace plugin 104 } // namespace plugin
131 105
132 #endif // NATIVE_CLIENT_SRC_TRUSTED_PLUGIN_SERVICE_RUNTIME_H_ 106 #endif // NATIVE_CLIENT_SRC_TRUSTED_PLUGIN_SERVICE_RUNTIME_H_
OLDNEW
« no previous file with comments | « no previous file | src/trusted/plugin/service_runtime.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698