Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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 NET_SERVER_HTTP_CONNECTION_H_ | 5 #ifndef CHROME_BROWSER_EXTENSIONS_API_SESSIONS_FOREIGN_SESSION_ID_H__ |
| 6 #define NET_SERVER_HTTP_CONNECTION_H_ | 6 #define CHROME_BROWSER_EXTENSIONS_API_SESSIONS_FOREIGN_SESSION_ID_H__ |
| 7 | 7 |
| 8 #include <string> | 8 #include <string> |
| 9 | 9 |
| 10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
| 11 #include "base/memory/ref_counted.h" | |
| 12 #include "base/memory/scoped_ptr.h" | |
| 13 #include "net/http/http_status_code.h" | |
| 14 | 11 |
| 15 namespace net { | 12 namespace extensions { |
| 16 | 13 |
| 17 class HttpServer; | 14 class ForeignSessionId { |
| 18 class HttpServerResponseInfo; | 15 public: |
| 19 class StreamListenSocket; | 16 // Constructs a ForeignSessionId object for the given session information. |
| 20 class WebSocket; | 17 ForeignSessionId(const std::string& session_tag, int id); |
|
not at google - send to devlin
2013/08/12 23:51:34
maybe you need to explain the difference between t
Kristen Dwan
2013/08/15 07:11:56
Done.
| |
| 21 | 18 |
| 22 class HttpConnection { | 19 // Constructs a ForeignSessionId, given a string formatted by ToString(). |
| 23 public: | 20 explicit ForeignSessionId(const std::string& foreign_session_string); |
|
not at google - send to devlin
2013/08/12 23:51:34
generally nicer to have a static method like Parse
Kristen Dwan
2013/08/15 07:11:56
Done.
| |
| 24 ~HttpConnection(); | |
| 25 | 21 |
| 26 void Send(const std::string& data); | 22 // Returns true if the provided |id| is in the format of a ForeignSessionId. |
| 27 void Send(const char* bytes, int len); | 23 static bool IsForeignSessionId(const std::string& id); |
| 28 void Send(const HttpServerResponseInfo& response); | |
| 29 | 24 |
| 30 void Shift(int num_bytes); | 25 // Returns the compressed std::string representation of a ForeignSessionId. |
| 26 std::string ToString(); | |
| 31 | 27 |
| 32 const std::string& recv_data() const { return recv_data_; } | 28 std::string session_tag() const { return session_tag_; } |
|
not at google - send to devlin
2013/08/12 23:51:34
return a const std::string& here
Kristen Dwan
2013/08/15 07:11:56
Done.
| |
| 33 int id() const { return id_; } | 29 int id() const { return id_; } |
| 34 | 30 |
| 35 private: | 31 private: |
| 36 friend class HttpServer; | 32 // Associated session tag for this foreign entry. |
| 37 static int last_id_; | 33 std::string session_tag_; |
| 38 | 34 |
| 39 HttpConnection(HttpServer* server, StreamListenSocket* sock); | 35 // ID corresponding to this foreign entry. |
| 36 int id_; | |
| 40 | 37 |
| 41 void DetachSocket(); | 38 DISALLOW_COPY_AND_ASSIGN(ForeignSessionId); |
| 42 | |
| 43 HttpServer* server_; | |
| 44 scoped_refptr<StreamListenSocket> socket_; | |
| 45 scoped_ptr<WebSocket> web_socket_; | |
| 46 std::string recv_data_; | |
| 47 int id_; | |
| 48 DISALLOW_COPY_AND_ASSIGN(HttpConnection); | |
| 49 }; | 39 }; |
| 50 | 40 |
| 51 } // namespace net | 41 } // namespace extensions |
| 52 | 42 |
| 53 #endif // NET_SERVER_HTTP_CONNECTION_H_ | 43 #endif // CHROME_BROWSER_EXTENSIONS_API_SESSIONS_FOREIGN_SESSION_ID_H__ |
| OLD | NEW |