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

Side by Side Diff: components/nacl/renderer/plugin/pnacl_translate_thread.h

Issue 1615523003: PNaCl cleanup: Remove TempFile class and use base::File instead (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Fix Windows Created 4 years, 11 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
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 #ifndef COMPONENTS_NACL_RENDERER_PLUGIN_PNACL_TRANSLATE_THREAD_H_ 5 #ifndef COMPONENTS_NACL_RENDERER_PLUGIN_PNACL_TRANSLATE_THREAD_H_
6 #define COMPONENTS_NACL_RENDERER_PLUGIN_PNACL_TRANSLATE_THREAD_H_ 6 #define COMPONENTS_NACL_RENDERER_PLUGIN_PNACL_TRANSLATE_THREAD_H_
7 7
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include <deque> 10 #include <deque>
11 #include <vector> 11 #include <vector>
12 12
13 #include "base/files/file.h"
13 #include "base/macros.h" 14 #include "base/macros.h"
14 #include "base/memory/scoped_ptr.h" 15 #include "base/memory/scoped_ptr.h"
15 #include "components/nacl/renderer/plugin/plugin_error.h" 16 #include "components/nacl/renderer/plugin/plugin_error.h"
16 #include "native_client/src/shared/platform/nacl_sync_checked.h" 17 #include "native_client/src/shared/platform/nacl_sync_checked.h"
17 #include "native_client/src/shared/platform/nacl_threads.h" 18 #include "native_client/src/shared/platform/nacl_threads.h"
18 #include "ppapi/cpp/completion_callback.h" 19 #include "ppapi/cpp/completion_callback.h"
19 #include "ppapi/proxy/serialized_handle.h" 20 #include "ppapi/proxy/serialized_handle.h"
20 21
21 struct PP_PNaClOptions; 22 struct PP_PNaClOptions;
22 23
23 namespace plugin { 24 namespace plugin {
24 25
25 class NaClSubprocess; 26 class NaClSubprocess;
26 class PnaclCoordinator; 27 class PnaclCoordinator;
27 class TempFile;
28 28
29 class PnaclTranslateThread { 29 class PnaclTranslateThread {
30 public: 30 public:
31 PnaclTranslateThread(); 31 PnaclTranslateThread();
32 ~PnaclTranslateThread(); 32 ~PnaclTranslateThread();
33 33
34 // Set up the state for RunCompile and RunLink. When an error is 34 // Set up the state for RunCompile and RunLink. When an error is
35 // encountered, or RunLink is complete the finish_callback is run 35 // encountered, or RunLink is complete the finish_callback is run
36 // to notify the main thread. 36 // to notify the main thread.
37 void SetupState(const pp::CompletionCallback& finish_callback, 37 void SetupState(const pp::CompletionCallback& finish_callback,
38 NaClSubprocess* compiler_subprocess, 38 NaClSubprocess* compiler_subprocess,
39 NaClSubprocess* ld_subprocess, 39 NaClSubprocess* ld_subprocess,
40 const std::vector<TempFile*>* obj_files, 40 std::vector<base::File>* obj_files,
41 int num_threads, 41 int num_threads,
42 TempFile* nexe_file, 42 base::File* nexe_file,
43 ErrorInfo* error_info, 43 ErrorInfo* error_info,
44 PP_PNaClOptions* pnacl_options, 44 PP_PNaClOptions* pnacl_options,
45 const std::string& architecture_attributes, 45 const std::string& architecture_attributes,
46 PnaclCoordinator* coordinator); 46 PnaclCoordinator* coordinator);
47 47
48 // Create a compile thread and run/command the compiler_subprocess. 48 // Create a compile thread and run/command the compiler_subprocess.
49 // It will continue to run and consume data as it is passed in with PutBytes. 49 // It will continue to run and consume data as it is passed in with PutBytes.
50 // On success, runs compile_finished_callback. 50 // On success, runs compile_finished_callback.
51 // On error, runs finish_callback. 51 // On error, runs finish_callback.
52 // The compiler_subprocess must already be loaded. 52 // The compiler_subprocess must already be loaded.
(...skipping 19 matching lines...) Expand all
72 // Called from the main thread. 72 // Called from the main thread.
73 void EndStream(); 73 void EndStream();
74 74
75 int64_t GetCompileTime() const { return compile_time_; } 75 int64_t GetCompileTime() const { return compile_time_; }
76 76
77 // Returns true if the translation process is initiated via SetupState. 77 // Returns true if the translation process is initiated via SetupState.
78 bool started() const { return coordinator_ != NULL; } 78 bool started() const { return coordinator_ != NULL; }
79 79
80 private: 80 private:
81 ppapi::proxy::SerializedHandle GetHandleForSubprocess( 81 ppapi::proxy::SerializedHandle GetHandleForSubprocess(
82 TempFile* file, int32_t open_flags, base::ProcessId peer_pid); 82 base::File* file, int32_t open_flags, base::ProcessId peer_pid);
83 83
84 // Helper thread entry point for compilation. Takes a pointer to 84 // Helper thread entry point for compilation. Takes a pointer to
85 // PnaclTranslateThread and calls DoCompile(). 85 // PnaclTranslateThread and calls DoCompile().
86 static void WINAPI DoCompileThread(void* arg); 86 static void WINAPI DoCompileThread(void* arg);
87 // Runs the streaming compilation. Called from the helper thread. 87 // Runs the streaming compilation. Called from the helper thread.
88 void DoCompile(); 88 void DoCompile();
89 89
90 // Similar to DoCompile*, but for linking. 90 // Similar to DoCompile*, but for linking.
91 static void WINAPI DoLinkThread(void* arg); 91 static void WINAPI DoLinkThread(void* arg);
92 void DoLink(); 92 void DoLink();
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
131 // Data buffers from FileDownloader are enqueued here to pass from the 131 // Data buffers from FileDownloader are enqueued here to pass from the
132 // main thread to the SRPC thread. Protected by cond_mu_ 132 // main thread to the SRPC thread. Protected by cond_mu_
133 std::deque<std::string> data_buffers_; 133 std::deque<std::string> data_buffers_;
134 // Whether all data has been downloaded and copied to translation thread. 134 // Whether all data has been downloaded and copied to translation thread.
135 // Associated with buffer_cond_ 135 // Associated with buffer_cond_
136 bool done_; 136 bool done_;
137 137
138 int64_t compile_time_; 138 int64_t compile_time_;
139 139
140 // Data about the translation files, owned by the coordinator 140 // Data about the translation files, owned by the coordinator
141 const std::vector<TempFile*>* obj_files_; 141 std::vector<base::File>* obj_files_;
bbudge 2016/01/21 18:37:38 Have you considered making this a const ref? Or is
Mark Seaborn 2016/01/21 19:18:21 I started off keeping the 'const', but it didn't w
142 int num_threads_; 142 int num_threads_;
143 TempFile* nexe_file_; 143 base::File* nexe_file_;
144 ErrorInfo* coordinator_error_info_; 144 ErrorInfo* coordinator_error_info_;
145 PP_PNaClOptions* pnacl_options_; 145 PP_PNaClOptions* pnacl_options_;
146 std::string architecture_attributes_; 146 std::string architecture_attributes_;
147 PnaclCoordinator* coordinator_; 147 PnaclCoordinator* coordinator_;
148 148
149 // These IPC::SyncChannels can only be used and freed by the parent thread. 149 // These IPC::SyncChannels can only be used and freed by the parent thread.
150 scoped_ptr<IPC::SyncChannel> compiler_channel_; 150 scoped_ptr<IPC::SyncChannel> compiler_channel_;
151 scoped_ptr<IPC::SyncChannel> ld_channel_; 151 scoped_ptr<IPC::SyncChannel> ld_channel_;
152 // These IPC::SyncMessageFilters can be used by the child thread. 152 // These IPC::SyncMessageFilters can be used by the child thread.
153 scoped_refptr<IPC::SyncMessageFilter> compiler_channel_filter_; 153 scoped_refptr<IPC::SyncMessageFilter> compiler_channel_filter_;
154 scoped_refptr<IPC::SyncMessageFilter> ld_channel_filter_; 154 scoped_refptr<IPC::SyncMessageFilter> ld_channel_filter_;
155 // PIDs of the subprocesses, needed for copying handles to the subprocess 155 // PIDs of the subprocesses, needed for copying handles to the subprocess
156 // on Windows. These are used by the child thread. 156 // on Windows. These are used by the child thread.
157 base::ProcessId compiler_channel_peer_pid_; 157 base::ProcessId compiler_channel_peer_pid_;
158 base::ProcessId ld_channel_peer_pid_; 158 base::ProcessId ld_channel_peer_pid_;
159 159
160 private: 160 private:
161 DISALLOW_COPY_AND_ASSIGN(PnaclTranslateThread); 161 DISALLOW_COPY_AND_ASSIGN(PnaclTranslateThread);
162 }; 162 };
163 163
164 } 164 }
165 #endif // COMPONENTS_NACL_RENDERER_PLUGIN_PNACL_TRANSLATE_THREAD_H_ 165 #endif // COMPONENTS_NACL_RENDERER_PLUGIN_PNACL_TRANSLATE_THREAD_H_
OLDNEW
« no previous file with comments | « components/nacl/renderer/plugin/pnacl_coordinator.cc ('k') | components/nacl/renderer/plugin/pnacl_translate_thread.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698