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

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

Issue 7004007: iwyu: Include stringprintf.h where appropriate, part 2. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix 2. Created 9 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) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
61 #include "base/eintr_wrapper.h" 61 #include "base/eintr_wrapper.h"
62 #include "base/file_path.h" 62 #include "base/file_path.h"
63 #include "base/file_util.h" 63 #include "base/file_util.h"
64 #include "base/logging.h" 64 #include "base/logging.h"
65 #include "base/message_loop.h" 65 #include "base/message_loop.h"
66 #include "base/path_service.h" 66 #include "base/path_service.h"
67 #include "base/process_util.h" 67 #include "base/process_util.h"
68 #include "base/rand_util.h" 68 #include "base/rand_util.h"
69 #include "base/safe_strerror_posix.h" 69 #include "base/safe_strerror_posix.h"
70 #include "base/stl_util-inl.h" 70 #include "base/stl_util-inl.h"
71 #include "base/stringprintf.h"
71 #include "base/string_number_conversions.h" 72 #include "base/string_number_conversions.h"
72 #include "base/string_split.h" 73 #include "base/string_split.h"
73 #include "base/sys_string_conversions.h" 74 #include "base/sys_string_conversions.h"
74 #include "base/threading/platform_thread.h" 75 #include "base/threading/platform_thread.h"
75 #include "base/time.h" 76 #include "base/time.h"
76 #include "base/timer.h" 77 #include "base/timer.h"
77 #include "base/utf_string_conversions.h" 78 #include "base/utf_string_conversions.h"
78 #include "chrome/browser/browser_process.h" 79 #include "chrome/browser/browser_process.h"
79 #if defined(TOOLKIT_GTK) 80 #if defined(TOOLKIT_GTK)
80 #include "chrome/browser/ui/gtk/process_singleton_dialog.h" 81 #include "chrome/browser/ui/gtk/process_singleton_dialog.h"
(...skipping 830 matching lines...) Expand 10 before | Expand all | Expand 10 after
911 912
912 return LOCK_ERROR; 913 return LOCK_ERROR;
913 } 914 }
914 915
915 bool ProcessSingleton::Create() { 916 bool ProcessSingleton::Create() {
916 int sock; 917 int sock;
917 sockaddr_un addr; 918 sockaddr_un addr;
918 919
919 // The symlink lock is pointed to the hostname and process id, so other 920 // The symlink lock is pointed to the hostname and process id, so other
920 // processes can find it out. 921 // processes can find it out.
921 FilePath symlink_content(StringPrintf( 922 FilePath symlink_content(base::StringPrintf(
922 "%s%c%u", 923 "%s%c%u",
923 net::GetHostName().c_str(), 924 net::GetHostName().c_str(),
924 kLockDelimiter, 925 kLockDelimiter,
925 base::GetCurrentProcId())); 926 base::GetCurrentProcId()));
926 927
927 // Create symbol link before binding the socket, to ensure only one instance 928 // Create symbol link before binding the socket, to ensure only one instance
928 // can have the socket open. 929 // can have the socket open.
929 if (!SymlinkPath(symlink_content, lock_path_)) { 930 if (!SymlinkPath(symlink_content, lock_path_)) {
930 // If we failed to create the lock, most likely another instance won the 931 // If we failed to create the lock, most likely another instance won the
931 // startup race. 932 // startup race.
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
980 sock)); 981 sock));
981 982
982 return true; 983 return true;
983 } 984 }
984 985
985 void ProcessSingleton::Cleanup() { 986 void ProcessSingleton::Cleanup() {
986 UnlinkPath(socket_path_); 987 UnlinkPath(socket_path_);
987 UnlinkPath(cookie_path_); 988 UnlinkPath(cookie_path_);
988 UnlinkPath(lock_path_); 989 UnlinkPath(lock_path_);
989 } 990 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698