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

Side by Side Diff: components/browser_watcher/window_hang_monitor_win.cc

Issue 2375663002: Replace MessageLoop::current()->task_runner() with ThreadTaskRunnerHandle::Get(). (Closed)
Patch Set: rebase Created 4 years, 2 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 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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 #include "components/browser_watcher/window_hang_monitor_win.h" 4 #include "components/browser_watcher/window_hang_monitor_win.h"
5 5
6 #include <utility> 6 #include <utility>
7 7
8 #include "base/callback.h" 8 #include "base/callback.h"
9 #include "base/files/file_util.h" 9 #include "base/files/file_util.h"
10 #include "base/location.h" 10 #include "base/location.h"
11 #include "base/logging.h" 11 #include "base/logging.h"
12 #include "base/message_loop/message_loop.h"
13 #include "base/strings/string_piece.h" 12 #include "base/strings/string_piece.h"
14 #include "base/strings/string_util.h" 13 #include "base/strings/string_util.h"
14 #include "base/threading/thread_task_runner_handle.h"
15 #include "base/win/message_window.h" 15 #include "base/win/message_window.h"
16 16
17 namespace browser_watcher { 17 namespace browser_watcher {
18 18
19 namespace { 19 namespace {
20 20
21 // Returns true if the class name for |window| equals |str|. 21 // Returns true if the class name for |window| equals |str|.
22 bool WindowClassNameEqualsString(HWND window, base::StringPiece16 str) { 22 bool WindowClassNameEqualsString(HWND window, base::StringPiece16 str) {
23 wchar_t class_name[MAX_PATH]; 23 wchar_t class_name[MAX_PATH];
24 int str_length = ::GetClassName(window, class_name, MAX_PATH); 24 int str_length = ::GetClassName(window, class_name, MAX_PATH);
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
68 if (outstanding_ping_) { 68 if (outstanding_ping_) {
69 // We have an outstanding ping, disable it and leak it intentionally as 69 // We have an outstanding ping, disable it and leak it intentionally as
70 // if the callback arrives eventually, it'll cause a use-after-free. 70 // if the callback arrives eventually, it'll cause a use-after-free.
71 outstanding_ping_->monitor = nullptr; 71 outstanding_ping_->monitor = nullptr;
72 outstanding_ping_ = nullptr; 72 outstanding_ping_ = nullptr;
73 } 73 }
74 } 74 }
75 75
76 void WindowHangMonitor::Initialize(base::Process process) { 76 void WindowHangMonitor::Initialize(base::Process process) {
77 window_process_ = std::move(process); 77 window_process_ = std::move(process);
78 timer_.SetTaskRunner(base::MessageLoop::current()->task_runner()); 78 timer_.SetTaskRunner(base::ThreadTaskRunnerHandle::Get());
79 79
80 ScheduleFindWindow(); 80 ScheduleFindWindow();
81 } 81 }
82 82
83 void WindowHangMonitor::ScheduleFindWindow() { 83 void WindowHangMonitor::ScheduleFindWindow() {
84 // TODO(erikwright): We could reduce the polling by using WaitForInputIdle, 84 // TODO(erikwright): We could reduce the polling by using WaitForInputIdle,
85 // but it is hard to test (requiring a non-Console executable). 85 // but it is hard to test (requiring a non-Console executable).
86 timer_.Start( 86 timer_.Start(
87 FROM_HERE, ping_interval_, 87 FROM_HERE, ping_interval_,
88 base::Bind(&WindowHangMonitor::PollForWindow, base::Unretained(this))); 88 base::Bind(&WindowHangMonitor::PollForWindow, base::Unretained(this)));
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
182 // at any point after we found it. 182 // at any point after we found it.
183 HWND hwnd = FindChromeMessageWindow(window_process_.Pid()); 183 HWND hwnd = FindChromeMessageWindow(window_process_.Pid());
184 if (hwnd) { 184 if (hwnd) {
185 SendPing(hwnd); 185 SendPing(hwnd);
186 } else { 186 } else {
187 callback_.Run(WINDOW_VANISHED); 187 callback_.Run(WINDOW_VANISHED);
188 } 188 }
189 } 189 }
190 190
191 } // namespace browser_watcher 191 } // namespace browser_watcher
OLDNEW
« no previous file with comments | « components/arc/arc_bridge_service_impl.cc ('k') | components/browsing_data/content/conditional_cache_deletion_helper.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698