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

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

Issue 1143343005: chrome/browser: Remove use of MessageLoopProxy and deprecated MessageLoop APIs (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebased. Created 5 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
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
51 #include <cstring> 51 #include <cstring>
52 #include <set> 52 #include <set>
53 #include <string> 53 #include <string>
54 54
55 #include "base/base_paths.h" 55 #include "base/base_paths.h"
56 #include "base/basictypes.h" 56 #include "base/basictypes.h"
57 #include "base/bind.h" 57 #include "base/bind.h"
58 #include "base/command_line.h" 58 #include "base/command_line.h"
59 #include "base/files/file_path.h" 59 #include "base/files/file_path.h"
60 #include "base/files/file_util.h" 60 #include "base/files/file_util.h"
61 #include "base/location.h"
61 #include "base/logging.h" 62 #include "base/logging.h"
62 #include "base/message_loop/message_loop.h" 63 #include "base/message_loop/message_loop.h"
63 #include "base/path_service.h" 64 #include "base/path_service.h"
64 #include "base/posix/eintr_wrapper.h" 65 #include "base/posix/eintr_wrapper.h"
65 #include "base/posix/safe_strerror.h" 66 #include "base/posix/safe_strerror.h"
66 #include "base/rand_util.h" 67 #include "base/rand_util.h"
67 #include "base/sequenced_task_runner_helpers.h" 68 #include "base/sequenced_task_runner_helpers.h"
69 #include "base/single_thread_task_runner.h"
68 #include "base/stl_util.h" 70 #include "base/stl_util.h"
69 #include "base/strings/string_number_conversions.h" 71 #include "base/strings/string_number_conversions.h"
70 #include "base/strings/string_split.h" 72 #include "base/strings/string_split.h"
71 #include "base/strings/string_util.h" 73 #include "base/strings/string_util.h"
72 #include "base/strings/stringprintf.h" 74 #include "base/strings/stringprintf.h"
73 #include "base/strings/sys_string_conversions.h" 75 #include "base/strings/sys_string_conversions.h"
74 #include "base/strings/utf_string_conversions.h" 76 #include "base/strings/utf_string_conversions.h"
75 #include "base/threading/platform_thread.h" 77 #include "base/threading/platform_thread.h"
76 #include "base/time/time.h" 78 #include "base/time/time.h"
77 #include "base/timer/timer.h" 79 #include "base/timer/timer.h"
(...skipping 617 matching lines...) Expand 10 before | Expand all | Expand 10 after
695 // terminated unexpectly. 697 // terminated unexpectly.
696 timer_.Stop(); 698 timer_.Stop();
697 699
698 std::string current_dir = tokens[1]; 700 std::string current_dir = tokens[1];
699 // Remove the first two tokens. The remaining tokens should be the command 701 // Remove the first two tokens. The remaining tokens should be the command
700 // line argv array. 702 // line argv array.
701 tokens.erase(tokens.begin()); 703 tokens.erase(tokens.begin());
702 tokens.erase(tokens.begin()); 704 tokens.erase(tokens.begin());
703 705
704 // Return to the UI thread to handle opening a new browser tab. 706 // Return to the UI thread to handle opening a new browser tab.
705 ui_message_loop_->PostTask(FROM_HERE, base::Bind( 707 ui_message_loop_->task_runner()->PostTask(
706 &ProcessSingleton::LinuxWatcher::HandleMessage, 708 FROM_HERE, base::Bind(&ProcessSingleton::LinuxWatcher::HandleMessage,
707 parent_, 709 parent_, current_dir, tokens, this));
708 current_dir,
709 tokens,
710 this));
711 fd_reader_.StopWatchingFileDescriptor(); 710 fd_reader_.StopWatchingFileDescriptor();
712 711
713 // LinuxWatcher::HandleMessage() is in charge of destroying this SocketReader 712 // LinuxWatcher::HandleMessage() is in charge of destroying this SocketReader
714 // object by invoking SocketReader::FinishWithACK(). 713 // object by invoking SocketReader::FinishWithACK().
715 } 714 }
716 715
717 void ProcessSingleton::LinuxWatcher::SocketReader::FinishWithACK( 716 void ProcessSingleton::LinuxWatcher::SocketReader::FinishWithACK(
718 const char *message, size_t length) { 717 const char *message, size_t length) {
719 if (message && length) { 718 if (message && length) {
720 // Not necessary to care about the return value. 719 // Not necessary to care about the return value.
(...skipping 343 matching lines...) Expand 10 before | Expand all | Expand 10 after
1064 } 1063 }
1065 1064
1066 void ProcessSingleton::KillProcess(int pid) { 1065 void ProcessSingleton::KillProcess(int pid) {
1067 // TODO(james.su@gmail.com): Is SIGKILL ok? 1066 // TODO(james.su@gmail.com): Is SIGKILL ok?
1068 int rv = kill(static_cast<base::ProcessHandle>(pid), SIGKILL); 1067 int rv = kill(static_cast<base::ProcessHandle>(pid), SIGKILL);
1069 // ESRCH = No Such Process (can happen if the other process is already in 1068 // ESRCH = No Such Process (can happen if the other process is already in
1070 // progress of shutting down and finishes before we try to kill it). 1069 // progress of shutting down and finishes before we try to kill it).
1071 DCHECK(rv == 0 || errno == ESRCH) << "Error killing process: " 1070 DCHECK(rv == 0 || errno == ESRCH) << "Error killing process: "
1072 << base::safe_strerror(errno); 1071 << base::safe_strerror(errno);
1073 } 1072 }
OLDNEW
« no previous file with comments | « chrome/browser/process_singleton_browsertest.cc ('k') | chrome/browser/process_singleton_posix_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698