Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2015 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2015 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 <utility> | 5 #include <utility> |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/bind_helpers.h" | 8 #include "base/bind_helpers.h" |
| 9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
| 10 #include "base/files/file_util.h" | 10 #include "base/files/file_util.h" |
| 11 #include "base/memory/ptr_util.h" | 11 #include "base/memory/ptr_util.h" |
| 12 #include "base/strings/string_number_conversions.h" | 12 #include "base/strings/string_number_conversions.h" |
| 13 #include "base/strings/stringprintf.h" | 13 #include "base/strings/stringprintf.h" |
| 14 #include "base/task_runner_util.h" | 14 #include "base/task_runner_util.h" |
| 15 #include "base/thread_task_runner_handle.h" | |
| 15 #include "chrome/browser/browser_process.h" | 16 #include "chrome/browser/browser_process.h" |
| 16 #include "chrome/browser/chromeos/policy/upload_job_impl.h" | 17 #include "chrome/browser/chromeos/policy/upload_job_impl.h" |
| 17 #include "chrome/browser/chromeos/settings/device_oauth2_token_service.h" | 18 #include "chrome/browser/chromeos/settings/device_oauth2_token_service.h" |
| 18 #include "chrome/browser/chromeos/settings/device_oauth2_token_service_factory.h " | 19 #include "chrome/browser/chromeos/settings/device_oauth2_token_service_factory.h " |
| 19 #include "chrome/common/chrome_switches.h" | 20 #include "chrome/common/chrome_switches.h" |
| 20 #include "components/feedback/anonymizer_tool.h" | 21 #include "components/feedback/anonymizer_tool.h" |
| 21 #include "components/policy/core/browser/browser_policy_connector.h" | 22 #include "components/policy/core/browser/browser_policy_connector.h" |
| 22 #include "content/public/browser/browser_thread.h" | 23 #include "content/public/browser/browser_thread.h" |
| 23 #include "net/http/http_request_headers.h" | 24 #include "net/http/http_request_headers.h" |
| 24 #include "system_log_uploader.h" | 25 #include "system_log_uploader.h" |
| (...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 97 chromeos::DeviceOAuth2TokenService* device_oauth2_token_service = | 98 chromeos::DeviceOAuth2TokenService* device_oauth2_token_service = |
| 98 chromeos::DeviceOAuth2TokenServiceFactory::Get(); | 99 chromeos::DeviceOAuth2TokenServiceFactory::Get(); |
| 99 | 100 |
| 100 scoped_refptr<net::URLRequestContextGetter> system_request_context = | 101 scoped_refptr<net::URLRequestContextGetter> system_request_context = |
| 101 g_browser_process->system_request_context(); | 102 g_browser_process->system_request_context(); |
| 102 std::string robot_account_id = | 103 std::string robot_account_id = |
| 103 device_oauth2_token_service->GetRobotAccountId(); | 104 device_oauth2_token_service->GetRobotAccountId(); |
| 104 return std::unique_ptr<policy::UploadJob>(new policy::UploadJobImpl( | 105 return std::unique_ptr<policy::UploadJob>(new policy::UploadJobImpl( |
| 105 upload_url, robot_account_id, device_oauth2_token_service, | 106 upload_url, robot_account_id, device_oauth2_token_service, |
| 106 system_request_context, delegate, | 107 system_request_context, delegate, |
| 107 base::WrapUnique( | 108 base::WrapUnique(new policy::UploadJobImpl::RandomMimeBoundaryGenerator), |
| 108 new policy::UploadJobImpl::RandomMimeBoundaryGenerator))); | 109 base::ThreadTaskRunnerHandle::Get())); |
|
Andrew T Wilson (Slow)
2016/05/02 09:15:49
Why not use task_runner_ here? If there's a reason
Marton Hunyady
2016/05/04 11:26:41
Done.
| |
| 109 } | 110 } |
| 110 | 111 |
| 111 // Returns the system log upload frequency. | 112 // Returns the system log upload frequency. |
| 112 base::TimeDelta GetUploadFrequency() { | 113 base::TimeDelta GetUploadFrequency() { |
| 113 base::TimeDelta upload_frequency(base::TimeDelta::FromMilliseconds( | 114 base::TimeDelta upload_frequency(base::TimeDelta::FromMilliseconds( |
| 114 policy::SystemLogUploader::kDefaultUploadDelayMs)); | 115 policy::SystemLogUploader::kDefaultUploadDelayMs)); |
| 115 if (base::CommandLine::ForCurrentProcess()->HasSwitch( | 116 if (base::CommandLine::ForCurrentProcess()->HasSwitch( |
| 116 switches::kSystemLogUploadFrequency)) { | 117 switches::kSystemLogUploadFrequency)) { |
| 117 std::string string_value = | 118 std::string string_value = |
| 118 base::CommandLine::ForCurrentProcess()->GetSwitchValueASCII( | 119 base::CommandLine::ForCurrentProcess()->GetSwitchValueASCII( |
| (...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 286 base::TimeDelta()); | 287 base::TimeDelta()); |
| 287 // Ensure that we never have more than one pending delayed task. | 288 // Ensure that we never have more than one pending delayed task. |
| 288 weak_factory_.InvalidateWeakPtrs(); | 289 weak_factory_.InvalidateWeakPtrs(); |
| 289 task_runner_->PostDelayedTask(FROM_HERE, | 290 task_runner_->PostDelayedTask(FROM_HERE, |
| 290 base::Bind(&SystemLogUploader::StartLogUpload, | 291 base::Bind(&SystemLogUploader::StartLogUpload, |
| 291 weak_factory_.GetWeakPtr()), | 292 weak_factory_.GetWeakPtr()), |
| 292 delay); | 293 delay); |
| 293 } | 294 } |
| 294 | 295 |
| 295 } // namespace policy | 296 } // namespace policy |
| OLD | NEW |