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

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. 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.
45 bool ApplyForStartLogging();
46
47 // Uploads log and decreases log count.
48 void UploadLog(scoped_ptr<base::SharedMemory> shared_memory, uint32 length);
vabr (Chromium) 2013/05/13 08:55:50 If the contract is that ApplyForStartLogging() nee
Henrik Grunell 2013/05/14 13:48:50 Done.
49
50 private:
51 void SetupMultipartFile(uint8* log_buffer, uint32 log_buffer_length,
52 const base::FilePath& upload_file_path);
53 void AddPairString(const std::string& key, const std::string& value);
54 void AddUrlChunks();
55 void AddLogData(uint8* log_buffer, uint32 log_buffer_length);
56 void CompressLog(uint8* input, uint32 input_size,
57 base::PlatformFile output_file);
58 void AddMultipartValueForUpload(const std::string& value_name,
59 const std::string& value,
60 const std::string& mime_boundary,
61 const std::string& content_type,
62 std::string* post_data);
63 void DecreaseLogCount();
64
65 int log_count_;
66
67 std::vector<net::URLFetcher*> url_fetchers_;
68 scoped_refptr<WebRtcLogURLRequestContextGetter>
69 request_context_getter_;
70
71 // TODO(grunell): Maybe don't need to be member.
72 base::PlatformFile multipart_file_;
73
74 DISALLOW_COPY_AND_ASSIGN(WebRtcLogUploader);
75 };
76
77 } // namespace components
78
79 #endif // COMPONENTS_WEBRTC_LOG_UPLOADER_WEBRTC_LOG_UPLOADER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698