| 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 #include "net/traffic_annotation/network_traffic_annotation.h" | 12 #include "net/traffic_annotation/network_traffic_annotation.h" |
| 13 | 13 |
| 14 namespace remoting { | 14 namespace remoting { |
| 15 | 15 |
| 16 const int kMaxSendAttempts = 5; | 16 const int kMaxSendAttempts = 5; |
| 17 | 17 |
| 18 TelemetryLogWriter::TelemetryLogWriter( | 18 TelemetryLogWriter::TelemetryLogWriter( |
| 19 const std::string& telemetry_base_url, | 19 const std::string& telemetry_base_url, |
| 20 std::unique_ptr<UrlRequestFactory> request_factory) | 20 std::unique_ptr<UrlRequestFactory> request_factory) |
| 21 : telemetry_base_url_(telemetry_base_url), | 21 : telemetry_base_url_(telemetry_base_url), |
| 22 request_factory_(std::move(request_factory)) {} | 22 request_factory_(std::move(request_factory)) {} |
| 23 | 23 |
| 24 TelemetryLogWriter::~TelemetryLogWriter() {} | 24 TelemetryLogWriter::~TelemetryLogWriter() { |
| 25 DCHECK(thread_checker_.CalledOnValidThread()); |
| 26 } |
| 25 | 27 |
| 26 void TelemetryLogWriter::SetAuthToken(const std::string& auth_token) { | 28 void TelemetryLogWriter::SetAuthToken(const std::string& auth_token) { |
| 27 DCHECK(thread_checker_.CalledOnValidThread()); | 29 DCHECK(thread_checker_.CalledOnValidThread()); |
| 28 auth_token_ = auth_token; | 30 auth_token_ = auth_token; |
| 29 SendPendingEntries(); | 31 SendPendingEntries(); |
| 30 } | 32 } |
| 31 | 33 |
| 32 void TelemetryLogWriter::SetAuthClosure(const base::Closure& closure) { | 34 void TelemetryLogWriter::SetAuthClosure(const base::Closure& closure) { |
| 33 DCHECK(thread_checker_.CalledOnValidThread()); | 35 DCHECK(thread_checker_.CalledOnValidThread()); |
| 34 auth_closure_ = closure; | 36 auth_closure_ = closure; |
| (...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 132 request_.reset(); // This may also destroy the result. | 134 request_.reset(); // This may also destroy the result. |
| 133 if (should_call_auth_closure) { | 135 if (should_call_auth_closure) { |
| 134 VLOG(1) << "Request is unauthorized. Trying to call the auth closure..."; | 136 VLOG(1) << "Request is unauthorized. Trying to call the auth closure..."; |
| 135 auth_closure_.Run(); | 137 auth_closure_.Run(); |
| 136 } else { | 138 } else { |
| 137 SendPendingEntries(); | 139 SendPendingEntries(); |
| 138 } | 140 } |
| 139 } | 141 } |
| 140 | 142 |
| 141 } // namespace remoting | 143 } // namespace remoting |
| OLD | NEW |