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

Side by Side 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: work around MSVC compiler error due to missing Client definition Created 5 years, 3 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
OLDNEW
(Empty)
1 // Copyright 2015 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 #include <map>
6
7 #include "base/callback.h"
8 #include "base/files/file.h"
9 #include "base/memory/ref_counted_delete_on_message_loop.h"
10 #include "base/memory/ref_counted_memory.h"
11
12 namespace content {
13 namespace devtools {
14
15 class DevToolsIOContext {
16 public:
17 class Stream : public base::RefCountedDeleteOnMessageLoop<Stream> {
18 public:
19 enum Status {
20 StatusSuccess,
21 StatusEOF,
22 StatusFailure
23 };
24
25 using ReadCallback = base::Callback<
26 void(const scoped_refptr<base::RefCountedString>& data, int status)>;
27
28 void Read(off_t position, size_t max_size, ReadCallback callback);
29 void Append(const scoped_refptr<base::RefCountedString>& data);
30 const std::string& handle() const { return handle_; }
31
32 private:
33 Stream();
34 ~Stream();
35 friend class DevToolsIOContext;
36 friend class base::RefCountedDeleteOnMessageLoop<Stream>;
37 friend class base::DeleteHelper<Stream>;
38
39 void ReadOnFileThread(off_t pos, size_t max_size, ReadCallback callback);
40 void AppendOnFileThread(const scoped_refptr<base::RefCountedString>& data);
41 bool InitOnFileThreadIfNeeded();
42
43 const std::string handle_;
44 base::File file_;
45 bool had_errors_;
46 off_t last_read_pos_;
47 };
48
49 DevToolsIOContext();
50 ~DevToolsIOContext();
51
52 scoped_refptr<Stream> CreateTempFileBackedStream();
53 scoped_refptr<Stream> GetByHandle(const std::string& handle);
54 bool Close(const std::string& handle);
55 void DiscardAllStreams();
56
57 private:
58 using StreamsMap = std::map<std::string, scoped_refptr<Stream>>;
59 StreamsMap streams_;
60 };
61
62 } // namespace devtools
63 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/devtools/devtools_agent_host_impl.cc ('k') | content/browser/devtools/devtools_io_context.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698