| 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 #ifndef CONTENT_BROWSER_DEVTOOLS_PROTOCOL_IO_HANDLER_H_ | 5 #ifndef CONTENT_BROWSER_DEVTOOLS_PROTOCOL_IO_HANDLER_H_ |
| 6 #define CONTENT_BROWSER_DEVTOOLS_PROTOCOL_IO_HANDLER_H_ | 6 #define CONTENT_BROWSER_DEVTOOLS_PROTOCOL_IO_HANDLER_H_ |
| 7 | 7 |
| 8 #include "base/macros.h" | 8 #include "base/macros.h" |
| 9 #include "base/memory/weak_ptr.h" | 9 #include "base/memory/weak_ptr.h" |
| 10 #include "content/browser/devtools/protocol/devtools_protocol_dispatcher.h" | 10 #include "content/browser/devtools/protocol/io.h" |
| 11 | 11 |
| 12 namespace base { | 12 namespace base { |
| 13 class RefCountedString; | 13 class RefCountedString; |
| 14 } | 14 } |
| 15 | 15 |
| 16 namespace content { | 16 namespace content { |
| 17 namespace devtools { | |
| 18 class DevToolsIOContext; | 17 class DevToolsIOContext; |
| 19 | 18 |
| 20 namespace io { | 19 namespace protocol { |
| 21 | 20 |
| 22 class IOHandler { | 21 class IOHandler : public IO::Backend { |
| 23 public: | 22 public: |
| 24 using Response = DevToolsProtocolClient::Response; | 23 explicit IOHandler(DevToolsIOContext* io_context); |
| 24 ~IOHandler() override; |
| 25 | 25 |
| 26 explicit IOHandler(DevToolsIOContext* io_context); | 26 void Wire(UberDispatcher*); |
| 27 ~IOHandler(); | 27 Response Disable() override; |
| 28 | |
| 29 void SetClient(std::unique_ptr<Client> client); | |
| 30 | 28 |
| 31 // Protocol methods. | 29 // Protocol methods. |
| 32 Response Read(DevToolsCommandId command_id, const std::string& handle, | 30 void Read( |
| 33 const int* offset, const int* max_size); | 31 const std::string& handle, |
| 34 Response Close(const std::string& handle); | 32 Maybe<int> offset, |
| 33 Maybe<int> max_size, |
| 34 std::unique_ptr<ReadCallback> callback) override; |
| 35 Response Close(const std::string& handle) override; |
| 35 | 36 |
| 36 private: | 37 private: |
| 37 void ReadComplete(DevToolsCommandId command_id, | 38 void ReadComplete(std::unique_ptr<ReadCallback> callback, |
| 38 const scoped_refptr<base::RefCountedString>& data, int status); | 39 const scoped_refptr<base::RefCountedString>& data, int status); |
| 39 | 40 |
| 40 std::unique_ptr<Client> client_; | 41 std::unique_ptr<IO::Frontend> frontend_; |
| 41 DevToolsIOContext* io_context_; | 42 DevToolsIOContext* io_context_; |
| 42 base::WeakPtrFactory<IOHandler> weak_factory_; | 43 base::WeakPtrFactory<IOHandler> weak_factory_; |
| 43 | 44 |
| 44 DISALLOW_COPY_AND_ASSIGN(IOHandler); | 45 DISALLOW_COPY_AND_ASSIGN(IOHandler); |
| 45 }; | 46 }; |
| 46 | 47 |
| 47 } // namespace io | 48 } // namespace protocol |
| 48 } // namespace devtools | |
| 49 } // namespace content | 49 } // namespace content |
| 50 | 50 |
| 51 #endif // CONTENT_BROWSER_DEVTOOLS_PROTOCOL_TRACING_HANDLER_H_ | 51 #endif // CONTENT_BROWSER_DEVTOOLS_PROTOCOL_TRACING_HANDLER_H_ |
| OLD | NEW |