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

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

Issue 1949393007: X11: Better timestamp handling for _NET_ACTIVE_WINDOW (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 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
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 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
74 #include "base/strings/string_split.h" 74 #include "base/strings/string_split.h"
75 #include "base/strings/string_util.h" 75 #include "base/strings/string_util.h"
76 #include "base/strings/stringprintf.h" 76 #include "base/strings/stringprintf.h"
77 #include "base/strings/sys_string_conversions.h" 77 #include "base/strings/sys_string_conversions.h"
78 #include "base/strings/utf_string_conversions.h" 78 #include "base/strings/utf_string_conversions.h"
79 #include "base/threading/platform_thread.h" 79 #include "base/threading/platform_thread.h"
80 #include "base/time/time.h" 80 #include "base/time/time.h"
81 #include "base/timer/timer.h" 81 #include "base/timer/timer.h"
82 #include "build/build_config.h" 82 #include "build/build_config.h"
83 #include "chrome/common/chrome_constants.h" 83 #include "chrome/common/chrome_constants.h"
84 #include "chrome/common/chrome_switches.h"
84 #include "chrome/grit/chromium_strings.h" 85 #include "chrome/grit/chromium_strings.h"
85 #include "chrome/grit/generated_resources.h" 86 #include "chrome/grit/generated_resources.h"
86 #include "content/public/browser/browser_thread.h" 87 #include "content/public/browser/browser_thread.h"
87 #include "net/base/network_interfaces.h" 88 #include "net/base/network_interfaces.h"
88 #include "ui/base/l10n/l10n_util.h" 89 #include "ui/base/l10n/l10n_util.h"
89 90
90 #if defined(OS_LINUX) 91 #if defined(OS_LINUX)
91 #include "chrome/browser/ui/process_singleton_dialog_linux.h" 92 #include "chrome/browser/ui/process_singleton_dialog_linux.h"
92 #endif 93 #endif
93 94
95 #if defined(OS_LINUX) && !defined(OS_CHROMEOS)
96 #include "ui/events/platform/x11/x11_event_source.h"
97 #endif
98
94 #if defined(TOOLKIT_VIEWS) && defined(OS_LINUX) && !defined(OS_CHROMEOS) 99 #if defined(TOOLKIT_VIEWS) && defined(OS_LINUX) && !defined(OS_CHROMEOS)
95 #include "ui/views/linux_ui/linux_ui.h" 100 #include "ui/views/linux_ui/linux_ui.h"
96 #endif 101 #endif
97 102
98 using content::BrowserThread; 103 using content::BrowserThread;
99 104
100 namespace { 105 namespace {
101 106
102 // Timeout for the current browser process to respond. 20 seconds should be 107 // Timeout for the current browser process to respond. 20 seconds should be
103 // enough. 108 // enough.
(...skipping 706 matching lines...) Expand 10 before | Expand all | Expand 10 after
810 if (retries == retry_attempts) { 815 if (retries == retry_attempts) {
811 // Retries failed. Kill the unresponsive chrome process and continue. 816 // Retries failed. Kill the unresponsive chrome process and continue.
812 if (!kill_unresponsive || !KillProcessByLockPath()) 817 if (!kill_unresponsive || !KillProcessByLockPath())
813 return PROFILE_IN_USE; 818 return PROFILE_IN_USE;
814 return PROCESS_NONE; 819 return PROCESS_NONE;
815 } 820 }
816 821
817 base::PlatformThread::Sleep(sleep_interval); 822 base::PlatformThread::Sleep(sleep_interval);
818 } 823 }
819 824
825 #if defined(OS_LINUX) && !defined(OS_CHROMEOS)
826 base::CommandLine::ForCurrentProcess()->AppendSwitchASCII(
827 switches::kWmUserTimeMs,
828 base::Uint64ToString(
829 ui::X11EventSource::GetInstance()->UpdateServerTime()));
830 #endif
831
Tom (Use chromium acct) 2016/05/06 20:42:00 This doesn't seem like the best place to put this.
Elliot Glaysher 2016/05/06 21:13:13 I agree that this is really not a good place for t
Tom (Use chromium acct) 2016/05/06 22:09:43 Done.
820 timeval socket_timeout = TimeDeltaToTimeVal(timeout); 832 timeval socket_timeout = TimeDeltaToTimeVal(timeout);
821 setsockopt(socket.fd(), 833 setsockopt(socket.fd(),
822 SOL_SOCKET, 834 SOL_SOCKET,
823 SO_SNDTIMEO, 835 SO_SNDTIMEO,
824 &socket_timeout, 836 &socket_timeout,
825 sizeof(socket_timeout)); 837 sizeof(socket_timeout));
826 838
827 // Found another process, prepare our command line 839 // Found another process, prepare our command line
828 // format is "START\0<current dir>\0<argv[0]>\0...\0<argv[n]>". 840 // format is "START\0<current dir>\0<argv[0]>\0...\0<argv[n]>".
829 std::string to_send(kStartToken); 841 std::string to_send(kStartToken);
(...skipping 225 matching lines...) Expand 10 before | Expand all | Expand 10 after
1055 } 1067 }
1056 1068
1057 void ProcessSingleton::KillProcess(int pid) { 1069 void ProcessSingleton::KillProcess(int pid) {
1058 // TODO(james.su@gmail.com): Is SIGKILL ok? 1070 // TODO(james.su@gmail.com): Is SIGKILL ok?
1059 int rv = kill(static_cast<base::ProcessHandle>(pid), SIGKILL); 1071 int rv = kill(static_cast<base::ProcessHandle>(pid), SIGKILL);
1060 // ESRCH = No Such Process (can happen if the other process is already in 1072 // ESRCH = No Such Process (can happen if the other process is already in
1061 // progress of shutting down and finishes before we try to kill it). 1073 // progress of shutting down and finishes before we try to kill it).
1062 DCHECK(rv == 0 || errno == ESRCH) << "Error killing process: " 1074 DCHECK(rv == 0 || errno == ESRCH) << "Error killing process: "
1063 << base::safe_strerror(errno); 1075 << base::safe_strerror(errno);
1064 } 1076 }
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/ui/startup/startup_browser_creator.cc » ('j') | ui/events/platform/x11/x11_event_source.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698