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

Side by Side Diff: chrome/browser/nacl_host/nacl_process_host.cc

Issue 10383262: RefCounted types should not have public destructors, delegate cleanup (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Make win bot happy Created 8 years, 5 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 | « chrome/browser/nacl_host/nacl_process_host.h ('k') | chrome/browser/policy/policy_service.h » ('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 "chrome/browser/nacl_host/nacl_process_host.h" 5 #include "chrome/browser/nacl_host/nacl_process_host.h"
6 6
7 #include <string> 7 #include <string>
8 #include <vector> 8 #include <vector>
9 9
10 #include "base/bind.h" 10 #include "base/bind.h"
(...skipping 312 matching lines...) Expand 10 before | Expand all | Expand 10 after
323 cmd_line->AppendArgNative(script.value()); 323 cmd_line->AppendArgNative(script.value());
324 } 324 }
325 cmd_line->AppendArg("--args"); 325 cmd_line->AppendArg("--args");
326 const CommandLine::StringVector& argv = line->argv(); 326 const CommandLine::StringVector& argv = line->argv();
327 for (size_t i = 0; i < argv.size(); i++) { 327 for (size_t i = 0; i < argv.size(); i++) {
328 cmd_line->AppendArgNative(argv[i]); 328 cmd_line->AppendArgNative(argv[i]);
329 } 329 }
330 return scoped_ptr<CommandLine>(cmd_line); 330 return scoped_ptr<CommandLine>(cmd_line);
331 } 331 }
332 #elif defined(OS_LINUX) 332 #elif defined(OS_LINUX)
333 namespace { 333 class NaClProcessHost::NaClGdbWatchDelegate
334 class NaClGdbWatchDelegate : public MessageLoopForIO::Watcher { 334 : public MessageLoopForIO::Watcher {
335 public: 335 public:
336 // fd_write_ is used by nacl-gdb via /proc/browser_PID/fd/fd_write_ 336 // fd_write_ is used by nacl-gdb via /proc/browser_PID/fd/fd_write_
337 NaClGdbWatchDelegate(int fd_read, int fd_write, 337 NaClGdbWatchDelegate(int fd_read, int fd_write,
338 const base::Closure& reply) 338 const base::Closure& reply)
339 : fd_read_(fd_read), 339 : fd_read_(fd_read),
340 fd_write_(fd_write), 340 fd_write_(fd_write),
341 reply_(reply) {} 341 reply_(reply) {}
342 342
343 ~NaClGdbWatchDelegate() { 343 ~NaClGdbWatchDelegate() {
344 if (HANDLE_EINTR(close(fd_read_)) != 0) 344 if (HANDLE_EINTR(close(fd_read_)) != 0)
345 DLOG(ERROR) << "close(fd_read_) failed"; 345 DLOG(ERROR) << "close(fd_read_) failed";
346 if (HANDLE_EINTR(close(fd_write_)) != 0) 346 if (HANDLE_EINTR(close(fd_write_)) != 0)
347 DLOG(ERROR) << "close(fd_write_) failed"; 347 DLOG(ERROR) << "close(fd_write_) failed";
348 } 348 }
349 349
350 virtual void OnFileCanReadWithoutBlocking(int fd) OVERRIDE; 350 virtual void OnFileCanReadWithoutBlocking(int fd) OVERRIDE;
351 virtual void OnFileCanWriteWithoutBlocking(int fd) OVERRIDE {} 351 virtual void OnFileCanWriteWithoutBlocking(int fd) OVERRIDE {}
352 352
353 private: 353 private:
354 int fd_read_; 354 int fd_read_;
355 int fd_write_; 355 int fd_write_;
356 base::Closure reply_; 356 base::Closure reply_;
357 }; 357 };
358 358
359 void NaClGdbWatchDelegate::OnFileCanReadWithoutBlocking(int fd) { 359 void NaClProcessHost::NaClGdbWatchDelegate::OnFileCanReadWithoutBlocking(
360 int fd) {
360 char buf; 361 char buf;
361 if (HANDLE_EINTR(read(fd_read_, &buf, 1)) != 1 || buf != '\0') 362 if (HANDLE_EINTR(read(fd_read_, &buf, 1)) != 1 || buf != '\0')
362 LOG(ERROR) << "Failed to sync with nacl-gdb"; 363 LOG(ERROR) << "Failed to sync with nacl-gdb";
363 BrowserThread::PostTask(BrowserThread::IO, FROM_HERE, reply_); 364 BrowserThread::PostTask(BrowserThread::IO, FROM_HERE, reply_);
364 } 365 }
365 } // namespace
366 366
367 bool NaClProcessHost::LaunchNaClGdb(base::ProcessId pid) { 367 bool NaClProcessHost::LaunchNaClGdb(base::ProcessId pid) {
368 CommandLine::StringType nacl_gdb = 368 CommandLine::StringType nacl_gdb =
369 CommandLine::ForCurrentProcess()->GetSwitchValueNative( 369 CommandLine::ForCurrentProcess()->GetSwitchValueNative(
370 switches::kNaClGdb); 370 switches::kNaClGdb);
371 CommandLine::StringVector argv; 371 CommandLine::StringVector argv;
372 // We don't support spaces inside arguments in --nacl-gdb switch. 372 // We don't support spaces inside arguments in --nacl-gdb switch.
373 base::SplitString(nacl_gdb, static_cast<CommandLine::CharType>(' '), &argv); 373 base::SplitString(nacl_gdb, static_cast<CommandLine::CharType>(' '), &argv);
374 CommandLine cmd_line(argv); 374 CommandLine cmd_line(argv);
375 cmd_line.AppendArg("--eval-command"); 375 cmd_line.AppendArg("--eval-command");
(...skipping 406 matching lines...) Expand 10 before | Expand all | Expand 10 after
782 } else { 782 } else {
783 NaClStartDebugExceptionHandlerThread( 783 NaClStartDebugExceptionHandlerThread(
784 process_handle.Take(), info, 784 process_handle.Take(), info,
785 base::MessageLoopProxy::current(), 785 base::MessageLoopProxy::current(),
786 base::Bind(&NaClProcessHost::OnDebugExceptionHandlerLaunchedByBroker, 786 base::Bind(&NaClProcessHost::OnDebugExceptionHandlerLaunchedByBroker,
787 weak_factory_.GetWeakPtr())); 787 weak_factory_.GetWeakPtr()));
788 return true; 788 return true;
789 } 789 }
790 } 790 }
791 #endif 791 #endif
OLDNEW
« no previous file with comments | « chrome/browser/nacl_host/nacl_process_host.h ('k') | chrome/browser/policy/policy_service.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698