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

Side by Side Diff: remoting/host/plugin/daemon_controller_linux.cc

Issue 10537182: The user's consent to crash dumps reporting can now be set via the UI (Windows only). The checkbox … (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebased Created 8 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 | « remoting/host/plugin/daemon_controller.h ('k') | remoting/host/plugin/daemon_controller_mac.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 // 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 #include "remoting/host/plugin/daemon_controller.h" 5 #include "remoting/host/plugin/daemon_controller.h"
6 6
7 #include <unistd.h> 7 #include <unistd.h>
8 8
9 #include "base/basictypes.h" 9 #include "base/basictypes.h"
10 #include "base/bind.h" 10 #include "base/bind.h"
11 #include "base/command_line.h" 11 #include "base/command_line.h"
12 #include "base/compiler_specific.h" 12 #include "base/compiler_specific.h"
13 #include "base/environment.h" 13 #include "base/environment.h"
14 #include "base/file_path.h" 14 #include "base/file_path.h"
15 #include "base/file_util.h" 15 #include "base/file_util.h"
16 #include "base/json/json_writer.h" 16 #include "base/json/json_writer.h"
17 #include "base/logging.h" 17 #include "base/logging.h"
18 #include "base/md5.h" 18 #include "base/md5.h"
19 #include "base/process_util.h" 19 #include "base/process_util.h"
20 #include "base/string_number_conversions.h" 20 #include "base/string_number_conversions.h"
21 #include "base/string_split.h" 21 #include "base/string_split.h"
22 #include "base/string_util.h" 22 #include "base/string_util.h"
23 #include "base/threading/thread.h" 23 #include "base/threading/thread.h"
24 #include "base/values.h" 24 #include "base/values.h"
25 #include "net/base/net_util.h" 25 #include "net/base/net_util.h"
26 #include "remoting/host/host_config.h" 26 #include "remoting/host/host_config.h"
27 #include "remoting/host/json_host_config.h" 27 #include "remoting/host/json_host_config.h"
28 #include "remoting/host/usage_stats_consent.h"
28 29
29 namespace remoting { 30 namespace remoting {
30 31
31 namespace { 32 namespace {
32 33
33 const char kDaemonScript[] = "me2me_virtual_host.py"; 34 const char kDaemonScript[] = "me2me_virtual_host.py";
34 const int64 kDaemonTimeoutMs = 5000; 35 const int64 kDaemonTimeoutMs = 5000;
35 36
36 std::string GetMd5(const std::string& value) { 37 std::string GetMd5(const std::string& value) {
37 base::MD5Context ctx; 38 base::MD5Context ctx;
(...skipping 14 matching lines...) Expand all
52 // Rewrite this code to solve these two problems. 53 // Rewrite this code to solve these two problems.
53 // http://crbug.com/120950 . 54 // http://crbug.com/120950 .
54 class DaemonControllerLinux : public remoting::DaemonController { 55 class DaemonControllerLinux : public remoting::DaemonController {
55 public: 56 public:
56 DaemonControllerLinux(); 57 DaemonControllerLinux();
57 58
58 virtual State GetState() OVERRIDE; 59 virtual State GetState() OVERRIDE;
59 virtual void GetConfig(const GetConfigCallback& callback) OVERRIDE; 60 virtual void GetConfig(const GetConfigCallback& callback) OVERRIDE;
60 virtual void SetConfigAndStart( 61 virtual void SetConfigAndStart(
61 scoped_ptr<base::DictionaryValue> config, 62 scoped_ptr<base::DictionaryValue> config,
62 const CompletionCallback& done_callback) OVERRIDE; 63 bool consent,
64 const CompletionCallback& done) OVERRIDE;
63 virtual void UpdateConfig(scoped_ptr<base::DictionaryValue> config, 65 virtual void UpdateConfig(scoped_ptr<base::DictionaryValue> config,
64 const CompletionCallback& done_callback) OVERRIDE; 66 const CompletionCallback& done_callback) OVERRIDE;
65 virtual void Stop(const CompletionCallback& done_callback) OVERRIDE; 67 virtual void Stop(const CompletionCallback& done_callback) OVERRIDE;
66 virtual void SetWindow(void* window_handle) OVERRIDE; 68 virtual void SetWindow(void* window_handle) OVERRIDE;
67 virtual void GetVersion(const GetVersionCallback& done_callback) OVERRIDE; 69 virtual void GetVersion(const GetVersionCallback& done_callback) OVERRIDE;
70 virtual void GetUsageStatsConsent(
71 const GetUsageStatsConsentCallback& done) OVERRIDE;
68 72
69 private: 73 private:
70 FilePath GetConfigPath(); 74 FilePath GetConfigPath();
71 75
72 void DoGetConfig(const GetConfigCallback& callback); 76 void DoGetConfig(const GetConfigCallback& callback);
73 void DoSetConfigAndStart(scoped_ptr<base::DictionaryValue> config, 77 void DoSetConfigAndStart(scoped_ptr<base::DictionaryValue> config,
74 const CompletionCallback& done_callback); 78 const CompletionCallback& done);
75 void DoUpdateConfig(scoped_ptr<base::DictionaryValue> config, 79 void DoUpdateConfig(scoped_ptr<base::DictionaryValue> config,
76 const CompletionCallback& done_callback); 80 const CompletionCallback& done_callback);
77 void DoStop(const CompletionCallback& done_callback); 81 void DoStop(const CompletionCallback& done_callback);
78 82
79 base::Thread file_io_thread_; 83 base::Thread file_io_thread_;
80 84
81 DISALLOW_COPY_AND_ASSIGN(DaemonControllerLinux); 85 DISALLOW_COPY_AND_ASSIGN(DaemonControllerLinux);
82 }; 86 };
83 87
84 DaemonControllerLinux::DaemonControllerLinux() 88 DaemonControllerLinux::DaemonControllerLinux()
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
152 return remoting::DaemonController::STATE_STOPPED; 156 return remoting::DaemonController::STATE_STOPPED;
153 } 157 }
154 } 158 }
155 159
156 void DaemonControllerLinux::GetConfig(const GetConfigCallback& callback) { 160 void DaemonControllerLinux::GetConfig(const GetConfigCallback& callback) {
157 // base::Unretained() is safe because we control lifetime of the thread. 161 // base::Unretained() is safe because we control lifetime of the thread.
158 file_io_thread_.message_loop()->PostTask(FROM_HERE, base::Bind( 162 file_io_thread_.message_loop()->PostTask(FROM_HERE, base::Bind(
159 &DaemonControllerLinux::DoGetConfig, base::Unretained(this), callback)); 163 &DaemonControllerLinux::DoGetConfig, base::Unretained(this), callback));
160 } 164 }
161 165
166 void DaemonControllerLinux::GetUsageStatsConsent(
167 const GetUsageStatsConsentCallback& done) {
168 // Crash dump collection is not implemented on Linux yet.
169 // http://crbug.com/130678.
170 done.Run(false, false, false);
171 }
172
162 void DaemonControllerLinux::SetConfigAndStart( 173 void DaemonControllerLinux::SetConfigAndStart(
163 scoped_ptr<base::DictionaryValue> config, 174 scoped_ptr<base::DictionaryValue> config,
164 const CompletionCallback& done_callback) { 175 bool /* consent */,
176 const CompletionCallback& done) {
165 // base::Unretained() is safe because we control lifetime of the thread. 177 // base::Unretained() is safe because we control lifetime of the thread.
166 file_io_thread_.message_loop()->PostTask(FROM_HERE, base::Bind( 178 file_io_thread_.message_loop()->PostTask(FROM_HERE, base::Bind(
167 &DaemonControllerLinux::DoSetConfigAndStart, base::Unretained(this), 179 &DaemonControllerLinux::DoSetConfigAndStart, base::Unretained(this),
168 base::Passed(&config), done_callback)); 180 base::Passed(&config), done));
169 } 181 }
170 182
171 void DaemonControllerLinux::UpdateConfig( 183 void DaemonControllerLinux::UpdateConfig(
172 scoped_ptr<base::DictionaryValue> config, 184 scoped_ptr<base::DictionaryValue> config,
173 const CompletionCallback& done_callback) { 185 const CompletionCallback& done_callback) {
174 file_io_thread_.message_loop()->PostTask(FROM_HERE, base::Bind( 186 file_io_thread_.message_loop()->PostTask(FROM_HERE, base::Bind(
175 &DaemonControllerLinux::DoUpdateConfig, base::Unretained(this), 187 &DaemonControllerLinux::DoUpdateConfig, base::Unretained(this),
176 base::Passed(&config), done_callback)); 188 base::Passed(&config), done_callback));
177 } 189 }
178 190
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
214 } else { 226 } else {
215 result.reset(); // Return NULL in case of error. 227 result.reset(); // Return NULL in case of error.
216 } 228 }
217 } 229 }
218 230
219 callback.Run(result.Pass()); 231 callback.Run(result.Pass());
220 } 232 }
221 233
222 void DaemonControllerLinux::DoSetConfigAndStart( 234 void DaemonControllerLinux::DoSetConfigAndStart(
223 scoped_ptr<base::DictionaryValue> config, 235 scoped_ptr<base::DictionaryValue> config,
224 const CompletionCallback& done_callback) { 236 const CompletionCallback& done) {
225 std::vector<std::string> args; 237 std::vector<std::string> args;
226 args.push_back("--explicit-config"); 238 args.push_back("--explicit-config");
227 std::string config_json; 239 std::string config_json;
228 base::JSONWriter::Write(config.get(), &config_json); 240 base::JSONWriter::Write(config.get(), &config_json);
229 args.push_back(config_json); 241 args.push_back(config_json);
230 std::vector<std::string> no_args; 242 std::vector<std::string> no_args;
231 int exit_code = 0; 243 int exit_code = 0;
232 AsyncResult result; 244 AsyncResult result;
233 if (RunScript(args, &exit_code)) { 245 if (RunScript(args, &exit_code)) {
234 result = (exit_code == 0) ? RESULT_OK : RESULT_FAILED; 246 result = (exit_code == 0) ? RESULT_OK : RESULT_FAILED;
235 } else { 247 } else {
236 result = RESULT_FAILED; 248 result = RESULT_FAILED;
237 } 249 }
238 done_callback.Run(result); 250 done.Run(result);
239 } 251 }
240 252
241 void DaemonControllerLinux::DoUpdateConfig( 253 void DaemonControllerLinux::DoUpdateConfig(
242 scoped_ptr<base::DictionaryValue> config, 254 scoped_ptr<base::DictionaryValue> config,
243 const CompletionCallback& done_callback) { 255 const CompletionCallback& done_callback) {
244 JsonHostConfig config_file(GetConfigPath()); 256 JsonHostConfig config_file(GetConfigPath());
245 if (!config_file.Read()) { 257 if (!config_file.Read()) {
246 done_callback.Run(RESULT_FAILED); 258 done_callback.Run(RESULT_FAILED);
247 } 259 }
248 260
(...skipping 24 matching lines...) Expand all
273 done_callback.Run(result); 285 done_callback.Run(result);
274 } 286 }
275 287
276 } // namespace 288 } // namespace
277 289
278 scoped_ptr<DaemonController> remoting::DaemonController::Create() { 290 scoped_ptr<DaemonController> remoting::DaemonController::Create() {
279 return scoped_ptr<DaemonController>(new DaemonControllerLinux()); 291 return scoped_ptr<DaemonController>(new DaemonControllerLinux());
280 } 292 }
281 293
282 } // namespace remoting 294 } // namespace remoting
OLDNEW
« no previous file with comments | « remoting/host/plugin/daemon_controller.h ('k') | remoting/host/plugin/daemon_controller_mac.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698