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

Side by Side Diff: chrome/browser/process_singleton_linux.cc

Issue 12212048: Linux/ChromeOS Chromium style checker cleanup, chrome/browser edition. (Closed) Base URL: http://src.chromium.org/svn/trunk/src/
Patch Set: Created 7 years, 10 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 // On Linux, when the user tries to launch a second copy of chrome, we check 5 // On Linux, when the user tries to launch a second copy of chrome, we check
6 // for a socket in the user's profile directory. If the socket file is open we 6 // for a socket in the user's profile directory. If the socket file is open we
7 // send a message to the first chrome browser process with the current 7 // send a message to the first chrome browser process with the current
8 // directory and second process command line flags. The second process then 8 // directory and second process command line flags. The second process then
9 // exits. 9 // exits.
10 // 10 //
(...skipping 417 matching lines...) Expand 10 before | Expand all | Expand 10 after
428 // If we haven't completed in a reasonable amount of time, give up. 428 // If we haven't completed in a reasonable amount of time, give up.
429 timer_.Start(FROM_HERE, base::TimeDelta::FromSeconds(kTimeoutInSeconds), 429 timer_.Start(FROM_HERE, base::TimeDelta::FromSeconds(kTimeoutInSeconds),
430 this, &SocketReader::CleanupAndDeleteSelf); 430 this, &SocketReader::CleanupAndDeleteSelf);
431 } 431 }
432 432
433 virtual ~SocketReader() { 433 virtual ~SocketReader() {
434 CloseSocket(fd_); 434 CloseSocket(fd_);
435 } 435 }
436 436
437 // MessageLoopForIO::Watcher impl. 437 // MessageLoopForIO::Watcher impl.
438 virtual void OnFileCanReadWithoutBlocking(int fd); 438 virtual void OnFileCanReadWithoutBlocking(int fd) OVERRIDE;
439 virtual void OnFileCanWriteWithoutBlocking(int fd) { 439 virtual void OnFileCanWriteWithoutBlocking(int fd) OVERRIDE {
440 // SocketReader only watches for accept (read) events. 440 // SocketReader only watches for accept (read) events.
441 NOTREACHED(); 441 NOTREACHED();
442 } 442 }
443 443
444 // Finish handling the incoming message by optionally sending back an ACK 444 // Finish handling the incoming message by optionally sending back an ACK
445 // message and removing this SocketReader. 445 // message and removing this SocketReader.
446 void FinishWithACK(const char *message, size_t length); 446 void FinishWithACK(const char *message, size_t length);
447 447
448 private: 448 private:
449 void CleanupAndDeleteSelf() { 449 void CleanupAndDeleteSelf() {
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
487 void StartListening(int socket); 487 void StartListening(int socket);
488 488
489 // This method determines if we should use the same process and if we should, 489 // This method determines if we should use the same process and if we should,
490 // opens a new browser tab. This runs on the UI thread. 490 // opens a new browser tab. This runs on the UI thread.
491 // |reader| is for sending back ACK message. 491 // |reader| is for sending back ACK message.
492 void HandleMessage(const std::string& current_dir, 492 void HandleMessage(const std::string& current_dir,
493 const std::vector<std::string>& argv, 493 const std::vector<std::string>& argv,
494 SocketReader* reader); 494 SocketReader* reader);
495 495
496 // MessageLoopForIO::Watcher impl. These run on the IO thread. 496 // MessageLoopForIO::Watcher impl. These run on the IO thread.
497 virtual void OnFileCanReadWithoutBlocking(int fd); 497 virtual void OnFileCanReadWithoutBlocking(int fd) OVERRIDE;
498 virtual void OnFileCanWriteWithoutBlocking(int fd) { 498 virtual void OnFileCanWriteWithoutBlocking(int fd) OVERRIDE {
499 // ProcessSingleton only watches for accept (read) events. 499 // ProcessSingleton only watches for accept (read) events.
500 NOTREACHED(); 500 NOTREACHED();
501 } 501 }
502 502
503 // MessageLoop::DestructionObserver 503 // MessageLoop::DestructionObserver
504 virtual void WillDestroyCurrentMessageLoop() { 504 virtual void WillDestroyCurrentMessageLoop() OVERRIDE {
505 fd_watcher_.StopWatchingFileDescriptor(); 505 fd_watcher_.StopWatchingFileDescriptor();
506 } 506 }
507 507
508 private: 508 private:
509 friend struct BrowserThread::DeleteOnThread<BrowserThread::IO>; 509 friend struct BrowserThread::DeleteOnThread<BrowserThread::IO>;
510 friend class base::DeleteHelper<ProcessSingleton::LinuxWatcher>; 510 friend class base::DeleteHelper<ProcessSingleton::LinuxWatcher>;
511 511
512 virtual ~LinuxWatcher() { 512 virtual ~LinuxWatcher() {
513 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); 513 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
514 STLDeleteElements(&readers_); 514 STLDeleteElements(&readers_);
(...skipping 478 matching lines...) Expand 10 before | Expand all | Expand 10 after
993 993
994 void ProcessSingleton::KillProcess(int pid) { 994 void ProcessSingleton::KillProcess(int pid) {
995 // TODO(james.su@gmail.com): Is SIGKILL ok? 995 // TODO(james.su@gmail.com): Is SIGKILL ok?
996 int rv = kill(static_cast<base::ProcessHandle>(pid), SIGKILL); 996 int rv = kill(static_cast<base::ProcessHandle>(pid), SIGKILL);
997 // ESRCH = No Such Process (can happen if the other process is already in 997 // ESRCH = No Such Process (can happen if the other process is already in
998 // progress of shutting down and finishes before we try to kill it). 998 // progress of shutting down and finishes before we try to kill it).
999 DCHECK(rv == 0 || errno == ESRCH) << "Error killing process: " 999 DCHECK(rv == 0 || errno == ESRCH) << "Error killing process: "
1000 << safe_strerror(errno); 1000 << safe_strerror(errno);
1001 } 1001 }
1002 1002
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698