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

Side by Side Diff: content/browser/devtools/protocol/devtools_protocol_client.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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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_DEVTOOLS_PROTOCOL_CLIENT_H_ 5 #ifndef CONTENT_BROWSER_DEVTOOLS_PROTOCOL_DEVTOOLS_PROTOCOL_CLIENT_H_
6 #define CONTENT_BROWSER_DEVTOOLS_PROTOCOL_DEVTOOLS_PROTOCOL_CLIENT_H_ 6 #define CONTENT_BROWSER_DEVTOOLS_PROTOCOL_DEVTOOLS_PROTOCOL_CLIENT_H_
7 7
8 #include "base/callback.h" 8 #include "base/callback.h"
9 #include "base/values.h" 9 #include "base/values.h"
10 10
11 namespace content { 11 namespace content {
12 12
13 using DevToolsCommandId = int; 13 struct DevToolsCommandId {
14 static const int kNoId;
15 DevToolsCommandId(int call_id, int session_id)
16 : call_id(call_id), session_id(session_id) {}
17 DevToolsCommandId() : call_id(kNoId), session_id(kNoId) {}
dgozman 2015/11/07 02:28:40 Remove this constructor.
kozy 2015/11/07 03:02:35 Done.
18 int call_id;
19 int session_id;
20 };
21 class DevToolsProtocolDelegate;
dgozman 2015/11/07 02:28:40 nit: empty line before this please
kozy 2015/11/07 03:02:35 Done.
22 class DevToolsProtocolDispatcher;
14 class DevToolsProtocolHandler; 23 class DevToolsProtocolHandler;
15 class DevToolsProtocolDispatcher;
16 24
17 class DevToolsProtocolClient { 25 class DevToolsProtocolClient {
18 public: 26 public:
19 typedef base::Callback<void(const std::string& message)>
20 RawMessageCallback;
21 static const DevToolsCommandId kNoId;
22
23 struct Response { 27 struct Response {
24 public: 28 public:
25 static Response FallThrough(); 29 static Response FallThrough();
26 static Response OK(); 30 static Response OK();
27 static Response InvalidParams(const std::string& param); 31 static Response InvalidParams(const std::string& param);
28 static Response InternalError(const std::string& message); 32 static Response InternalError(const std::string& message);
29 static Response ServerError(const std::string& message); 33 static Response ServerError(const std::string& message);
30 34
31 int status() const; 35 int status() const;
32 const std::string& message() const; 36 const std::string& message() const;
33 37
34 bool IsFallThrough() const; 38 bool IsFallThrough() const;
35 39
36 private: 40 private:
37 friend class DevToolsProtocolHandler; 41 friend class DevToolsProtocolHandler;
38 42
39 explicit Response(int status); 43 explicit Response(int status);
40 Response(int status, const std::string& message); 44 Response(int status, const std::string& message);
41 45
42 int status_; 46 int status_;
43 std::string message_; 47 std::string message_;
44 }; 48 };
45 49
46 bool SendError(DevToolsCommandId command_id, 50 bool SendError(DevToolsCommandId command_id,
47 const Response& response); 51 const Response& response);
48 52
49 // Sends message to client, the caller is presumed to properly 53 // Sends message to client, the caller is presumed to properly
50 // format the message. Do not use unless you must. 54 // format the message. Do not use unless you must.
51 void SendRawMessage(const std::string& message); 55 void SendRawMessage(int session_id, const std::string& message);
dgozman 2015/11/07 02:28:40 Rename to SendRawNotification and remove session_i
kozy 2015/11/07 03:02:35 Done.
52 56
53 explicit DevToolsProtocolClient( 57 explicit DevToolsProtocolClient(DevToolsProtocolDelegate* notifier);
54 const RawMessageCallback& raw_message_callback);
55 virtual ~DevToolsProtocolClient(); 58 virtual ~DevToolsProtocolClient();
56 59
57 protected: 60 protected:
58 void SendSuccess(DevToolsCommandId command_id, 61 void SendSuccess(DevToolsCommandId command_id,
59 scoped_ptr<base::DictionaryValue> params); 62 scoped_ptr<base::DictionaryValue> params);
60 void SendNotification(const std::string& method, 63 void SendNotification(const std::string& method,
61 scoped_ptr<base::DictionaryValue> params); 64 scoped_ptr<base::DictionaryValue> params);
62 65
63 private: 66 private:
64 friend class DevToolsProtocolDispatcher; 67 friend class DevToolsProtocolDispatcher;
65 68
66 void SendMessage(const base::DictionaryValue& message); 69 void SendMessage(int session_id, const base::DictionaryValue& message);
67 70
68 RawMessageCallback raw_message_callback_; 71 DevToolsProtocolDelegate* notifier_;
69 DISALLOW_COPY_AND_ASSIGN(DevToolsProtocolClient); 72 DISALLOW_COPY_AND_ASSIGN(DevToolsProtocolClient);
70 }; 73 };
71 74
72 } // namespace content 75 } // namespace content
73 76
74 #endif // CONTENT_BROWSER_DEVTOOLS_PROTOCOL_DEVTOOLS_PROTOCOL_CLIENT_H_ 77 #endif // CONTENT_BROWSER_DEVTOOLS_PROTOCOL_DEVTOOLS_PROTOCOL_CLIENT_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698