OLD | NEW |
1 // Copyright 2017 The Chromium Authors. All rights reserved. | 1 // Copyright 2017 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 // This file defines a service that sends metrics logs to a server. | 5 // This file defines a service that sends metrics logs to a server. |
6 | 6 |
7 #ifndef COMPONENTS_METRICS_REPORTING_SERVICE_H_ | 7 #ifndef COMPONENTS_METRICS_REPORTING_SERVICE_H_ |
8 #define COMPONENTS_METRICS_REPORTING_SERVICE_H_ | 8 #define COMPONENTS_METRICS_REPORTING_SERVICE_H_ |
9 | 9 |
10 #include <stdint.h> | 10 #include <stdint.h> |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
82 virtual LogStore* log_store() = 0; | 82 virtual LogStore* log_store() = 0; |
83 | 83 |
84 // Getters for MetricsLogUploader parameters. | 84 // Getters for MetricsLogUploader parameters. |
85 virtual std::string GetUploadUrl() const = 0; | 85 virtual std::string GetUploadUrl() const = 0; |
86 virtual base::StringPiece upload_mime_type() const = 0; | 86 virtual base::StringPiece upload_mime_type() const = 0; |
87 virtual MetricsLogUploader::MetricServiceType service_type() const = 0; | 87 virtual MetricsLogUploader::MetricServiceType service_type() const = 0; |
88 | 88 |
89 // Methods for recording data to histograms. | 89 // Methods for recording data to histograms. |
90 virtual void LogActualUploadInterval(base::TimeDelta interval) {} | 90 virtual void LogActualUploadInterval(base::TimeDelta interval) {} |
91 virtual void LogCellularConstraint(bool upload_canceled) {} | 91 virtual void LogCellularConstraint(bool upload_canceled) {} |
92 virtual void LogResponseCode(int response_code) {} | 92 virtual void LogResponseOrErrorCode(int response_code, int error_code) {} |
93 virtual void LogSuccess(size_t log_size) {} | 93 virtual void LogSuccess(size_t log_size) {} |
94 virtual void LogLargeRejection(size_t log_size) {} | 94 virtual void LogLargeRejection(size_t log_size) {} |
95 | 95 |
96 // If recording is enabled, begins uploading the next completed log from | 96 // If recording is enabled, begins uploading the next completed log from |
97 // the log manager, staging it if necessary. | 97 // the log manager, staging it if necessary. |
98 void SendNextLog(); | 98 void SendNextLog(); |
99 | 99 |
100 // Uploads the currently staged log (which must be non-null). | 100 // Uploads the currently staged log (which must be non-null). |
101 void SendStagedLog(); | 101 void SendStagedLog(); |
102 | 102 |
103 // Called after transmission completes (either successfully or with failure). | 103 // Called after transmission completes (either successfully or with failure). |
104 void OnLogUploadComplete(int response_code); | 104 void OnLogUploadComplete(int response_code, int error_code); |
105 | 105 |
106 // Used to interact with the embedder. Weak pointer; must outlive |this| | 106 // Used to interact with the embedder. Weak pointer; must outlive |this| |
107 // instance. | 107 // instance. |
108 MetricsServiceClient* const client_; | 108 MetricsServiceClient* const client_; |
109 | 109 |
110 // Largest log size to attempt to retransmit. | 110 // Largest log size to attempt to retransmit. |
111 size_t max_retransmit_size_; | 111 size_t max_retransmit_size_; |
112 | 112 |
113 // Indicate whether recording and reporting are currently happening. | 113 // Indicate whether recording and reporting are currently happening. |
114 // These should not be set directly, but by calling SetRecording and | 114 // These should not be set directly, but by calling SetRecording and |
(...skipping 22 matching lines...) Expand all Loading... |
137 // pointers managed by this factory have the same lifetime as | 137 // pointers managed by this factory have the same lifetime as |
138 // ReportingService. | 138 // ReportingService. |
139 base::WeakPtrFactory<ReportingService> self_ptr_factory_; | 139 base::WeakPtrFactory<ReportingService> self_ptr_factory_; |
140 | 140 |
141 DISALLOW_COPY_AND_ASSIGN(ReportingService); | 141 DISALLOW_COPY_AND_ASSIGN(ReportingService); |
142 }; | 142 }; |
143 | 143 |
144 } // namespace metrics | 144 } // namespace metrics |
145 | 145 |
146 #endif // COMPONENTS_METRICS_REPORTING_SERVICE_H_ | 146 #endif // COMPONENTS_METRICS_REPORTING_SERVICE_H_ |
OLD | NEW |