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/device_management_backend_impl.cc

Issue 7105018: UMA metrics for cloud policies. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fixed detection of some events, rebased Created 9 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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/device_management_backend_impl.h" 5 #include "chrome/browser/policy/device_management_backend_impl.h"
6 6
7 #include <utility> 7 #include <utility>
8 #include <vector> 8 #include <vector>
9 9
10 #if defined(OS_POSIX) && !defined(OS_MACOSX) 10 #if defined(OS_POSIX) && !defined(OS_MACOSX)
11 #include <sys/utsname.h> 11 #include <sys/utsname.h>
12 #endif 12 #endif
13 13
14 #include "base/stringprintf.h" 14 #include "base/stringprintf.h"
15 #include "base/sys_info.h" 15 #include "base/sys_info.h"
16 #include "chrome/browser/policy/device_management_service.h" 16 #include "chrome/browser/policy/device_management_service.h"
17 #include "chrome/browser/policy/enterprise_metrics.h"
17 #include "chrome/common/chrome_version_info.h" 18 #include "chrome/common/chrome_version_info.h"
18 #include "net/base/escape.h" 19 #include "net/base/escape.h"
19 #include "net/url_request/url_request_status.h" 20 #include "net/url_request/url_request_status.h"
20 21
21 #if defined(OS_CHROMEOS) 22 #if defined(OS_CHROMEOS)
22 #include "chrome/browser/chromeos/system_access.h" 23 #include "chrome/browser/chromeos/system_access.h"
23 #endif 24 #endif
24 25
25 namespace policy { 26 namespace policy {
26 27
28 namespace em = enterprise_management;
29
27 // Name constants for URL query parameters. 30 // Name constants for URL query parameters.
28 const char DeviceManagementBackendImpl::kParamRequest[] = "request"; 31 const char DeviceManagementBackendImpl::kParamRequest[] = "request";
29 const char DeviceManagementBackendImpl::kParamDeviceType[] = "devicetype"; 32 const char DeviceManagementBackendImpl::kParamDeviceType[] = "devicetype";
30 const char DeviceManagementBackendImpl::kParamAppType[] = "apptype"; 33 const char DeviceManagementBackendImpl::kParamAppType[] = "apptype";
31 const char DeviceManagementBackendImpl::kParamDeviceID[] = "deviceid"; 34 const char DeviceManagementBackendImpl::kParamDeviceID[] = "deviceid";
32 const char DeviceManagementBackendImpl::kParamAgent[] = "agent"; 35 const char DeviceManagementBackendImpl::kParamAgent[] = "agent";
33 const char DeviceManagementBackendImpl::kParamPlatform[] = "platform"; 36 const char DeviceManagementBackendImpl::kParamPlatform[] = "platform";
34 37
35 // String constants for the device and app type we report to the server. 38 // String constants for the device and app type we report to the server.
36 const char DeviceManagementBackendImpl::kValueRequestRegister[] = "register"; 39 const char DeviceManagementBackendImpl::kValueRequestRegister[] = "register";
(...skipping 258 matching lines...) Expand 10 before | Expand all | Expand 10 after
295 SetAuthToken(auth_token); 298 SetAuthToken(auth_token);
296 em::DeviceManagementRequest request_wrapper; 299 em::DeviceManagementRequest request_wrapper;
297 request_wrapper.mutable_register_request()->CopyFrom(request); 300 request_wrapper.mutable_register_request()->CopyFrom(request);
298 SetPayload(request_wrapper); 301 SetPayload(request_wrapper);
299 } 302 }
300 virtual ~DeviceManagementRegisterJob() {} 303 virtual ~DeviceManagementRegisterJob() {}
301 304
302 private: 305 private:
303 // DeviceManagementJobBase overrides. 306 // DeviceManagementJobBase overrides.
304 virtual void OnError(DeviceManagementBackend::ErrorCode error) { 307 virtual void OnError(DeviceManagementBackend::ErrorCode error) {
308 switch (error) {
309 case DeviceManagementBackend::kErrorRequestInvalid:
310 case DeviceManagementBackend::kErrorRequestFailed:
311 em::LogTokenOperation(em::kTokenFetchRequestFailed);
312 break;
313 case DeviceManagementBackend::kErrorServiceDeviceNotFound:
314 em::LogTokenOperation(em::kTokenFetchDeviceNotFound);
315 break;
316 case DeviceManagementBackend::kErrorServiceManagementNotSupported:
317 em::LogTokenOperation(em::kTokenFetchManagementNotSupported);
318 break;
319 default:
320 em::LogTokenOperation(em::kTokenFetchServerFailed);
321 break;
322 }
305 delegate_->OnError(error); 323 delegate_->OnError(error);
306 } 324 }
307 virtual void OnResponse(const em::DeviceManagementResponse& response) { 325 virtual void OnResponse(const em::DeviceManagementResponse& response) {
326 em::LogTokenOperation(em::kTokenFetchResponseReceived);
308 delegate_->HandleRegisterResponse(response.register_response()); 327 delegate_->HandleRegisterResponse(response.register_response());
309 } 328 }
310 329
311 DeviceManagementBackend::DeviceRegisterResponseDelegate* delegate_; 330 DeviceManagementBackend::DeviceRegisterResponseDelegate* delegate_;
312 331
313 DISALLOW_COPY_AND_ASSIGN(DeviceManagementRegisterJob); 332 DISALLOW_COPY_AND_ASSIGN(DeviceManagementRegisterJob);
314 }; 333 };
315 334
316 // Handles device unregistration jobs. 335 // Handles device unregistration jobs.
317 class DeviceManagementUnregisterJob : public DeviceManagementJobBase { 336 class DeviceManagementUnregisterJob : public DeviceManagementJobBase {
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
365 SetDeviceManagementToken(device_management_token); 384 SetDeviceManagementToken(device_management_token);
366 em::DeviceManagementRequest request_wrapper; 385 em::DeviceManagementRequest request_wrapper;
367 request_wrapper.mutable_policy_request()->CopyFrom(request); 386 request_wrapper.mutable_policy_request()->CopyFrom(request);
368 SetPayload(request_wrapper); 387 SetPayload(request_wrapper);
369 } 388 }
370 virtual ~DeviceManagementPolicyJob() {} 389 virtual ~DeviceManagementPolicyJob() {}
371 390
372 private: 391 private:
373 // DeviceManagementJobBase overrides. 392 // DeviceManagementJobBase overrides.
374 virtual void OnError(DeviceManagementBackend::ErrorCode error) { 393 virtual void OnError(DeviceManagementBackend::ErrorCode error) {
394 switch (error) {
395 case DeviceManagementBackend::kErrorRequestInvalid:
396 case DeviceManagementBackend::kErrorRequestFailed:
397 em::LogPolicyOperation(em::kPolicyFetchRequestFailed);
398 break;
399 case DeviceManagementBackend::kErrorServicePolicyNotFound:
400 em::LogPolicyOperation(em::kPolicyFetchNotFound);
401 break;
402 case DeviceManagementBackend::kErrorServiceManagementTokenInvalid:
403 em::LogPolicyOperation(em::kPolicyFetchInvalidToken);
404 break;
405 default:
406 em::LogPolicyOperation(em::kPolicyFetchServerFailed);
407 break;
408 }
375 delegate_->OnError(error); 409 delegate_->OnError(error);
376 } 410 }
377 virtual void OnResponse(const em::DeviceManagementResponse& response) { 411 virtual void OnResponse(const em::DeviceManagementResponse& response) {
412 em::LogPolicyOperation(em::kPolicyFetchResponseReceived);
378 delegate_->HandlePolicyResponse(response.policy_response()); 413 delegate_->HandlePolicyResponse(response.policy_response());
379 } 414 }
380 415
381 DeviceManagementBackend::DevicePolicyResponseDelegate* delegate_; 416 DeviceManagementBackend::DevicePolicyResponseDelegate* delegate_;
382 417
383 DISALLOW_COPY_AND_ASSIGN(DeviceManagementPolicyJob); 418 DISALLOW_COPY_AND_ASSIGN(DeviceManagementPolicyJob);
384 }; 419 };
385 420
386 DeviceManagementBackendImpl::DeviceManagementBackendImpl( 421 DeviceManagementBackendImpl::DeviceManagementBackendImpl(
387 DeviceManagementService* service) 422 DeviceManagementService* service)
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
460 void DeviceManagementBackendImpl::AddJob(DeviceManagementJobBase* job) { 495 void DeviceManagementBackendImpl::AddJob(DeviceManagementJobBase* job) {
461 pending_jobs_.insert(job); 496 pending_jobs_.insert(job);
462 service_->AddJob(job); 497 service_->AddJob(job);
463 } 498 }
464 499
465 void DeviceManagementBackendImpl::ProcessRegisterRequest( 500 void DeviceManagementBackendImpl::ProcessRegisterRequest(
466 const std::string& auth_token, 501 const std::string& auth_token,
467 const std::string& device_id, 502 const std::string& device_id,
468 const em::DeviceRegisterRequest& request, 503 const em::DeviceRegisterRequest& request,
469 DeviceRegisterResponseDelegate* delegate) { 504 DeviceRegisterResponseDelegate* delegate) {
505 em::LogTokenOperation(em::kTokenFetchRequested);
470 AddJob(new DeviceManagementRegisterJob(this, auth_token, device_id, request, 506 AddJob(new DeviceManagementRegisterJob(this, auth_token, device_id, request,
471 delegate)); 507 delegate));
472 } 508 }
473 509
474 void DeviceManagementBackendImpl::ProcessUnregisterRequest( 510 void DeviceManagementBackendImpl::ProcessUnregisterRequest(
475 const std::string& device_management_token, 511 const std::string& device_management_token,
476 const std::string& device_id, 512 const std::string& device_id,
477 const em::DeviceUnregisterRequest& request, 513 const em::DeviceUnregisterRequest& request,
478 DeviceUnregisterResponseDelegate* delegate) { 514 DeviceUnregisterResponseDelegate* delegate) {
479 AddJob(new DeviceManagementUnregisterJob(this, device_management_token, 515 AddJob(new DeviceManagementUnregisterJob(this, device_management_token,
480 device_id, request, delegate)); 516 device_id, request, delegate));
481 } 517 }
482 518
483 void DeviceManagementBackendImpl::ProcessPolicyRequest( 519 void DeviceManagementBackendImpl::ProcessPolicyRequest(
484 const std::string& device_management_token, 520 const std::string& device_management_token,
485 const std::string& device_id, 521 const std::string& device_id,
486 const em::DevicePolicyRequest& request, 522 const em::DevicePolicyRequest& request,
487 DevicePolicyResponseDelegate* delegate) { 523 DevicePolicyResponseDelegate* delegate) {
524 em::LogPolicyOperation(em::kPolicyFetchRequested);
488 AddJob(new DeviceManagementPolicyJob(this, device_management_token, device_id, 525 AddJob(new DeviceManagementPolicyJob(this, device_management_token, device_id,
489 request, delegate)); 526 request, delegate));
490 } 527 }
491 528
492 } // namespace policy 529 } // namespace policy
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698