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

Unified Diff: content/browser/devtools/devtools_io_context.h

Issue 1307073002: DevTools: provide an option to return traces as streams (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 4 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: content/browser/devtools/devtools_io_context.h
diff --git a/content/browser/devtools/devtools_io_context.h b/content/browser/devtools/devtools_io_context.h
new file mode 100644
index 0000000000000000000000000000000000000000..3990186d282e6d05997cae0396317c104e9881ce
--- /dev/null
+++ b/content/browser/devtools/devtools_io_context.h
@@ -0,0 +1,61 @@
+// Copyright 2015 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.
+
+#include <map>
+
+#include "base/callback.h"
+#include "base/files/file.h"
+#include "base/memory/ref_counted_delete_on_message_loop.h"
+#include "base/memory/ref_counted_memory.h"
+
+namespace content {
+namespace devtools {
+
+class DevToolsIOContext {
+ public:
+ class Stream : public base::RefCountedDeleteOnMessageLoop<Stream> {
+ public:
+ enum Status {
+ StatusSuccess,
+ StatusEOF,
+ StatusFailure
+ };
+
+ using ReadCallback = base::Callback<
+ void(const scoped_refptr<base::RefCountedString>& data, int status)>;
+
+ void Read(off_t position, size_t max_size, ReadCallback callback);
+ void Append(const scoped_refptr<base::RefCountedString>& data);
+ const std::string& id() const { return id_; }
+
+ private:
+ Stream();
+ ~Stream();
+ friend class DevToolsIOContext;
+ friend class base::RefCountedDeleteOnMessageLoop<Stream>;
+ friend class base::DeleteHelper<Stream>;
+
+ bool InitOnFileThreadIdNeeded();
dgozman 2015/08/24 20:45:44 typo: Id instead of If
+
+ const std::string id_;
+ base::File file_;
+ bool had_errors_;
+ off_t last_read_pos_;
+ };
+
+ DevToolsIOContext();
+ ~DevToolsIOContext();
+
+ scoped_refptr<Stream> CreateTempFileBackedStream();
+ scoped_refptr<Stream> GetById(const std::string& id);
+ bool Close(const std::string& id);
+ void DiscardAllStreams();
+
+ private:
+ using StreamsMap = std::map<std::string, scoped_refptr<Stream>>;
+ StreamsMap streams_;
+};
+
+} // namespace devtools
+} // namespace content

Powered by Google App Engine
This is Rietveld 408576698