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

Side by Side Diff: chrome/browser/policy/cloud/user_cloud_policy_invalidator.cc

Issue 465433002: Separate UMA histograms for user and device policy invalidation (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Nesting preprocessor directives inside macros does not work under Windows. Created 6 years, 4 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 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/policy/cloud/user_cloud_policy_invalidator.h" 5 #include "chrome/browser/policy/cloud/user_cloud_policy_invalidator.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/memory/scoped_ptr.h" 8 #include "base/memory/scoped_ptr.h"
9 #include "base/message_loop/message_loop_proxy.h" 9 #include "base/message_loop/message_loop_proxy.h"
10 #include "base/time/default_clock.h" 10 #include "base/time/default_clock.h"
11 #include "chrome/browser/chrome_notification_types.h" 11 #include "chrome/browser/chrome_notification_types.h"
12 #include "chrome/browser/invalidation/profile_invalidation_provider_factory.h" 12 #include "chrome/browser/invalidation/profile_invalidation_provider_factory.h"
13 #include "components/invalidation/profile_invalidation_provider.h" 13 #include "components/invalidation/profile_invalidation_provider.h"
14 #include "components/policy/core/common/cloud/cloud_policy_manager.h" 14 #include "components/policy/core/common/cloud/cloud_policy_manager.h"
15 #include "content/public/browser/notification_source.h" 15 #include "content/public/browser/notification_source.h"
16 16
17 namespace policy { 17 namespace policy {
18 18
19 UserCloudPolicyInvalidator::UserCloudPolicyInvalidator( 19 UserCloudPolicyInvalidator::UserCloudPolicyInvalidator(
20 Profile* profile, 20 Profile* profile,
21 CloudPolicyManager* policy_manager) 21 CloudPolicyManager* policy_manager)
22 : CloudPolicyInvalidator( 22 : CloudPolicyInvalidator(GetPolicyType(),
23 policy_manager->core(), 23 policy_manager->core(),
24 base::MessageLoopProxy::current(), 24 base::MessageLoopProxy::current(),
25 scoped_ptr<base::Clock>(new base::DefaultClock())), 25 scoped_ptr<base::Clock>(new base::DefaultClock())),
26 profile_(profile) { 26 profile_(profile) {
27 DCHECK(profile); 27 DCHECK(profile);
28 28
29 // Register for notification that profile creation is complete. The 29 // Register for notification that profile creation is complete. The
30 // invalidator must not be initialized before then because the invalidation 30 // invalidator must not be initialized before then because the invalidation
31 // service cannot be started because it depends on components initialized 31 // service cannot be started because it depends on components initialized
32 // after this object is instantiated. 32 // after this object is instantiated.
33 // TODO(stepco): Delayed initialization can be removed once the request 33 // TODO(stepco): Delayed initialization can be removed once the request
34 // context can be accessed during profile-keyed service creation. Tracked by 34 // context can be accessed during profile-keyed service creation. Tracked by
35 // bug 286209. 35 // bug 286209.
36 registrar_.Add(this, 36 registrar_.Add(this,
37 chrome::NOTIFICATION_PROFILE_ADDED, 37 chrome::NOTIFICATION_PROFILE_ADDED,
38 content::Source<Profile>(profile)); 38 content::Source<Profile>(profile));
39 } 39 }
40 40
41 // static
42 enterprise_management::DeviceRegisterRequest::Type
43 UserCloudPolicyInvalidator::GetPolicyType() {
44 #if defined(OS_CHROMEOS)
45 return enterprise_management::DeviceRegisterRequest::USER;
46 #elif defined(OS_ANDROID)
47 return enterprise_management::DeviceRegisterRequest::ANDROID_BROWSER;
48 #elif defined(OS_IOS)
49 return enterprise_management::DeviceRegisterRequest::IOS_BROWSER;
50 #else
51 return enterprise_management::DeviceRegisterRequest::BROWSER;
52 #endif
53 }
54
41 void UserCloudPolicyInvalidator::Shutdown() { 55 void UserCloudPolicyInvalidator::Shutdown() {
42 CloudPolicyInvalidator::Shutdown(); 56 CloudPolicyInvalidator::Shutdown();
43 } 57 }
44 58
45 void UserCloudPolicyInvalidator::Observe( 59 void UserCloudPolicyInvalidator::Observe(
46 int type, 60 int type,
47 const content::NotificationSource& source, 61 const content::NotificationSource& source,
48 const content::NotificationDetails& details) { 62 const content::NotificationDetails& details) {
49 // Initialize now that profile creation is complete and the invalidation 63 // Initialize now that profile creation is complete and the invalidation
50 // service can safely be initialized. 64 // service can safely be initialized.
51 DCHECK(type == chrome::NOTIFICATION_PROFILE_ADDED); 65 DCHECK(type == chrome::NOTIFICATION_PROFILE_ADDED);
52 invalidation::ProfileInvalidationProvider* invalidation_provider = 66 invalidation::ProfileInvalidationProvider* invalidation_provider =
53 invalidation::ProfileInvalidationProviderFactory::GetForProfile(profile_); 67 invalidation::ProfileInvalidationProviderFactory::GetForProfile(profile_);
54 if (invalidation_provider) 68 if (invalidation_provider)
55 Initialize(invalidation_provider->GetInvalidationService()); 69 Initialize(invalidation_provider->GetInvalidationService());
56 } 70 }
57 71
58 } // namespace policy 72 } // namespace policy
OLDNEW
« no previous file with comments | « chrome/browser/policy/cloud/user_cloud_policy_invalidator.h ('k') | components/policy/core/common/cloud/enterprise_metrics.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698