OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "content/browser/devtools/protocol/io_handler.h" | 5 #include "content/browser/devtools/protocol/io_handler.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 #include <stdint.h> | 8 #include <stdint.h> |
9 | 9 |
10 #include "base/bind.h" | 10 #include "base/bind.h" |
11 #include "base/files/file.h" | 11 #include "base/files/file.h" |
12 #include "base/files/file_util.h" | 12 #include "base/files/file_util.h" |
13 #include "base/memory/ref_counted_memory.h" | 13 #include "base/memory/ref_counted_memory.h" |
14 #include "base/strings/string_number_conversions.h" | 14 #include "base/strings/string_number_conversions.h" |
15 #include "content/browser/devtools/devtools_io_context.h" | 15 #include "content/browser/devtools/devtools_io_context.h" |
16 #include "content/public/browser/browser_thread.h" | 16 #include "content/public/browser/browser_thread.h" |
17 | 17 |
18 namespace content { | 18 namespace content { |
19 namespace protocol { | 19 namespace protocol { |
20 | 20 |
21 IOHandler::IOHandler(DevToolsIOContext* io_context) | 21 IOHandler::IOHandler(DevToolsIOContext* io_context) |
22 : io_context_(io_context) | 22 : DevToolsDomainHandler(IO::Metainfo::domainName), |
| 23 io_context_(io_context) |
23 , weak_factory_(this) {} | 24 , weak_factory_(this) {} |
24 | 25 |
25 IOHandler::~IOHandler() {} | 26 IOHandler::~IOHandler() {} |
26 | 27 |
27 void IOHandler::Wire(UberDispatcher* dispatcher) { | 28 void IOHandler::Wire(UberDispatcher* dispatcher) { |
28 frontend_.reset(new IO::Frontend(dispatcher->channel())); | 29 frontend_.reset(new IO::Frontend(dispatcher->channel())); |
29 IO::Dispatcher::wire(dispatcher, this); | 30 IO::Dispatcher::wire(dispatcher, this); |
30 } | 31 } |
31 | 32 |
32 Response IOHandler::Disable() { | |
33 return Response::OK(); | |
34 } | |
35 | |
36 void IOHandler::Read( | 33 void IOHandler::Read( |
37 const std::string& handle, | 34 const std::string& handle, |
38 Maybe<int> offset, | 35 Maybe<int> offset, |
39 Maybe<int> max_size, | 36 Maybe<int> max_size, |
40 std::unique_ptr<ReadCallback> callback) { | 37 std::unique_ptr<ReadCallback> callback) { |
41 static const size_t kDefaultChunkSize = 10 * 1024 * 1024; | 38 static const size_t kDefaultChunkSize = 10 * 1024 * 1024; |
42 | 39 |
43 scoped_refptr<DevToolsIOContext::Stream> stream = | 40 scoped_refptr<DevToolsIOContext::Stream> stream = |
44 io_context_->GetByHandle(handle); | 41 io_context_->GetByHandle(handle); |
45 if (!stream) { | 42 if (!stream) { |
(...skipping 18 matching lines...) Expand all Loading... |
64 callback->sendSuccess(data->data(), eof); | 61 callback->sendSuccess(data->data(), eof); |
65 } | 62 } |
66 | 63 |
67 Response IOHandler::Close(const std::string& handle) { | 64 Response IOHandler::Close(const std::string& handle) { |
68 return io_context_->Close(handle) ? Response::OK() | 65 return io_context_->Close(handle) ? Response::OK() |
69 : Response::InvalidParams("Invalid stream handle"); | 66 : Response::InvalidParams("Invalid stream handle"); |
70 } | 67 } |
71 | 68 |
72 } // namespace protocol | 69 } // namespace protocol |
73 } // namespace content | 70 } // namespace content |
OLD | NEW |