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

Side by Side Diff: chrome/browser/chromeos/policy/device_status_collector.cc

Issue 355203007: Remove enterprise device user report size limit. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 5 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
« no previous file with comments | « no previous file | chrome/browser/chromeos/policy/device_status_collector_browsertest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/chromeos/policy/device_status_collector.h" 5 #include "chrome/browser/chromeos/policy/device_status_collector.h"
6 6
7 #include <limits> 7 #include <limits>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/bind_helpers.h" 10 #include "base/bind_helpers.h"
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
65 const char kTimestamp[] = "timestamp"; 65 const char kTimestamp[] = "timestamp";
66 66
67 // Determine the day key (milliseconds since epoch for corresponding day in UTC) 67 // Determine the day key (milliseconds since epoch for corresponding day in UTC)
68 // for a given |timestamp|. 68 // for a given |timestamp|.
69 int64 TimestampToDayKey(Time timestamp) { 69 int64 TimestampToDayKey(Time timestamp) {
70 Time::Exploded exploded; 70 Time::Exploded exploded;
71 timestamp.LocalMidnight().LocalExplode(&exploded); 71 timestamp.LocalMidnight().LocalExplode(&exploded);
72 return (Time::FromUTCExploded(exploded) - Time::UnixEpoch()).InMilliseconds(); 72 return (Time::FromUTCExploded(exploded) - Time::UnixEpoch()).InMilliseconds();
73 } 73 }
74 74
75 // Maximum number of users to report.
76 const int kMaxUserCount = 5;
77
78 } // namespace 75 } // namespace
79 76
80 namespace policy { 77 namespace policy {
81 78
82 DeviceStatusCollector::DeviceStatusCollector( 79 DeviceStatusCollector::DeviceStatusCollector(
83 PrefService* local_state, 80 PrefService* local_state,
84 chromeos::system::StatisticsProvider* provider, 81 chromeos::system::StatisticsProvider* provider,
85 LocationUpdateRequester* location_update_requester) 82 LocationUpdateRequester* location_update_requester)
86 : max_stored_past_activity_days_(kMaxStoredPastActivityDays), 83 : max_stored_past_activity_days_(kMaxStoredPastActivityDays),
87 max_stored_future_activity_days_(kMaxStoredFutureActivityDays), 84 max_stored_future_activity_days_(kMaxStoredFutureActivityDays),
(...skipping 335 matching lines...) Expand 10 before | Expand all | Expand 10 after
423 if (!(*device)->meid().empty()) 420 if (!(*device)->meid().empty())
424 interface->set_meid((*device)->meid()); 421 interface->set_meid((*device)->meid());
425 if (!(*device)->imei().empty()) 422 if (!(*device)->imei().empty())
426 interface->set_imei((*device)->imei()); 423 interface->set_imei((*device)->imei());
427 } 424 }
428 } 425 }
429 426
430 void DeviceStatusCollector::GetUsers(em::DeviceStatusReportRequest* request) { 427 void DeviceStatusCollector::GetUsers(em::DeviceStatusReportRequest* request) {
431 policy::BrowserPolicyConnectorChromeOS* connector = 428 policy::BrowserPolicyConnectorChromeOS* connector =
432 g_browser_process->platform_part()->browser_policy_connector_chromeos(); 429 g_browser_process->platform_part()->browser_policy_connector_chromeos();
433 bool found_managed_user = false;
434 const chromeos::UserList& users = chromeos::UserManager::Get()->GetUsers(); 430 const chromeos::UserList& users = chromeos::UserManager::Get()->GetUsers();
435 chromeos::UserList::const_iterator user; 431 chromeos::UserList::const_iterator user;
436 for (user = users.begin(); user != users.end(); ++user) { 432 for (user = users.begin(); user != users.end(); ++user) {
437 // Only regular users are reported. 433 // Only regular users are reported.
438 if ((*user)->GetType() != chromeos::User::USER_TYPE_REGULAR) 434 if ((*user)->GetType() != chromeos::User::USER_TYPE_REGULAR)
439 continue; 435 continue;
440 436
441 em::DeviceUser* device_user = request->add_user(); 437 em::DeviceUser* device_user = request->add_user();
442 const std::string& email = (*user)->email(); 438 const std::string& email = (*user)->email();
443 if (connector->GetUserAffiliation(email) == USER_AFFILIATION_MANAGED) { 439 if (connector->GetUserAffiliation(email) == USER_AFFILIATION_MANAGED) {
444 device_user->set_type(em::DeviceUser::USER_TYPE_MANAGED); 440 device_user->set_type(em::DeviceUser::USER_TYPE_MANAGED);
445 device_user->set_email(email); 441 device_user->set_email(email);
446 found_managed_user = true;
447 } else { 442 } else {
448 device_user->set_type(em::DeviceUser::USER_TYPE_UNMANAGED); 443 device_user->set_type(em::DeviceUser::USER_TYPE_UNMANAGED);
449 // Do not report the email address of unmanaged users. 444 // Do not report the email address of unmanaged users.
450 } 445 }
451
452 // Add only kMaxUserCount entries, unless no managed users are found in the
453 // first kMaxUserCount users. In that case, continue until at least one
454 // managed user is found.
455 if (request->user_size() >= kMaxUserCount && found_managed_user)
456 break;
457 } 446 }
458 } 447 }
459 448
460 void DeviceStatusCollector::GetStatus(em::DeviceStatusReportRequest* request) { 449 void DeviceStatusCollector::GetStatus(em::DeviceStatusReportRequest* request) {
461 // TODO(mnissler): Remove once the old cloud policy stack is retired. The old 450 // TODO(mnissler): Remove once the old cloud policy stack is retired. The old
462 // stack doesn't support reporting successful submissions back to here, so 451 // stack doesn't support reporting successful submissions back to here, so
463 // just assume whatever ends up in |request| gets submitted successfully. 452 // just assume whatever ends up in |request| gets submitted successfully.
464 GetDeviceStatus(request); 453 GetDeviceStatus(request);
465 OnSubmittedSuccessfully(); 454 OnSubmittedSuccessfully();
466 } 455 }
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after
559 location.SetDouble(kSpeed, position.speed); 548 location.SetDouble(kSpeed, position.speed);
560 location.SetString(kTimestamp, 549 location.SetString(kTimestamp,
561 base::Int64ToString(position.timestamp.ToInternalValue())); 550 base::Int64ToString(position.timestamp.ToInternalValue()));
562 local_state_->Set(prefs::kDeviceLocation, location); 551 local_state_->Set(prefs::kDeviceLocation, location);
563 } 552 }
564 553
565 ScheduleGeolocationUpdateRequest(); 554 ScheduleGeolocationUpdateRequest();
566 } 555 }
567 556
568 } // namespace policy 557 } // namespace policy
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/chromeos/policy/device_status_collector_browsertest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698