Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(40)

Side by Side Diff: components/rappor/log_uploader.h

Issue 49753002: RAPPOR implementation (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: RapporMetric Created 6 years, 12 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #ifndef COMPONENTS_RAPPOR_LOG_UPLOADER_H_
6 #define COMPONENTS_RAPPOR_LOG_UPLOADER_H_
7
8 #include <queue>
9 #include <string>
10
11 #include "base/memory/weak_ptr.h"
12 #include "base/time/time.h"
13 #include "base/timer/timer.h"
14 #include "net/url_request/url_fetcher.h"
15 #include "net/url_request/url_fetcher_delegate.h"
16 #include "net/url_request/url_request_context_getter.h"
17
18 namespace rappor {
19
20 // Handles uploading logs to an external server.
21 class LogUploader : public net::URLFetcherDelegate {
22 public:
23 LogUploader(const char* server_url, const char* mime_type);
24
25 void SetRequestContext(net::URLRequestContextGetter* request_context);
26
27 void QueueLog(const std::string& logData);
28
29 private:
30 // The server URL to upload logs to.
31 const char* server_url_;
Alexei Svitkine (slow) 2013/12/24 16:59:30 Nit: Vars should come after methods.
Steven Holte 2014/01/04 00:12:54 Done.
32
33 // The mime type to specify on uploaded logs.
34 const char* mime_type_;
35
36 net::URLRequestContextGetter* request_context_;
37
38 // The outstanding transmission appears as a URL Fetch operation.
39 scoped_ptr<net::URLFetcher> current_fetch_;
40
41 // The logs that still need to be uploaded.
42 std::queue<std::string> queued_logs_;
43
44 base::OneShotTimer<LogUploader> upload_timer_;
45
46 // Indicates that the last triggered upload hasn't resolved yet.
47 bool callback_pending_;
48
49 // The interval between being told an upload is done and starting the next
50 // upload.
51 base::TimeDelta upload_interval_;
52
53 // Starts transmission of the next log.
54 void StartScheduledUpload();
55
56 // Schedules a future call to StartScheduledUpload if one isn't already
57 // pending.
58 void ScheduleNextUpload();
59
60 // Increases the upload interval each time it's called, to handle the case
61 // where the server is having issues.
62 void BackOffUploadInterval();
63
64 // Implementation of net::URLFetcherDelegate. Called after transmission
65 // completes (either successfully or with failure).
66 virtual void OnURLFetchComplete(const net::URLFetcher* source) OVERRIDE;
67
68 // Called when the upload is completed.
69 void UploadFinished(bool server_is_healthy, bool more_logs_remaining);
70 };
Alexei Svitkine (slow) 2013/12/24 16:59:30 DISALLOW_COPY_AND_ASSIGN
Steven Holte 2014/01/04 00:12:54 Done.
71
72 } // namespace rappor
73
74 #endif // COMPONENTS_RAPPOR_LOG_UPLOADER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698