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

Unified 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 side-by-side diff with in-line comments
Download patch
Index: components/webrtc_log_uploader/webrtc_log_uploader.h
diff --git a/components/webrtc_log_uploader/webrtc_log_uploader.h b/components/webrtc_log_uploader/webrtc_log_uploader.h
new file mode 100644
index 0000000000000000000000000000000000000000..6821b9e49e82d34f0a8690cab61b13c0f79f69d4
--- /dev/null
+++ b/components/webrtc_log_uploader/webrtc_log_uploader.h
@@ -0,0 +1,81 @@
+// 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 COMPONENTS_WEBRTC_LOG_UPLOADER_WEBRTC_LOG_UPLOADER_H_
+#define COMPONENTS_WEBRTC_LOG_UPLOADER_WEBRTC_LOG_UPLOADER_H_
+
+#include <string>
+#include <vector>
+
+#include "base/basictypes.h"
+#include "base/memory/ref_counted.h"
+#include "base/platform_file.h"
+#include "components/webrtc_log_uploader/webrtc_log_uploader_export.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;
+
+namespace components {
+
+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 WEBRTC_LOG_UPLOADER_EXPORT 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 IncreaseMultipartBufferSize(std::string* post_data, z_stream* stream);
+ void DecreaseLogCount();
+
+ int log_count_;
+
+ DISALLOW_COPY_AND_ASSIGN(WebRtcLogUploader);
+};
+
+} // namespace components
+
+#endif // COMPONENTS_WEBRTC_LOG_UPLOADER_WEBRTC_LOG_UPLOADER_H_

Powered by Google App Engine
This is Rietveld 408576698