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

Side by Side Diff: chrome/browser/chromeos/first_run/drive_first_run_controller.cc

Issue 2033753002: Remove use of deprecated MessageLoop methods in chrome/. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: manual change Created 4 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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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/first_run/drive_first_run_controller.h" 5 #include "chrome/browser/chromeos/first_run/drive_first_run_controller.h"
6 6
7 #include <stdint.h> 7 #include <stdint.h>
8 #include <utility> 8 #include <utility>
9 9
10 #include "ash/shell.h" 10 #include "ash/shell.h"
11 #include "ash/system/tray/system_tray_delegate.h" 11 #include "ash/system/tray/system_tray_delegate.h"
12 #include "base/callback.h" 12 #include "base/callback.h"
13 #include "base/location.h"
13 #include "base/macros.h" 14 #include "base/macros.h"
14 #include "base/memory/weak_ptr.h" 15 #include "base/memory/weak_ptr.h"
15 #include "base/message_loop/message_loop.h"
16 #include "base/metrics/histogram.h" 16 #include "base/metrics/histogram.h"
17 #include "base/single_thread_task_runner.h"
17 #include "base/strings/utf_string_conversions.h" 18 #include "base/strings/utf_string_conversions.h"
19 #include "base/threading/thread_task_runner_handle.h"
18 #include "chrome/browser/background/background_contents.h" 20 #include "chrome/browser/background/background_contents.h"
19 #include "chrome/browser/background/background_contents_service.h" 21 #include "chrome/browser/background/background_contents_service.h"
20 #include "chrome/browser/background/background_contents_service_factory.h" 22 #include "chrome/browser/background/background_contents_service_factory.h"
21 #include "chrome/browser/chrome_notification_types.h" 23 #include "chrome/browser/chrome_notification_types.h"
22 #include "chrome/browser/extensions/chrome_extension_web_contents_observer.h" 24 #include "chrome/browser/extensions/chrome_extension_web_contents_observer.h"
23 #include "chrome/browser/extensions/extension_service.h" 25 #include "chrome/browser/extensions/extension_service.h"
24 #include "chrome/browser/ui/scoped_tabbed_browser_displayer.h" 26 #include "chrome/browser/ui/scoped_tabbed_browser_displayer.h"
25 #include "chrome/browser/ui/singleton_tabs.h" 27 #include "chrome/browser/ui/singleton_tabs.h"
26 #include "chrome/grit/generated_resources.h" 28 #include "chrome/grit/generated_resources.h"
27 #include "chrome/grit/theme_resources.h" 29 #include "chrome/grit/theme_resources.h"
(...skipping 201 matching lines...) Expand 10 before | Expand all | Expand 10 after
229 void DriveWebContentsManager::StopLoad() { 231 void DriveWebContentsManager::StopLoad() {
230 started_ = false; 232 started_ = false;
231 } 233 }
232 234
233 void DriveWebContentsManager::OnOfflineInit( 235 void DriveWebContentsManager::OnOfflineInit(
234 bool success, 236 bool success,
235 DriveFirstRunController::UMAOutcome outcome) { 237 DriveFirstRunController::UMAOutcome outcome) {
236 if (started_) { 238 if (started_) {
237 // We postpone notifying the controller as we may be in the middle 239 // We postpone notifying the controller as we may be in the middle
238 // of a call stack for some routine of the contained WebContents. 240 // of a call stack for some routine of the contained WebContents.
239 base::MessageLoop::current()->PostTask( 241 base::ThreadTaskRunnerHandle::Get()->PostTask(
240 FROM_HERE, 242 FROM_HERE,
241 base::Bind(&DriveWebContentsManager::RunCompletionCallback, 243 base::Bind(&DriveWebContentsManager::RunCompletionCallback,
242 weak_ptr_factory_.GetWeakPtr(), 244 weak_ptr_factory_.GetWeakPtr(), success, outcome));
243 success,
244 outcome));
245 StopLoad(); 245 StopLoad();
246 } 246 }
247 } 247 }
248 248
249 void DriveWebContentsManager::RunCompletionCallback( 249 void DriveWebContentsManager::RunCompletionCallback(
250 bool success, 250 bool success,
251 DriveFirstRunController::UMAOutcome outcome) { 251 DriveFirstRunController::UMAOutcome outcome) {
252 completion_callback_.Run(success, outcome); 252 completion_callback_.Run(success, outcome);
253 } 253 }
254 254
(...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after
427 void DriveFirstRunController::OnWebContentsTimedOut() { 427 void DriveFirstRunController::OnWebContentsTimedOut() {
428 LOG(WARNING) << "Timed out waiting for web contents."; 428 LOG(WARNING) << "Timed out waiting for web contents.";
429 FOR_EACH_OBSERVER(Observer, observer_list_, OnTimedOut()); 429 FOR_EACH_OBSERVER(Observer, observer_list_, OnTimedOut());
430 OnOfflineInit(false, OUTCOME_WEB_CONTENTS_TIMED_OUT); 430 OnOfflineInit(false, OUTCOME_WEB_CONTENTS_TIMED_OUT);
431 } 431 }
432 432
433 void DriveFirstRunController::CleanUp() { 433 void DriveFirstRunController::CleanUp() {
434 if (web_contents_manager_) 434 if (web_contents_manager_)
435 web_contents_manager_->StopLoad(); 435 web_contents_manager_->StopLoad();
436 web_contents_timer_.Stop(); 436 web_contents_timer_.Stop();
437 base::MessageLoop::current()->DeleteSoon(FROM_HERE, this); 437 base::ThreadTaskRunnerHandle::Get()->DeleteSoon(FROM_HERE, this);
438 } 438 }
439 439
440 void DriveFirstRunController::OnOfflineInit(bool success, UMAOutcome outcome) { 440 void DriveFirstRunController::OnOfflineInit(bool success, UMAOutcome outcome) {
441 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); 441 DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
442 if (success) 442 if (success)
443 ShowNotification(); 443 ShowNotification();
444 UMA_HISTOGRAM_ENUMERATION("DriveOffline.CrosAutoEnableOutcome", 444 UMA_HISTOGRAM_ENUMERATION("DriveOffline.CrosAutoEnableOutcome",
445 outcome, OUTCOME_MAX); 445 outcome, OUTCOME_MAX);
446 FOR_EACH_OBSERVER(Observer, observer_list_, OnCompletion(success)); 446 FOR_EACH_OBSERVER(Observer, observer_list_, OnCompletion(success));
447 CleanUp(); 447 CleanUp();
(...skipping 20 matching lines...) Expand all
468 base::UTF8ToUTF16(extension->name()), GURL(), 468 base::UTF8ToUTF16(extension->name()), GURL(),
469 message_center::NotifierId(message_center::NotifierId::APPLICATION, 469 message_center::NotifierId(message_center::NotifierId::APPLICATION,
470 kDriveHostedAppId), 470 kDriveHostedAppId),
471 data, new DriveOfflineNotificationDelegate(profile_))); 471 data, new DriveOfflineNotificationDelegate(profile_)));
472 notification->set_priority(message_center::LOW_PRIORITY); 472 notification->set_priority(message_center::LOW_PRIORITY);
473 message_center::MessageCenter::Get()->AddNotification( 473 message_center::MessageCenter::Get()->AddNotification(
474 std::move(notification)); 474 std::move(notification));
475 } 475 }
476 476
477 } // namespace chromeos 477 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698