OLD | NEW |
---|---|
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 // Change for readability | |
6 | |
5 #ifndef COMPONENTS_RAPPOR_LOG_UPLOADER_H_ | 7 #ifndef COMPONENTS_RAPPOR_LOG_UPLOADER_H_ |
6 #define COMPONENTS_RAPPOR_LOG_UPLOADER_H_ | 8 #define COMPONENTS_RAPPOR_LOG_UPLOADER_H_ |
7 | 9 |
8 #include <queue> | 10 #include <queue> |
9 #include <string> | 11 #include <string> |
10 | 12 |
13 #include "base/compiler_specific.h" | |
14 #include "base/macros.h" | |
11 #include "base/memory/scoped_ptr.h" | 15 #include "base/memory/scoped_ptr.h" |
12 #include "base/time/time.h" | 16 #include "base/time/time.h" |
13 #include "base/timer/timer.h" | 17 #include "base/timer/timer.h" |
14 #include "net/url_request/url_fetcher_delegate.h" | 18 #include "net/url_request/url_fetcher_delegate.h" |
15 #include "net/url_request/url_request_context_getter.h" | 19 #include "net/url_request/url_request_context_getter.h" |
16 #include "url/gurl.h" | 20 #include "url/gurl.h" |
17 | 21 |
18 namespace net { | 22 namespace net { |
19 class URLFetcher; | 23 class URLFetcher; |
20 } | 24 } |
21 | 25 |
22 namespace rappor { | 26 namespace rappor { |
23 | 27 |
24 // Handles uploading logs to an external server. | 28 // Handles uploading logs to an external server. |
ktl
2014/03/18 08:35:01
This class could use a longer comment. When do upl
Steven Holte
2014/03/19 23:46:55
Done
| |
25 class LogUploader : public net::URLFetcherDelegate { | 29 class LogUploader : public net::URLFetcherDelegate { |
26 public: | 30 public: |
27 // Constructor takes the server_url that logs should be uploaded to, the | 31 // Constructor takes the server_url that logs should be uploaded to, the |
ktl
2014/03/18 08:35:01
In other places you use |name| convention for vari
Steven Holte
2014/03/19 23:46:55
Done.
| |
28 // mime_type of the uploaded data, and request_context to create uploads | 32 // mime_type of the uploaded data, and request_context to create uploads |
29 // with. | 33 // with. |
30 LogUploader(const GURL& server_url, | 34 LogUploader(const GURL& server_url, |
31 const std::string& mime_type, | 35 const std::string& mime_type, |
32 net::URLRequestContextGetter* request_context); | 36 net::URLRequestContextGetter* request_context); |
33 | 37 |
34 virtual ~LogUploader(); | 38 virtual ~LogUploader(); |
35 | 39 |
36 // Adds an entry to the queue of logs to be uploaded to the server. The | 40 // Adds an entry to the queue of logs to be uploaded to the server. The |
37 // uploader makes no assumptions about the format of |log| and simply sends | 41 // uploader makes no assumptions about the format of |log| and simply sends |
38 // it verbatim to the server. | 42 // it verbatim to the server. |
39 void QueueLog(const std::string& log); | 43 void QueueLog(const std::string& log); |
40 | 44 |
41 protected: | 45 protected: |
42 // Check if an upload has been scheduled. | 46 // Check if an upload has been scheduled. |
ktl
2014/03/18 08:35:01
"Checks", for consistency.
Steven Holte
2014/03/19 23:46:55
Done.
| |
43 virtual bool IsUploadScheduled() const; | 47 virtual bool IsUploadScheduled() const; |
44 | 48 |
45 // Schedules a future call to StartScheduledUpload if one isn't already | 49 // Schedules a future call to StartScheduledUpload if one isn't already |
46 // pending. Can be overridden for testing. | 50 // pending. Can be overridden for testing. |
47 virtual void ScheduleNextUpload(base::TimeDelta interval); | 51 virtual void ScheduleNextUpload(base::TimeDelta interval); |
48 | 52 |
49 // Starts transmission of the next log. Exposed for tests. | 53 // Starts transmission of the next log. Exposed for tests. |
50 void StartScheduledUpload(); | 54 void StartScheduledUpload(); |
51 | 55 |
52 // Increases the upload interval each time it's called, to handle the case | 56 // Increases the upload interval each time it's called, to handle the case |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
85 // The interval to wait after an upload's URLFetcher completion before | 89 // The interval to wait after an upload's URLFetcher completion before |
86 // starting the next upload attempt. | 90 // starting the next upload attempt. |
87 base::TimeDelta upload_interval_; | 91 base::TimeDelta upload_interval_; |
88 | 92 |
89 DISALLOW_COPY_AND_ASSIGN(LogUploader); | 93 DISALLOW_COPY_AND_ASSIGN(LogUploader); |
90 }; | 94 }; |
91 | 95 |
92 } // namespace rappor | 96 } // namespace rappor |
93 | 97 |
94 #endif // COMPONENTS_RAPPOR_LOG_UPLOADER_H_ | 98 #endif // COMPONENTS_RAPPOR_LOG_UPLOADER_H_ |
OLD | NEW |