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

Side by Side Diff: components/html_viewer/web_socket_handle_impl.cc

Issue 1468803002: Switch to static_assert. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@assert1
Patch Set: message cleanup Created 5 years 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 #include "components/html_viewer/web_socket_handle_impl.h" 5 #include "components/html_viewer/web_socket_handle_impl.h"
6 6
7 #include <vector> 7 #include <vector>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/macros.h" 10 #include "base/macros.h"
(...skipping 22 matching lines...) Expand all
33 33
34 namespace mojo { 34 namespace mojo {
35 35
36 template<> 36 template<>
37 struct TypeConverter<WebSocket::MessageType, WebSocketHandle::MessageType> { 37 struct TypeConverter<WebSocket::MessageType, WebSocketHandle::MessageType> {
38 static WebSocket::MessageType Convert(WebSocketHandle::MessageType type) { 38 static WebSocket::MessageType Convert(WebSocketHandle::MessageType type) {
39 DCHECK(type == WebSocketHandle::MessageTypeContinuation || 39 DCHECK(type == WebSocketHandle::MessageTypeContinuation ||
40 type == WebSocketHandle::MessageTypeText || 40 type == WebSocketHandle::MessageTypeText ||
41 type == WebSocketHandle::MessageTypeBinary); 41 type == WebSocketHandle::MessageTypeBinary);
42 typedef WebSocket::MessageType MessageType; 42 typedef WebSocket::MessageType MessageType;
43 COMPILE_ASSERT( 43 static_assert(
44 static_cast<MessageType>(WebSocketHandle::MessageTypeContinuation) == 44 static_cast<MessageType>(WebSocketHandle::MessageTypeContinuation) ==
45 WebSocket::MESSAGE_TYPE_CONTINUATION, 45 WebSocket::MESSAGE_TYPE_CONTINUATION,
46 enum_values_must_match_for_message_type); 46 "WebSocket and WebSocketHandle enum values must match");
47 COMPILE_ASSERT( 47 static_assert(static_cast<MessageType>(WebSocketHandle::MessageTypeText) ==
48 static_cast<MessageType>(WebSocketHandle::MessageTypeText) == 48 WebSocket::MESSAGE_TYPE_TEXT,
49 WebSocket::MESSAGE_TYPE_TEXT, 49 "WebSocket and WebSocketHandle enum values must match");
50 enum_values_must_match_for_message_type); 50 static_assert(
51 COMPILE_ASSERT(
52 static_cast<MessageType>(WebSocketHandle::MessageTypeBinary) == 51 static_cast<MessageType>(WebSocketHandle::MessageTypeBinary) ==
53 WebSocket::MESSAGE_TYPE_BINARY, 52 WebSocket::MESSAGE_TYPE_BINARY,
54 enum_values_must_match_for_message_type); 53 "WebSocket and WebSocketHandle enum values must match");
55 return static_cast<WebSocket::MessageType>(type); 54 return static_cast<WebSocket::MessageType>(type);
56 } 55 }
57 }; 56 };
58 57
59 template<> 58 template<>
60 struct TypeConverter<WebSocketHandle::MessageType, WebSocket::MessageType> { 59 struct TypeConverter<WebSocketHandle::MessageType, WebSocket::MessageType> {
61 static WebSocketHandle::MessageType Convert(WebSocket::MessageType type) { 60 static WebSocketHandle::MessageType Convert(WebSocket::MessageType type) {
62 DCHECK(type == WebSocket::MESSAGE_TYPE_CONTINUATION || 61 DCHECK(type == WebSocket::MESSAGE_TYPE_CONTINUATION ||
63 type == WebSocket::MESSAGE_TYPE_TEXT || 62 type == WebSocket::MESSAGE_TYPE_TEXT ||
64 type == WebSocket::MESSAGE_TYPE_BINARY); 63 type == WebSocket::MESSAGE_TYPE_BINARY);
(...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after
216 const char* data) { 215 const char* data) {
217 web_socket_->Send(fin, ConvertTo<WebSocket::MessageType>(type), num_bytes); 216 web_socket_->Send(fin, ConvertTo<WebSocket::MessageType>(type), num_bytes);
218 } 217 }
219 218
220 void WebSocketHandleImpl::Disconnect() { 219 void WebSocketHandleImpl::Disconnect() {
221 did_close_ = true; 220 did_close_ = true;
222 client_.reset(); 221 client_.reset();
223 } 222 }
224 223
225 } // namespace html_viewer 224 } // namespace html_viewer
OLDNEW
« no previous file with comments | « components/html_viewer/html_frame_properties.cc ('k') | components/mus/public/cpp/window_property.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698