• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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
3 // found in the LICENSE file.
4 
5 #include "content/common/socket_stream_handle_data.h"
6 
7 #include "webkit/child/websocketstreamhandle_impl.h"
8 
9 using webkit_glue::WebSocketStreamHandleImpl;
10 using blink::WebSocketStreamHandle;
11 
12 namespace content {
13 
14 // static
AddToHandle(WebSocketStreamHandle * handle,int render_view_id)15 void SocketStreamHandleData::AddToHandle(
16     WebSocketStreamHandle* handle, int render_view_id) {
17   if (!handle) {
18     NOTREACHED();
19     return;
20   }
21   WebSocketStreamHandleImpl* impl =
22       static_cast<WebSocketStreamHandleImpl*>(handle);
23   impl->SetUserData(handle, new SocketStreamHandleData(render_view_id));
24 }
25 
26 // static
ForHandle(WebSocketStreamHandle * handle)27 const SocketStreamHandleData* SocketStreamHandleData::ForHandle(
28     WebSocketStreamHandle* handle) {
29   if (!handle)
30     return NULL;
31   WebSocketStreamHandleImpl* impl =
32       static_cast<WebSocketStreamHandleImpl*>(handle);
33   return static_cast<SocketStreamHandleData*>(impl->GetUserData(handle));
34 }
35 
36 }  // namespace content
37