summaryrefslogtreecommitdiffstats
path: root/chrome/browser/media/webrtc_log_uploader.h
diff options
context:
space:
mode:
authorgrunell@chromium.org <grunell@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-06-03 14:05:52 +0000
committergrunell@chromium.org <grunell@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-06-03 14:05:52 +0000
commitbbf32c588f457307ef10d93dd7b611b821b1433a (patch)
treea4585e2bf9eab07d96bb9352eec9c6d8c9ea7029 /chrome/browser/media/webrtc_log_uploader.h
parent3a27ba68d063d21ae08cf2f2a1462fa7ad353d1f (diff)
downloadchromium_src-bbf32c588f457307ef10d93dd7b611b821b1433a.zip
chromium_src-bbf32c588f457307ef10d93dd7b611b821b1433a.tar.gz
chromium_src-bbf32c588f457307ef10d93dd7b611b821b1433a.tar.bz2
Implementing uploading of a WebRTC diagnostic log.
BUG=229829 Committed: https://src.chromium.org/viewvc/chrome?view=rev&revision=203700 R=agl@chromium.org, joi@chromium.org, sky@chromium.org, tommi@chromium.org, vabr@chromium.org, wtc@chromium.org Review URL: https://codereview.chromium.org/14329020 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@203711 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/media/webrtc_log_uploader.h')
-rw-r--r--chrome/browser/media/webrtc_log_uploader.h75
1 files changed, 75 insertions, 0 deletions
diff --git a/chrome/browser/media/webrtc_log_uploader.h b/chrome/browser/media/webrtc_log_uploader.h
new file mode 100644
index 0000000..60225c6
--- /dev/null
+++ b/chrome/browser/media/webrtc_log_uploader.h
@@ -0,0 +1,75 @@
+// Copyright 2013 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef CHROME_BROWSER_MEDIA_WEBRTC_LOG_UPLOADER_H_
+#define CHROME_BROWSER_MEDIA_WEBRTC_LOG_UPLOADER_H_
+
+#include <string>
+#include <vector>
+
+#include "base/basictypes.h"
+#include "base/memory/ref_counted.h"
+#include "base/platform_file.h"
+#include "net/url_request/url_fetcher_delegate.h"
+
+namespace base {
+class SharedMemory;
+}
+
+namespace net {
+class URLFetcher;
+class URLRequestContextGetter;
+}
+
+typedef struct z_stream_s z_stream;
+
+class WebRtcLogURLRequestContextGetter;
+
+// WebRtcLogUploader uploads WebRTC logs, keeps count of how many logs have
+// been started and denies further logs if a limit is reached. There must only
+// be one object of this type.
+class WebRtcLogUploader : public net::URLFetcherDelegate {
+ public:
+ WebRtcLogUploader();
+ virtual ~WebRtcLogUploader();
+
+ // net::URLFetcherDelegate implementation.
+ virtual void OnURLFetchComplete(const net::URLFetcher* source) OVERRIDE;
+ virtual void OnURLFetchUploadProgress(const net::URLFetcher* source,
+ int64 current, int64 total) OVERRIDE;
+
+ // Returns true is number of logs limit is not reached yet. Increases log
+ // count if true is returned. Must be called before UploadLog().
+ bool ApplyForStartLogging();
+
+ // Uploads log and decreases log count. May only be called if permission to
+ // to log has been granted by calling ApplyForStartLogging() and getting true
+ // in return. After UploadLog has been called, a new permission must be
+ // granted.
+ void UploadLog(net::URLRequestContextGetter* request_context,
+ scoped_ptr<base::SharedMemory> shared_memory,
+ uint32 length,
+ const std::string& app_session_id,
+ const std::string& app_url);
+
+ private:
+ // Sets up a multipart body to be uploaded. The body is produced according
+ // to RFC 2046.
+ void SetupMultipart(std::string* post_data, uint8* log_buffer,
+ uint32 log_buffer_length,
+ const std::string& app_session_id,
+ const std::string& app_url);
+
+ void AddLogData(std::string* post_data, uint8* log_buffer,
+ uint32 log_buffer_length);
+ void CompressLog(std::string* post_data, uint8* input, uint32 input_size);
+ void ResizeForNextOutput(std::string* post_data, z_stream* stream);
+ void DecreaseLogCount();
+
+ int log_count_;
+
+ DISALLOW_COPY_AND_ASSIGN(WebRtcLogUploader);
+};
+
+#endif // CHROME_BROWSER_MEDIA_WEBRTC_LOG_UPLOADER_H_