OLD | NEW |
| 1 /* -*- c++ -*- */ |
1 /* | 2 /* |
2 * Copyright (c) 2011 The Native Client Authors. All rights reserved. | 3 * 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 | 4 * Use of this source code is governed by a BSD-style license that can be |
4 * found in the LICENSE file. | 5 * found in the LICENSE file. |
5 */ | 6 */ |
6 | 7 |
7 #ifndef NATIVE_CLIENT_SRC_TRUSTED_REVERSE_SERVICE_REVERSE_SERVICE_H_ | 8 #ifndef NATIVE_CLIENT_SRC_TRUSTED_REVERSE_SERVICE_REVERSE_SERVICE_H_ |
8 #define NATIVE_CLIENT_SRC_TRUSTED_REVERSE_SERVICE_REVERSE_SERVICE_H_ | 9 #define NATIVE_CLIENT_SRC_TRUSTED_REVERSE_SERVICE_REVERSE_SERVICE_H_ |
9 | 10 |
10 #include <set> | 11 #include <set> |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
63 | 64 |
64 class ReverseService : public RefCountBase { | 65 class ReverseService : public RefCountBase { |
65 public: | 66 public: |
66 ReverseService(nacl::DescWrapper* conn_cap, ReverseInterface* rif); | 67 ReverseService(nacl::DescWrapper* conn_cap, ReverseInterface* rif); |
67 | 68 |
68 // covariant impl of Ref() | 69 // covariant impl of Ref() |
69 ReverseService* Ref() { // down_cast | 70 ReverseService* Ref() { // down_cast |
70 return reinterpret_cast<ReverseService*>(RefCountBase::Ref()); | 71 return reinterpret_cast<ReverseService*>(RefCountBase::Ref()); |
71 } | 72 } |
72 | 73 |
73 bool Start(); | 74 // Start starts the reverse service by initiating a connection on |
| 75 // the conn_cap and spawning a service thread using the |
| 76 // ReverseInterface rif, both provided in the ctor. |
| 77 // |
| 78 // If |crash_report| is true, then the ReportCrash virtual function |
| 79 // will be invoked when the reverse channel is closed. Typically |
| 80 // this is needed only in one (the "primary" or "bootstrap") |
| 81 // instance of the reverse service, since additional channels |
| 82 // created are often used for and are under application program |
| 83 // control, and the untrusted application should be able to close |
| 84 // those channels without generating a false crash report. |
| 85 bool Start(bool crash_report); |
| 86 |
| 87 bool Start() { |
| 88 return Start(true); |
| 89 } |
74 | 90 |
75 void WaitForServiceThreadsToExit(); | 91 void WaitForServiceThreadsToExit(); |
76 | 92 |
77 void IncrThreadCount(); | 93 void IncrThreadCount(); |
78 void DecrThreadCount(); | 94 void DecrThreadCount(); |
79 | 95 |
80 ReverseInterface* reverse_interface() const { return reverse_interface_; } | 96 ReverseInterface* reverse_interface() const { return reverse_interface_; } |
81 | 97 |
82 protected: | 98 protected: |
83 ~ReverseService(); | 99 ~ReverseService(); |
(...skipping 10 matching lines...) Expand all Loading... |
94 static NaClSrpcHandlerDesc const handlers[]; | 110 static NaClSrpcHandlerDesc const handlers[]; |
95 | 111 |
96 NaClMutex mu_; | 112 NaClMutex mu_; |
97 NaClCondVar cv_; | 113 NaClCondVar cv_; |
98 uint32_t thread_count_; | 114 uint32_t thread_count_; |
99 }; | 115 }; |
100 | 116 |
101 } // namespace nacl | 117 } // namespace nacl |
102 | 118 |
103 #endif | 119 #endif |
OLD | NEW |