summaryrefslogtreecommitdiffstats
path: root/content/browser/devtools/protocol/io_handler.h
blob: d6ae25baaa410572f540af46b86e94bd88d154e2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
// 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.

#ifndef CONTENT_BROWSER_DEVTOOLS_PROTOCOL_IO_HANDLER_H_
#define CONTENT_BROWSER_DEVTOOLS_PROTOCOL_IO_HANDLER_H_

#include "base/memory/weak_ptr.h"
#include "content/browser/devtools/protocol/devtools_protocol_dispatcher.h"

namespace base {
class RefCountedString;
}

namespace content {
namespace devtools {
class DevToolsIOContext;

namespace io {

class IOHandler {
 public:
  using Response = DevToolsProtocolClient::Response;

  explicit IOHandler(DevToolsIOContext* io_context);
  ~IOHandler();

  void SetClient(scoped_ptr<Client> client);

  // Protocol methods.
  Response Read(DevToolsCommandId command_id, const std::string& handle,
      const int* offset, const int* max_size);
  Response Close(const std::string& handle);

 private:
  void ReadComplete(DevToolsCommandId command_id,
      const scoped_refptr<base::RefCountedString>& data, int status);

  scoped_ptr<Client> client_;
  DevToolsIOContext* io_context_;
  base::WeakPtrFactory<IOHandler> weak_factory_;

  DISALLOW_COPY_AND_ASSIGN(IOHandler);
};

}  // namespace io
}  // namespace devtools
}  // namespace content

#endif  // CONTENT_BROWSER_DEVTOOLS_PROTOCOL_TRACING_HANDLER_H_