| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 "remoting/base/telemetry_log_writer.h" | 5 #include "remoting/base/telemetry_log_writer.h" |
| 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/json/json_string_value_serializer.h" | 9 #include "base/json/json_string_value_serializer.h" |
| 10 #include "base/logging.h" | 10 #include "base/logging.h" |
| 11 #include "net/http/http_status_code.h" | 11 #include "net/http/http_status_code.h" |
| 12 | 12 |
| 13 namespace remoting { | 13 namespace remoting { |
| 14 | 14 |
| 15 const int kMaxSendAttempts = 5; | 15 const int kMaxSendAttempts = 5; |
| 16 | 16 |
| 17 TelemetryLogWriter::TelemetryLogWriter( | 17 TelemetryLogWriter::TelemetryLogWriter( |
| 18 const std::string& telemetry_base_url, | 18 const std::string& telemetry_base_url, |
| 19 std::unique_ptr<UrlRequestFactory> request_factory) | 19 std::unique_ptr<UrlRequestFactory> request_factory) |
| 20 : telemetry_base_url_(telemetry_base_url), | 20 : telemetry_base_url_(telemetry_base_url), |
| 21 request_factory_(std::move(request_factory)) {} | 21 request_factory_(std::move(request_factory)) {} |
| 22 |
| 22 TelemetryLogWriter::~TelemetryLogWriter() {} | 23 TelemetryLogWriter::~TelemetryLogWriter() {} |
| 23 | 24 |
| 24 void TelemetryLogWriter::SetAuthToken(const std::string& auth_token) { | 25 void TelemetryLogWriter::SetAuthToken(const std::string& auth_token) { |
| 25 DCHECK(thread_checker_.CalledOnValidThread()); | 26 DCHECK(thread_checker_.CalledOnValidThread()); |
| 26 auth_token_ = auth_token; | 27 auth_token_ = auth_token; |
| 27 SendPendingEntries(); | 28 SendPendingEntries(); |
| 28 } | 29 } |
| 29 | 30 |
| 30 void TelemetryLogWriter::SetAuthClosure(const base::Closure& closure) { | 31 void TelemetryLogWriter::SetAuthClosure(const base::Closure& closure) { |
| 31 DCHECK(thread_checker_.CalledOnValidThread()); | 32 DCHECK(thread_checker_.CalledOnValidThread()); |
| (...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 107 request_.reset(); // This may also destroy the result. | 108 request_.reset(); // This may also destroy the result. |
| 108 if (should_call_auth_closure) { | 109 if (should_call_auth_closure) { |
| 109 VLOG(1) << "Request is unauthorized. Trying to call the auth closure..."; | 110 VLOG(1) << "Request is unauthorized. Trying to call the auth closure..."; |
| 110 auth_closure_.Run(); | 111 auth_closure_.Run(); |
| 111 } else { | 112 } else { |
| 112 SendPendingEntries(); | 113 SendPendingEntries(); |
| 113 } | 114 } |
| 114 } | 115 } |
| 115 | 116 |
| 116 } // namespace remoting | 117 } // namespace remoting |
| OLD | NEW |