OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 #include "content/browser/websockets/websocket_handshake_request_info_impl.h" | 5 #include "content/browser/websockets/websocket_handshake_request_info_impl.h" |
6 | 6 |
| 7 #include "base/memory/ptr_util.h" |
7 #include "net/url_request/url_request.h" | 8 #include "net/url_request/url_request.h" |
8 | 9 |
9 namespace content { | 10 namespace content { |
10 | 11 |
11 namespace { | 12 namespace { |
12 | 13 |
13 constexpr int g_tag = 0; | 14 constexpr int g_tag = 0; |
14 | 15 |
15 } // namesapce | 16 } // namesapce |
16 | 17 |
17 WebSocketHandshakeRequestInfoImpl::WebSocketHandshakeRequestInfoImpl( | 18 WebSocketHandshakeRequestInfoImpl::WebSocketHandshakeRequestInfoImpl( |
18 int child_id, | 19 int child_id, |
19 int render_frame_id) | 20 int render_frame_id) |
20 : child_id_(child_id), render_frame_id_(render_frame_id) {} | 21 : child_id_(child_id), render_frame_id_(render_frame_id) {} |
21 | 22 |
22 WebSocketHandshakeRequestInfoImpl::~WebSocketHandshakeRequestInfoImpl() {} | 23 WebSocketHandshakeRequestInfoImpl::~WebSocketHandshakeRequestInfoImpl() {} |
23 | 24 |
24 void WebSocketHandshakeRequestInfoImpl::CreateInfoAndAssociateWithRequest( | 25 void WebSocketHandshakeRequestInfoImpl::CreateInfoAndAssociateWithRequest( |
25 int child_id, | 26 int child_id, |
26 int render_frame_id, | 27 int render_frame_id, |
27 net::URLRequest* request) { | 28 net::URLRequest* request) { |
28 request->SetUserData( | 29 request->SetUserData(&g_tag, |
29 &g_tag, new WebSocketHandshakeRequestInfoImpl(child_id, render_frame_id)); | 30 base::WrapUnique(new WebSocketHandshakeRequestInfoImpl( |
| 31 child_id, render_frame_id))); |
30 } | 32 } |
31 | 33 |
32 int WebSocketHandshakeRequestInfoImpl::GetChildId() const { | 34 int WebSocketHandshakeRequestInfoImpl::GetChildId() const { |
33 return child_id_; | 35 return child_id_; |
34 } | 36 } |
35 | 37 |
36 int WebSocketHandshakeRequestInfoImpl::GetRenderFrameId() const { | 38 int WebSocketHandshakeRequestInfoImpl::GetRenderFrameId() const { |
37 return render_frame_id_; | 39 return render_frame_id_; |
38 } | 40 } |
39 | 41 |
40 const WebSocketHandshakeRequestInfo* WebSocketHandshakeRequestInfo::ForRequest( | 42 const WebSocketHandshakeRequestInfo* WebSocketHandshakeRequestInfo::ForRequest( |
41 const net::URLRequest* request) { | 43 const net::URLRequest* request) { |
42 return static_cast<WebSocketHandshakeRequestInfoImpl*>( | 44 return static_cast<WebSocketHandshakeRequestInfoImpl*>( |
43 request->GetUserData(&g_tag)); | 45 request->GetUserData(&g_tag)); |
44 } | 46 } |
45 | 47 |
46 } // namespace content | 48 } // namespace content |
OLD | NEW |