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

Side by Side Diff: net/server/web_socket_encoder.h

Issue 1893083002: Change scoped_ptr to std::unique_ptr in //net. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: scopedptr-net-all: iwyu Created 4 years, 8 months 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
« no previous file with comments | « net/server/web_socket.h ('k') | net/server/web_socket_encoder.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 NET_SERVER_WEB_SOCKET_ENCODER_H_ 5 #ifndef NET_SERVER_WEB_SOCKET_ENCODER_H_
6 #define NET_SERVER_WEB_SOCKET_ENCODER_H_ 6 #define NET_SERVER_WEB_SOCKET_ENCODER_H_
7 7
8 #include <memory>
8 #include <string> 9 #include <string>
9 10
10 #include "base/macros.h" 11 #include "base/macros.h"
11 #include "base/memory/scoped_ptr.h"
12 #include "base/strings/string_piece.h" 12 #include "base/strings/string_piece.h"
13 #include "net/server/web_socket.h" 13 #include "net/server/web_socket.h"
14 #include "net/websockets/websocket_deflater.h" 14 #include "net/websockets/websocket_deflater.h"
15 #include "net/websockets/websocket_inflater.h" 15 #include "net/websockets/websocket_inflater.h"
16 16
17 namespace net { 17 namespace net {
18 18
19 class WebSocketDeflateParameters; 19 class WebSocketDeflateParameters;
20 20
21 class WebSocketEncoder final { 21 class WebSocketEncoder final {
22 public: 22 public:
23 static const char kClientExtensions[]; 23 static const char kClientExtensions[];
24 24
25 ~WebSocketEncoder(); 25 ~WebSocketEncoder();
26 26
27 // Creates and returns an encoder for a server without extensions. 27 // Creates and returns an encoder for a server without extensions.
28 static scoped_ptr<WebSocketEncoder> CreateServer(); 28 static std::unique_ptr<WebSocketEncoder> CreateServer();
29 // Creates and returns an encoder. 29 // Creates and returns an encoder.
30 // |extensions| is the value of a Sec-WebSocket-Extensions header. 30 // |extensions| is the value of a Sec-WebSocket-Extensions header.
31 // Returns nullptr when there is an error. 31 // Returns nullptr when there is an error.
32 static scoped_ptr<WebSocketEncoder> CreateServer( 32 static std::unique_ptr<WebSocketEncoder> CreateServer(
33 const std::string& extensions, 33 const std::string& extensions,
34 WebSocketDeflateParameters* params); 34 WebSocketDeflateParameters* params);
35 static scoped_ptr<WebSocketEncoder> CreateClient( 35 static std::unique_ptr<WebSocketEncoder> CreateClient(
36 const std::string& response_extensions); 36 const std::string& response_extensions);
37 37
38 WebSocket::ParseResult DecodeFrame(const base::StringPiece& frame, 38 WebSocket::ParseResult DecodeFrame(const base::StringPiece& frame,
39 int* bytes_consumed, 39 int* bytes_consumed,
40 std::string* output); 40 std::string* output);
41 void EncodeFrame(const std::string& frame, 41 void EncodeFrame(const std::string& frame,
42 int masking_key, 42 int masking_key,
43 std::string* output); 43 std::string* output);
44 44
45 bool deflate_enabled() const { return !!deflater_; } 45 bool deflate_enabled() const { return !!deflater_; }
46 46
47 private: 47 private:
48 enum Type { 48 enum Type {
49 FOR_SERVER, 49 FOR_SERVER,
50 FOR_CLIENT, 50 FOR_CLIENT,
51 }; 51 };
52 52
53 WebSocketEncoder(Type type, 53 WebSocketEncoder(Type type,
54 scoped_ptr<WebSocketDeflater> deflater, 54 std::unique_ptr<WebSocketDeflater> deflater,
55 scoped_ptr<WebSocketInflater> inflater); 55 std::unique_ptr<WebSocketInflater> inflater);
56 56
57 bool Inflate(std::string* message); 57 bool Inflate(std::string* message);
58 bool Deflate(const std::string& message, std::string* output); 58 bool Deflate(const std::string& message, std::string* output);
59 59
60 Type type_; 60 Type type_;
61 scoped_ptr<WebSocketDeflater> deflater_; 61 std::unique_ptr<WebSocketDeflater> deflater_;
62 scoped_ptr<WebSocketInflater> inflater_; 62 std::unique_ptr<WebSocketInflater> inflater_;
63 63
64 DISALLOW_COPY_AND_ASSIGN(WebSocketEncoder); 64 DISALLOW_COPY_AND_ASSIGN(WebSocketEncoder);
65 }; 65 };
66 66
67 } // namespace net 67 } // namespace net
68 68
69 #endif // NET_SERVER_WEB_SOCKET_ENCODER_H_ 69 #endif // NET_SERVER_WEB_SOCKET_ENCODER_H_
OLDNEW
« no previous file with comments | « net/server/web_socket.h ('k') | net/server/web_socket_encoder.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698