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

Side by Side Diff: chrome/browser/background/background_contents_service.cc

Issue 14113053: chrome: Use base::MessageLoop. (Part 3) (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 8 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) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/background/background_contents_service.h" 5 #include "chrome/browser/background/background_contents_service.h"
6 6
7 #include "base/basictypes.h" 7 #include "base/basictypes.h"
8 #include "base/bind.h" 8 #include "base/bind.h"
9 #include "base/command_line.h" 9 #include "base/command_line.h"
10 #include "base/message_loop.h" 10 #include "base/message_loop.h"
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
49 49
50 namespace { 50 namespace {
51 51
52 const char kNotificationPrefix[] = "app.background.crashed."; 52 const char kNotificationPrefix[] = "app.background.crashed.";
53 53
54 void CloseBalloon(const std::string id) { 54 void CloseBalloon(const std::string id) {
55 g_browser_process->notification_ui_manager()->CancelById(id); 55 g_browser_process->notification_ui_manager()->CancelById(id);
56 } 56 }
57 57
58 void ScheduleCloseBalloon(const std::string& extension_id) { 58 void ScheduleCloseBalloon(const std::string& extension_id) {
59 if (!MessageLoop::current()) // For unit_tests 59 if (!base::MessageLoop::current()) // For unit_tests
60 return; 60 return;
61 MessageLoop::current()->PostTask( 61 base::MessageLoop::current()->PostTask(
62 FROM_HERE, base::Bind(&CloseBalloon, kNotificationPrefix + extension_id)); 62 FROM_HERE, base::Bind(&CloseBalloon, kNotificationPrefix + extension_id));
63 } 63 }
64 64
65 class CrashNotificationDelegate : public NotificationDelegate { 65 class CrashNotificationDelegate : public NotificationDelegate {
66 public: 66 public:
67 CrashNotificationDelegate(Profile* profile, 67 CrashNotificationDelegate(Profile* profile,
68 const Extension* extension) 68 const Extension* extension)
69 : profile_(profile), 69 : profile_(profile),
70 is_hosted_app_(extension->is_hosted_app()), 70 is_hosted_app_(extension->is_hosted_app()),
71 is_platform_app_(extension->is_platform_app()), 71 is_platform_app_(extension->is_platform_app()),
(...skipping 250 matching lines...) Expand 10 before | Expand all | Expand 10 after
322 extension = extension_host->extension(); 322 extension = extension_host->extension();
323 } 323 }
324 if (!extension) 324 if (!extension)
325 break; 325 break;
326 326
327 // When an extension crashes, EXTENSION_PROCESS_TERMINATED is followed by 327 // When an extension crashes, EXTENSION_PROCESS_TERMINATED is followed by
328 // an EXTENSION_UNLOADED notification. This UNLOADED signal causes all the 328 // an EXTENSION_UNLOADED notification. This UNLOADED signal causes all the
329 // notifications for this extension to be cancelled by 329 // notifications for this extension to be cancelled by
330 // DesktopNotificationService. For this reason, instead of showing the 330 // DesktopNotificationService. For this reason, instead of showing the
331 // balloon right now, we schedule it to show a little later. 331 // balloon right now, we schedule it to show a little later.
332 MessageLoop::current()->PostTask( 332 base::MessageLoop::current()->PostTask(
333 FROM_HERE, base::Bind(&ShowBalloon, extension, profile)); 333 FROM_HERE, base::Bind(&ShowBalloon, extension, profile));
334 break; 334 break;
335 } 335 }
336 case chrome::NOTIFICATION_EXTENSION_UNLOADED: 336 case chrome::NOTIFICATION_EXTENSION_UNLOADED:
337 switch (content::Details<UnloadedExtensionInfo>(details)->reason) { 337 switch (content::Details<UnloadedExtensionInfo>(details)->reason) {
338 case extension_misc::UNLOAD_REASON_DISABLE: // Fall through. 338 case extension_misc::UNLOAD_REASON_DISABLE: // Fall through.
339 case extension_misc::UNLOAD_REASON_TERMINATE: // Fall through. 339 case extension_misc::UNLOAD_REASON_TERMINATE: // Fall through.
340 case extension_misc::UNLOAD_REASON_UNINSTALL: // Fall through. 340 case extension_misc::UNLOAD_REASON_UNINSTALL: // Fall through.
341 case extension_misc::UNLOAD_REASON_BLACKLIST: 341 case extension_misc::UNLOAD_REASON_BLACKLIST:
342 ShutdownAssociatedBackgroundContents( 342 ShutdownAssociatedBackgroundContents(
(...skipping 294 matching lines...) Expand 10 before | Expand all | Expand 10 after
637 bool user_gesture, 637 bool user_gesture,
638 bool* was_blocked) { 638 bool* was_blocked) {
639 Browser* browser = chrome::FindLastActiveWithProfile( 639 Browser* browser = chrome::FindLastActiveWithProfile(
640 Profile::FromBrowserContext(new_contents->GetBrowserContext()), 640 Profile::FromBrowserContext(new_contents->GetBrowserContext()),
641 chrome::GetActiveDesktop()); 641 chrome::GetActiveDesktop());
642 if (browser) { 642 if (browser) {
643 chrome::AddWebContents(browser, NULL, new_contents, disposition, 643 chrome::AddWebContents(browser, NULL, new_contents, disposition,
644 initial_pos, user_gesture, was_blocked); 644 initial_pos, user_gesture, was_blocked);
645 } 645 }
646 } 646 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698