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

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

Issue 10815080: Add an interface for nacl to create delete-on-close temp files, (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: revert buildbot hack Created 8 years, 4 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
OLDNEW
1 /* -*- c++ -*- */ 1 /* -*- c++ -*- */
2 /* 2 /*
3 * Copyright (c) 2012 The Chromium Authors. All rights reserved. 3 * Copyright (c) 2012 The Chromium Authors. All rights reserved.
4 * 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
5 * found in the LICENSE file. 5 * found in the LICENSE file.
6 */ 6 */
7 7
8 // A class containing information regarding a socket connection to a 8 // A class containing information regarding a socket connection to a
9 // service runtime instance. 9 // service runtime instance.
10 10
11 #ifndef NATIVE_CLIENT_SRC_TRUSTED_PLUGIN_SERVICE_RUNTIME_H_ 11 #ifndef NATIVE_CLIENT_SRC_TRUSTED_PLUGIN_SERVICE_RUNTIME_H_
12 #define NATIVE_CLIENT_SRC_TRUSTED_PLUGIN_SERVICE_RUNTIME_H_ 12 #define NATIVE_CLIENT_SRC_TRUSTED_PLUGIN_SERVICE_RUNTIME_H_
13 13
14 #include <map>
15
14 #include "native_client/src/include/nacl_macros.h" 16 #include "native_client/src/include/nacl_macros.h"
15 #include "native_client/src/include/nacl_scoped_ptr.h" 17 #include "native_client/src/include/nacl_scoped_ptr.h"
16 #include "native_client/src/include/nacl_string.h" 18 #include "native_client/src/include/nacl_string.h"
17 #include "native_client/src/shared/platform/nacl_sync.h" 19 #include "native_client/src/shared/platform/nacl_sync.h"
18 #include "native_client/src/shared/srpc/nacl_srpc.h" 20 #include "native_client/src/shared/srpc/nacl_srpc.h"
19 #include "native_client/src/trusted/desc/nacl_desc_wrapper.h" 21 #include "native_client/src/trusted/desc/nacl_desc_wrapper.h"
20 #include "native_client/src/trusted/nonnacl_util/sel_ldr_launcher.h" 22 #include "native_client/src/trusted/nonnacl_util/sel_ldr_launcher.h"
21 #include "native_client/src/trusted/plugin/utility.h" 23 #include "native_client/src/trusted/plugin/utility.h"
22 #include "native_client/src/trusted/reverse_service/reverse_service.h" 24 #include "native_client/src/trusted/reverse_service/reverse_service.h"
23 #include "native_client/src/trusted/weak_ref/weak_ref.h" 25 #include "native_client/src/trusted/weak_ref/weak_ref.h"
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
83 bool* op_result) 85 bool* op_result)
84 : desc(desc_to_close), 86 : desc(desc_to_close),
85 op_complete_ptr(op_complete), 87 op_complete_ptr(op_complete),
86 op_result_ptr(op_result) {} 88 op_result_ptr(op_result) {}
87 89
88 int32_t desc; 90 int32_t desc;
89 bool* op_complete_ptr; 91 bool* op_complete_ptr;
90 bool* op_result_ptr; 92 bool* op_result_ptr;
91 }; 93 };
92 94
95 enum QuotaDataType {
96 PepperQuotaType,
97 TempQuotaType
98 };
99
100 struct QuotaData {
101 QuotaData(QuotaDataType type_, PP_Resource resource_)
102 : type(type_), resource(resource_) {}
103 QuotaData()
104 : type(PepperQuotaType), resource(0) {}
105
106 QuotaDataType type;
107 PP_Resource resource;
108 };
109
93 struct QuotaRequest { 110 struct QuotaRequest {
94 public: 111 public:
95 QuotaRequest(PP_Resource file_resource, 112 QuotaRequest(QuotaData quota_data,
96 int64_t start_offset, 113 int64_t start_offset,
97 int64_t quota_bytes_requested, 114 int64_t quota_bytes_requested,
98 int64_t* quota_bytes_granted, 115 int64_t* quota_bytes_granted,
99 bool* op_complete) 116 bool* op_complete)
100 : resource(file_resource), 117 : data(quota_data),
101 offset(start_offset), 118 offset(start_offset),
102 bytes_requested(quota_bytes_requested), 119 bytes_requested(quota_bytes_requested),
103 bytes_granted(quota_bytes_granted), 120 bytes_granted(quota_bytes_granted),
104 op_complete_ptr(op_complete) { } 121 op_complete_ptr(op_complete) { }
105 122
106 PP_Resource resource; 123 QuotaData data;
107 int64_t offset; 124 int64_t offset;
108 int64_t bytes_requested; 125 int64_t bytes_requested;
109 int64_t* bytes_granted; 126 int64_t* bytes_granted;
110 bool* op_complete_ptr; 127 bool* op_complete_ptr;
111 }; 128 };
112 129
113 // Do not invoke from the main thread, since the main methods will 130 // Do not invoke from the main thread, since the main methods will
114 // invoke CallOnMainThread and then wait on a condvar for the task to 131 // invoke CallOnMainThread and then wait on a condvar for the task to
115 // complete: if invoked from the main thread, the main method not 132 // complete: if invoked from the main thread, the main method not
116 // returning (and thus unblocking the main thread) means that the 133 // returning (and thus unblocking the main thread) means that the
(...skipping 27 matching lines...) Expand all
144 virtual void ReportCrash(); 161 virtual void ReportCrash();
145 162
146 virtual void ReportExitStatus(int exit_status); 163 virtual void ReportExitStatus(int exit_status);
147 164
148 virtual int64_t RequestQuotaForWrite(nacl::string file_id, 165 virtual int64_t RequestQuotaForWrite(nacl::string file_id,
149 int64_t offset, 166 int64_t offset,
150 int64_t bytes_to_write); 167 int64_t bytes_to_write);
151 168
152 void AddQuotaManagedFile(const nacl::string& file_id, 169 void AddQuotaManagedFile(const nacl::string& file_id,
153 const pp::FileIO& file_io); 170 const pp::FileIO& file_io);
171 void AddTempQuotaManagedFile(const nacl::string& file_id);
154 172
155 protected: 173 protected:
156 virtual void Log_MainThreadContinuation(LogToJavaScriptConsoleResource* p, 174 virtual void Log_MainThreadContinuation(LogToJavaScriptConsoleResource* p,
157 int32_t err); 175 int32_t err);
158 176
159 virtual void PostMessage_MainThreadContinuation(PostMessageResource* p, 177 virtual void PostMessage_MainThreadContinuation(PostMessageResource* p,
160 int32_t err); 178 int32_t err);
161 179
162 virtual void OpenManifestEntry_MainThreadContinuation( 180 virtual void OpenManifestEntry_MainThreadContinuation(
163 OpenManifestEntryResource* p, 181 OpenManifestEntryResource* p,
(...skipping 20 matching lines...) Expand all
184 int32_t err); 202 int32_t err);
185 203
186 private: 204 private:
187 nacl::WeakRefAnchor* anchor_; // holds a ref 205 nacl::WeakRefAnchor* anchor_; // holds a ref
188 Plugin* plugin_; // value may be copied, but should be used only in 206 Plugin* plugin_; // value may be copied, but should be used only in
189 // main thread in WeakRef-protected callbacks. 207 // main thread in WeakRef-protected callbacks.
190 const Manifest* manifest_; 208 const Manifest* manifest_;
191 ServiceRuntime* service_runtime_; 209 ServiceRuntime* service_runtime_;
192 NaClMutex mu_; 210 NaClMutex mu_;
193 NaClCondVar cv_; 211 NaClCondVar cv_;
194 std::map<int64_t, PP_Resource> quota_map_; 212 std::map<int64_t, QuotaData> quota_map_;
195 bool shutting_down_; 213 bool shutting_down_;
196 214
197 nacl::scoped_ptr<PnaclCoordinator> pnacl_coordinator_; 215 nacl::scoped_ptr<PnaclCoordinator> pnacl_coordinator_;
198 216
199 pp::CompletionCallback init_done_cb_; 217 pp::CompletionCallback init_done_cb_;
200 pp::CompletionCallback crash_cb_; 218 pp::CompletionCallback crash_cb_;
201 }; 219 };
202 220
203 // ServiceRuntime abstracts a NativeClient sel_ldr instance. 221 // ServiceRuntime abstracts a NativeClient sel_ldr instance.
204 class ServiceRuntime { 222 class ServiceRuntime {
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
256 274
257 PluginReverseInterface* rev_interface_; 275 PluginReverseInterface* rev_interface_;
258 276
259 NaClMutex mu_; 277 NaClMutex mu_;
260 int exit_status_; 278 int exit_status_;
261 }; 279 };
262 280
263 } // namespace plugin 281 } // namespace plugin
264 282
265 #endif // NATIVE_CLIENT_SRC_TRUSTED_PLUGIN_SERVICE_RUNTIME_H_ 283 #endif // NATIVE_CLIENT_SRC_TRUSTED_PLUGIN_SERVICE_RUNTIME_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698