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

Side by Side Diff: content/browser/devtools/devtools_agent_host_impl.h

Issue 1408363004: [DevTools] Filter any messages from previous sessions in DevToolsAgentHostImpl (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 1 month 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
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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_DEVTOOLS_AGENT_HOST_IMPL_H_ 5 #ifndef CONTENT_BROWSER_DEVTOOLS_DEVTOOLS_AGENT_HOST_IMPL_H_
6 #define CONTENT_BROWSER_DEVTOOLS_DEVTOOLS_AGENT_HOST_IMPL_H_ 6 #define CONTENT_BROWSER_DEVTOOLS_DEVTOOLS_AGENT_HOST_IMPL_H_
7 7
8 #include <string> 8 #include <string>
9 9
10 #include "base/compiler_specific.h" 10 #include "base/compiler_specific.h"
11 #include "content/browser/devtools/devtools_io_context.h" 11 #include "content/browser/devtools/devtools_io_context.h"
12 #include "content/browser/devtools/devtools_protocol_delegate.h"
dgozman 2015/11/07 02:28:40 Let's place this to devtools/protocol.
kozy 2015/11/07 03:02:35 Done.
12 #include "content/common/content_export.h" 13 #include "content/common/content_export.h"
13 #include "content/common/devtools_messages.h" 14 #include "content/common/devtools_messages.h"
14 #include "content/public/browser/devtools_agent_host.h" 15 #include "content/public/browser/devtools_agent_host.h"
15 16
16 namespace IPC { 17 namespace IPC {
17 class Message; 18 class Message;
18 } 19 }
19 20
20 namespace content { 21 namespace content {
21 22
22 class BrowserContext; 23 class BrowserContext;
23 24
24 // Describes interface for managing devtools agents from the browser process. 25 // Describes interface for managing devtools agents from the browser process.
25 class CONTENT_EXPORT DevToolsAgentHostImpl : public DevToolsAgentHost { 26 class CONTENT_EXPORT DevToolsAgentHostImpl : public DevToolsAgentHost,
27 public DevToolsProtocolDelegate {
26 public: 28 public:
27 // Informs the hosted agent that a client host has attached. 29 // Informs the hosted agent that a client host has attached.
28 virtual void Attach() = 0; 30 virtual void Attach() = 0;
29 31
30 // Informs the hosted agent that a client host has detached. 32 // Informs the hosted agent that a client host has detached.
31 virtual void Detach() = 0; 33 virtual void Detach() = 0;
32 34
33 // Opens the inspector for this host. 35 // Opens the inspector for this host.
34 void Inspect(BrowserContext* browser_context); 36 void Inspect(BrowserContext* browser_context);
35 37
36 // DevToolsAgentHost implementation. 38 // DevToolsAgentHost implementation.
37 void AttachClient(DevToolsAgentHostClient* client) override; 39 void AttachClient(DevToolsAgentHostClient* client) override;
38 void DetachClient() override; 40 void DetachClient() override;
39 bool IsAttached() override; 41 bool IsAttached() override;
40 void InspectElement(int x, int y) override; 42 void InspectElement(int x, int y) override;
41 std::string GetId() override; 43 std::string GetId() override;
42 BrowserContext* GetBrowserContext() override; 44 BrowserContext* GetBrowserContext() override;
43 WebContents* GetWebContents() override; 45 WebContents* GetWebContents() override;
44 void DisconnectWebContents() override; 46 void DisconnectWebContents() override;
45 void ConnectWebContents(WebContents* wc) override; 47 void ConnectWebContents(WebContents* wc) override;
46 48
49 void SendProtocolResponse(int session_id,
dgozman 2015/11/07 02:28:40 // DevToolsProtocolDelegate implementation.
kozy 2015/11/07 03:02:35 Done.
50 const std::string& message) override;
51 void SendProtocolNotification(const std::string& message) override;
52
47 protected: 53 protected:
48 DevToolsAgentHostImpl(); 54 DevToolsAgentHostImpl();
49 ~DevToolsAgentHostImpl() override; 55 ~DevToolsAgentHostImpl() override;
50 56
51 void HostClosed(); 57 void HostClosed();
52 void SendMessageToClient(const std::string& message); 58 void SendMessageToClient(int session_id, const std::string& message);
53 devtools::DevToolsIOContext* GetIOContext() { return &io_context_; } 59 devtools::DevToolsIOContext* GetIOContext() { return &io_context_; }
54 60
61 int session_id() { return session_id_; }
62
55 static void NotifyCallbacks(DevToolsAgentHostImpl* agent_host, bool attached); 63 static void NotifyCallbacks(DevToolsAgentHostImpl* agent_host, bool attached);
56 64
57 private: 65 private:
58 friend class DevToolsAgentHost; // for static methods 66 friend class DevToolsAgentHost; // for static methods
59 void InnerDetach(); 67 void InnerDetach();
60 68
61 const std::string id_; 69 const std::string id_;
70 int session_id_;
62 DevToolsAgentHostClient* client_; 71 DevToolsAgentHostClient* client_;
63 devtools::DevToolsIOContext io_context_; 72 devtools::DevToolsIOContext io_context_;
64 }; 73 };
65 74
66 class DevToolsMessageChunkProcessor { 75 class DevToolsMessageChunkProcessor {
67 public: 76 public:
68 using SendMessageCallback = base::Callback<void(const std::string&)>; 77 using SendMessageCallback = base::Callback<void(int, const std::string&)>;
69 explicit DevToolsMessageChunkProcessor(const SendMessageCallback& callback); 78 explicit DevToolsMessageChunkProcessor(const SendMessageCallback& callback);
70 ~DevToolsMessageChunkProcessor(); 79 ~DevToolsMessageChunkProcessor();
71 80
72 std::string state_cookie() const { return state_cookie_; } 81 std::string state_cookie() const { return state_cookie_; }
73 void set_state_cookie(const std::string& cookie) { state_cookie_ = cookie; } 82 void set_state_cookie(const std::string& cookie) { state_cookie_ = cookie; }
74 int last_call_id() const { return last_call_id_; } 83 int last_call_id() const { return last_call_id_; }
75 void ProcessChunkedMessageFromAgent(const DevToolsMessageChunk& chunk); 84 void ProcessChunkedMessageFromAgent(const DevToolsMessageChunk& chunk);
76 85
77 private: 86 private:
78 SendMessageCallback callback_; 87 SendMessageCallback callback_;
79 std::string message_buffer_; 88 std::string message_buffer_;
80 uint32 message_buffer_size_; 89 uint32 message_buffer_size_;
81 std::string state_cookie_; 90 std::string state_cookie_;
82 int last_call_id_; 91 int last_call_id_;
83 }; 92 };
84 93
85 } // namespace content 94 } // namespace content
86 95
87 #endif // CONTENT_BROWSER_DEVTOOLS_DEVTOOLS_AGENT_HOST_IMPL_H_ 96 #endif // CONTENT_BROWSER_DEVTOOLS_DEVTOOLS_AGENT_HOST_IMPL_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698