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

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: Created 8 years, 7 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 // 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 302 matching lines...) Expand 10 before | Expand all | Expand 10 after
313 manifest_path.value()); 313 manifest_path.value());
314 } 314 }
315 cmd_line->AppendArg("--args"); 315 cmd_line->AppendArg("--args");
316 const CommandLine::StringVector& argv = line->argv(); 316 const CommandLine::StringVector& argv = line->argv();
317 for (size_t i = 0; i < argv.size(); i++) { 317 for (size_t i = 0; i < argv.size(); i++) {
318 cmd_line->AppendArgNative(argv[i]); 318 cmd_line->AppendArgNative(argv[i]);
319 } 319 }
320 return scoped_ptr<CommandLine>(cmd_line); 320 return scoped_ptr<CommandLine>(cmd_line);
321 } 321 }
322 #elif defined(OS_LINUX) 322 #elif defined(OS_LINUX)
323 namespace { 323 class NaClProcessHost::NaClGdbWatchDelegate
324 class NaClGdbWatchDelegate : public MessageLoopForIO::Watcher { 324 : public MessageLoopForIO::Watcher {
325 public: 325 public:
326 // fd_write_ is used by nacl-gdb via /proc/browser_PID/fd/fd_write_ 326 // fd_write_ is used by nacl-gdb via /proc/browser_PID/fd/fd_write_
327 NaClGdbWatchDelegate(int fd_read, int fd_write, 327 NaClGdbWatchDelegate(int fd_read, int fd_write,
328 const base::Closure& reply) 328 const base::Closure& reply)
329 : fd_read_(fd_read), 329 : fd_read_(fd_read),
330 fd_write_(fd_write), 330 fd_write_(fd_write),
331 reply_(reply) {} 331 reply_(reply) {}
332 332
333 ~NaClGdbWatchDelegate() { 333 ~NaClGdbWatchDelegate() {
334 if (HANDLE_EINTR(close(fd_read_)) != 0) 334 if (HANDLE_EINTR(close(fd_read_)) != 0)
335 DLOG(ERROR) << "close(fd_read_) failed"; 335 DLOG(ERROR) << "close(fd_read_) failed";
336 if (HANDLE_EINTR(close(fd_write_)) != 0) 336 if (HANDLE_EINTR(close(fd_write_)) != 0)
337 DLOG(ERROR) << "close(fd_write_) failed"; 337 DLOG(ERROR) << "close(fd_write_) failed";
338 } 338 }
339 339
340 virtual void OnFileCanReadWithoutBlocking(int fd) OVERRIDE; 340 virtual void OnFileCanReadWithoutBlocking(int fd) OVERRIDE;
341 virtual void OnFileCanWriteWithoutBlocking(int fd) OVERRIDE {} 341 virtual void OnFileCanWriteWithoutBlocking(int fd) OVERRIDE {}
342 342
343 private: 343 private:
344 int fd_read_; 344 int fd_read_;
345 int fd_write_; 345 int fd_write_;
346 base::Closure reply_; 346 base::Closure reply_;
347 }; 347 };
348 348
349 void NaClGdbWatchDelegate::OnFileCanReadWithoutBlocking(int fd) { 349 void NaClProcessHost::NaClGdbWatchDelegate::OnFileCanReadWithoutBlocking(
350 int fd) {
350 char buf; 351 char buf;
351 if (HANDLE_EINTR(read(fd_read_, &buf, 1)) != 1 || buf != '\0') 352 if (HANDLE_EINTR(read(fd_read_, &buf, 1)) != 1 || buf != '\0')
352 LOG(ERROR) << "Failed to sync with nacl-gdb"; 353 LOG(ERROR) << "Failed to sync with nacl-gdb";
353 BrowserThread::PostTask(BrowserThread::IO, FROM_HERE, reply_); 354 BrowserThread::PostTask(BrowserThread::IO, FROM_HERE, reply_);
354 } 355 }
355 } // namespace
356 356
357 bool NaClProcessHost::LaunchNaClGdb(base::ProcessId pid) { 357 bool NaClProcessHost::LaunchNaClGdb(base::ProcessId pid) {
358 CommandLine::StringType nacl_gdb = 358 CommandLine::StringType nacl_gdb =
359 CommandLine::ForCurrentProcess()->GetSwitchValueNative( 359 CommandLine::ForCurrentProcess()->GetSwitchValueNative(
360 switches::kNaClGdb); 360 switches::kNaClGdb);
361 CommandLine::StringVector argv; 361 CommandLine::StringVector argv;
362 // We don't support spaces inside arguments in --nacl-gdb switch. 362 // We don't support spaces inside arguments in --nacl-gdb switch.
363 base::SplitString(nacl_gdb, static_cast<CommandLine::CharType>(' '), &argv); 363 base::SplitString(nacl_gdb, static_cast<CommandLine::CharType>(' '), &argv);
364 CommandLine cmd_line(argv); 364 CommandLine cmd_line(argv);
365 cmd_line.AppendArg("--eval-command"); 365 cmd_line.AppendArg("--eval-command");
(...skipping 391 matching lines...) Expand 10 before | Expand all | Expand 10 after
757 } else { 757 } else {
758 NaClStartDebugExceptionHandlerThread( 758 NaClStartDebugExceptionHandlerThread(
759 process_handle.Take(), info, 759 process_handle.Take(), info,
760 base::MessageLoopProxy::current(), 760 base::MessageLoopProxy::current(),
761 base::Bind(&NaClProcessHost::OnDebugExceptionHandlerLaunchedByBroker, 761 base::Bind(&NaClProcessHost::OnDebugExceptionHandlerLaunchedByBroker,
762 weak_factory_.GetWeakPtr())); 762 weak_factory_.GetWeakPtr()));
763 return true; 763 return true;
764 } 764 }
765 } 765 }
766 #endif 766 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698