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

Side by Side Diff: chrome/browser/notifications/profile_notification.cc

Issue 2719813005: CrOS: Add print statements to help debug BrowserProcessImpl::Unpin crash. (Closed)
Patch Set: Added dumps. Created 3 years, 9 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 #include "chrome/browser/notifications/profile_notification.h" 5 #include "chrome/browser/notifications/profile_notification.h"
6 6
7 #include "base/strings/stringprintf.h" 7 #include "base/strings/stringprintf.h"
8 #include "build/build_config.h" 8 #include "build/build_config.h"
9 #include "chrome/browser/chrome_notification_types.h"
9 #include "chrome/browser/lifetime/keep_alive_types.h" 10 #include "chrome/browser/lifetime/keep_alive_types.h"
10 #include "chrome/browser/lifetime/scoped_keep_alive.h" 11 #include "chrome/browser/lifetime/scoped_keep_alive.h"
11 #include "chrome/browser/ui/ash/multi_user/multi_user_util.h" 12 #include "chrome/browser/ui/ash/multi_user/multi_user_util.h"
12 #include "components/signin/core/account_id/account_id.h" 13 #include "components/signin/core/account_id/account_id.h"
14 #include "content/public/browser/notification_service.h"
13 15
14 // static 16 // static
15 std::string ProfileNotification::GetProfileNotificationId( 17 std::string ProfileNotification::GetProfileNotificationId(
16 const std::string& delegate_id, 18 const std::string& delegate_id,
17 ProfileID profile_id) { 19 ProfileID profile_id) {
18 DCHECK(profile_id); 20 DCHECK(profile_id);
19 return base::StringPrintf("notification-ui-manager#%p#%s", 21 return base::StringPrintf("notification-ui-manager#%p#%s",
20 profile_id, // Each profile has its unique instance 22 profile_id, // Each profile has its unique instance
21 // including incognito profile. 23 // including incognito profile.
22 delegate_id.c_str()); 24 delegate_id.c_str());
23 } 25 }
24 26
25 ProfileNotification::ProfileNotification(Profile* profile, 27 ProfileNotification::ProfileNotification(Profile* profile,
26 const Notification& notification) 28 const Notification& notification)
27 : profile_id_(NotificationUIManager::GetProfileID(profile)), 29 : profile_id_(NotificationUIManager::GetProfileID(profile)),
28 notification_( 30 notification_(
29 // Uses Notification's copy constructor to assign the message center 31 // Uses Notification's copy constructor to assign the message center
30 // id, which should be unique for every profile + Notification pair. 32 // id, which should be unique for every profile + Notification pair.
31 GetProfileNotificationId( 33 GetProfileNotificationId(
32 notification.delegate_id(), 34 notification.delegate_id(),
33 NotificationUIManager::GetProfileID(profile)), 35 NotificationUIManager::GetProfileID(profile)),
34 notification), 36 notification),
35 keep_alive_(new ScopedKeepAlive(KeepAliveOrigin::NOTIFICATION, 37 keep_alive_(new ScopedKeepAlive(KeepAliveOrigin::NOTIFICATION,
36 KeepAliveRestartOption::DISABLED)) { 38 KeepAliveRestartOption::DISABLED)) {
37 DCHECK(profile); 39 DCHECK(profile);
38 #if defined(OS_CHROMEOS) 40 #if defined(OS_CHROMEOS)
39 notification_.set_profile_id( 41 notification_.set_profile_id(
40 multi_user_util::GetAccountIdFromProfile(profile).GetUserEmail()); 42 multi_user_util::GetAccountIdFromProfile(profile).GetUserEmail());
41 #endif 43 #endif
44
45 registrar_.Add(this, chrome::NOTIFICATION_APP_TERMINATING,
46 content::NotificationService::AllSources());
47 registrar_.Add(this, chrome::NOTIFICATION_CLOSE_ALL_BROWSERS_REQUEST,
48 content::NotificationService::AllSources());
42 } 49 }
43 50
44 ProfileNotification::~ProfileNotification() {} 51 ProfileNotification::~ProfileNotification() {}
52
53 void ProfileNotification::Observe(int type,
54 const content::NotificationSource& source,
55 const content::NotificationDetails& details) {
56 switch (type) {
57 case chrome::NOTIFICATION_APP_TERMINATING: {
58 VLOG(1) << "ProfileNotification Terminating";
sky 2017/03/22 03:56:16 If you really need to log this information, add it
59 break;
60 }
61 case chrome::NOTIFICATION_CLOSE_ALL_BROWSERS_REQUEST: {
62 VLOG(1) << "ProfileNotification Close All Browsers Request";
63 break;
64 }
65 }
66 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698