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

Side by Side Diff: components/webrtc_log_uploader/webrtc_log_uploader.h

Issue 14329020: Implementing uploading of a WebRTC diagnostic log. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Code review, added url and app session id, rebase Created 7 years, 7 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 | Annotate | Revision Log
OLDNEW
(Empty)
1 // Copyright 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_WEBRTC_LOG_UPLOADER_WEBRTC_LOG_UPLOADER_H_
6 #define COMPONENTS_WEBRTC_LOG_UPLOADER_WEBRTC_LOG_UPLOADER_H_
7
8 #include <string>
9 #include <vector>
10
11 #include "base/basictypes.h"
12 #include "base/memory/ref_counted.h"
13 #include "base/platform_file.h"
14 #include "components/webrtc_log_uploader/webrtc_log_uploader_export.h"
15 #include "net/url_request/url_fetcher_delegate.h"
16
17 namespace base {
18 class SharedMemory;
19 }
20
21 namespace net {
22 class URLFetcher;
23 class URLRequestContextGetter;
24 }
25
26 typedef struct z_stream_s z_stream;
27
28 namespace components {
29
30 class WebRtcLogURLRequestContextGetter;
31
32 // WebRtcLogUploader uploads WebRTC logs, keeps count of how many logs have
33 // been started and denies further logs if a limit is reached. There must only
34 // be one object of this type.
35 class WEBRTC_LOG_UPLOADER_EXPORT WebRtcLogUploader
36 : public net::URLFetcherDelegate {
37 public:
38 WebRtcLogUploader();
39 virtual ~WebRtcLogUploader();
40
41 // net::URLFetcherDelegate implementation.
42 virtual void OnURLFetchComplete(const net::URLFetcher* source) OVERRIDE;
43 virtual void OnURLFetchUploadProgress(const net::URLFetcher* source,
44 int64 current, int64 total) OVERRIDE;
45
46 // Returns true is number of logs limit is not reached yet. Increases log
47 // count if true is returned. Must be called before UploadLog().
48 bool ApplyForStartLogging();
49
50 // Uploads log and decreases log count. May only be called if permission to
51 // to log has been granted by calling ApplyForStartLogging() and getting true
52 // in return. After UploadLog has been called, a new permission must be
53 // granted.
54 void UploadLog(net::URLRequestContextGetter* request_context,
55 scoped_ptr<base::SharedMemory> shared_memory,
56 uint32 length,
57 const std::string& app_session_id,
58 const std::string& app_url);
59
60 private:
61 // Sets up a multipart body to be uploaded. The body is produced according
62 // to RFC 2046.
63 void SetupMultipart(std::string* post_data, uint8* log_buffer,
64 uint32 log_buffer_length,
65 const std::string& app_session_id,
66 const std::string& app_url);
67
68 void AddLogData(std::string* post_data, uint8* log_buffer,
69 uint32 log_buffer_length);
70 void CompressLog(std::string* post_data, uint8* input, uint32 input_size);
71 void IncreaseMultipartBufferSize(std::string* post_data, z_stream* stream);
72 void DecreaseLogCount();
73
74 int log_count_;
75
76 DISALLOW_COPY_AND_ASSIGN(WebRtcLogUploader);
77 };
78
79 } // namespace components
80
81 #endif // COMPONENTS_WEBRTC_LOG_UPLOADER_WEBRTC_LOG_UPLOADER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698