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

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: Upload again (error last upload). 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 }
24
25 namespace components {
26
27 class WebRtcLogURLRequestContextGetter;
28
29 // WebRtcLogUploader uploads WebRTC logs, keeps count of how many logs have
30 // been started and denies further logs if a limit is reached. There must only
31 // be one object of this type.
32 class WEBRTC_LOG_UPLOADER_EXPORT WebRtcLogUploader
33 : public net::URLFetcherDelegate {
34 public:
35 WebRtcLogUploader();
36 virtual ~WebRtcLogUploader();
37
38 // net::URLFetcherDelegate implementation.
39 virtual void OnURLFetchComplete(const net::URLFetcher* source) OVERRIDE;
40 virtual void OnURLFetchUploadProgress(const net::URLFetcher* source,
41 int64 current, int64 total) OVERRIDE;
42
43 // Returns true is number of logs limit is not reached yet. Increases log
44 // count if true is returned. Must be called before UploadLog().
45 bool ApplyForStartLogging();
46
47 // Uploads log and decreases log count. May only be called if permission to
48 // to log has been granted by calling ApplyForStartLogging() and getting true
49 // in return. After UploadLog has been called, a new permission must be
50 // granted.
51 void UploadLog(scoped_ptr<base::SharedMemory> shared_memory, uint32 length);
52
53 private:
54 // Sets up a multipart file to be uploaded. The body is produced according
55 // to RFC 2046.
56 void SetupMultipartFile(uint8* log_buffer, uint32 log_buffer_length,
57 const base::FilePath& upload_file_path);
58
59 void AddPairString(base::PlatformFile multipart_file, const std::string& key,
60 const std::string& value);
61 void AddUrlChunks();
62 void AddLogData(base::PlatformFile multipart_file, uint8* log_buffer,
63 uint32 log_buffer_length);
64 void CompressLog(uint8* input, uint32 input_size,
65 base::PlatformFile output_file);
66 void AddMultipartValueForUpload(const std::string& value_name,
67 const std::string& value,
68 const std::string& mime_boundary,
69 const std::string& content_type,
70 std::string* post_data);
71 void DecreaseLogCount();
72
73 int log_count_;
74
75 std::vector<net::URLFetcher*> url_fetchers_;
Jói 2013/05/14 21:30:29 A one-liner comment about ownership (or not) of th
Henrik Grunell 2013/05/15 20:17:53 I removed this, not used.
76 scoped_refptr<WebRtcLogURLRequestContextGetter>
77 request_context_getter_;
78
79 DISALLOW_COPY_AND_ASSIGN(WebRtcLogUploader);
80 };
81
82 } // namespace components
83
84 #endif // COMPONENTS_WEBRTC_LOG_UPLOADER_WEBRTC_LOG_UPLOADER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698