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

Side by Side Diff: chrome/browser/chromeos/power/extension_event_observer.cc

Issue 1119803007: [chrome/browser/chromeos] Replace MessageLoopProxy usage with ThreadTaskRunnerHandle (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fixed nit Created 5 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 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 4
5 #include "chrome/browser/chromeos/power/extension_event_observer.h" 5 #include "chrome/browser/chromeos/power/extension_event_observer.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/logging.h" 8 #include "base/logging.h"
9 #include "base/memory/scoped_ptr.h" 9 #include "base/memory/scoped_ptr.h"
10 #include "base/thread_task_runner_handle.h"
10 #include "chrome/browser/chrome_notification_types.h" 11 #include "chrome/browser/chrome_notification_types.h"
11 #include "chrome/browser/profiles/profile.h" 12 #include "chrome/browser/profiles/profile.h"
12 #include "chrome/common/extensions/api/gcm.h" 13 #include "chrome/common/extensions/api/gcm.h"
13 #include "chromeos/dbus/dbus_thread_manager.h" 14 #include "chromeos/dbus/dbus_thread_manager.h"
14 #include "content/public/browser/notification_service.h" 15 #include "content/public/browser/notification_service.h"
15 #include "extensions/browser/extension_host.h" 16 #include "extensions/browser/extension_host.h"
16 #include "extensions/browser/process_manager.h" 17 #include "extensions/browser/process_manager.h"
17 #include "extensions/common/extension.h" 18 #include "extensions/common/extension.h"
18 #include "extensions/common/manifest_handlers/background_info.h" 19 #include "extensions/common/manifest_handlers/background_info.h"
19 #include "extensions/common/permissions/api_permission.h" 20 #include "extensions/common/permissions/api_permission.h"
(...skipping 225 matching lines...) Expand 10 before | Expand all | Expand 10 after
245 base::Bind(&ExtensionEventObserver::MaybeReportSuspendReadiness, 246 base::Bind(&ExtensionEventObserver::MaybeReportSuspendReadiness,
246 weak_factory_.GetWeakPtr())); 247 weak_factory_.GetWeakPtr()));
247 248
248 // Unfortunately, there is a race between the arrival of the 249 // Unfortunately, there is a race between the arrival of the
249 // DarkSuspendImminent signal and OnBackgroundEventDispatched. As a result, 250 // DarkSuspendImminent signal and OnBackgroundEventDispatched. As a result,
250 // there is no way to tell from within this method if a push message is about 251 // there is no way to tell from within this method if a push message is about
251 // to arrive. To try and deal with this, we wait one second before attempting 252 // to arrive. To try and deal with this, we wait one second before attempting
252 // to report suspend readiness. If there is a push message pending, we should 253 // to report suspend readiness. If there is a push message pending, we should
253 // receive it within that time and increment |suspend_keepalive_count_| to 254 // receive it within that time and increment |suspend_keepalive_count_| to
254 // prevent this callback from reporting ready. 255 // prevent this callback from reporting ready.
255 base::MessageLoopProxy::current()->PostDelayedTask( 256 base::ThreadTaskRunnerHandle::Get()->PostDelayedTask(
256 FROM_HERE, suspend_readiness_callback_.callback(), 257 FROM_HERE, suspend_readiness_callback_.callback(),
257 dark_suspend ? base::TimeDelta::FromMilliseconds(kDarkSuspendDelayMs) 258 dark_suspend ? base::TimeDelta::FromMilliseconds(kDarkSuspendDelayMs)
258 : base::TimeDelta()); 259 : base::TimeDelta());
259 } 260 }
260 261
261 void ExtensionEventObserver::MaybeReportSuspendReadiness() { 262 void ExtensionEventObserver::MaybeReportSuspendReadiness() {
262 if (!suspend_is_pending_ || suspend_keepalive_count_ > 0 || 263 if (!suspend_is_pending_ || suspend_keepalive_count_ > 0 ||
263 power_manager_callback_.is_null()) 264 power_manager_callback_.is_null())
264 return; 265 return;
265 266
266 suspend_is_pending_ = false; 267 suspend_is_pending_ = false;
267 power_manager_callback_.Run(); 268 power_manager_callback_.Run();
268 power_manager_callback_.Reset(); 269 power_manager_callback_.Reset();
269 } 270 }
270 271
271 } // namespace chromeos 272 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698