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

Side by Side Diff: components/devtools_bridge/socket_tunnel_connection.cc

Issue 794683005: replace COMPILE_ASSERT with static_assert in components/ (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: formatting fixup Created 5 years, 12 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
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/devtools_bridge/socket_tunnel_connection.h" 5 #include "components/devtools_bridge/socket_tunnel_connection.h"
6 6
7 #include <stdlib.h> 7 #include <stdlib.h>
8 8
9 #include "net/base/io_buffer.h" 9 #include "net/base/io_buffer.h"
10 #include "net/base/net_errors.h" 10 #include "net/base/net_errors.h"
(...skipping 12 matching lines...) Expand all
23 // data channel) we should disconnect if too much data buffered. 23 // data channel) we should disconnect if too much data buffered.
24 buffer_.push_back(); 24 buffer_.push_back();
25 if (buffer_.size() == 1) { 25 if (buffer_.size() == 1) {
26 current_ = new net::DrainableIOBuffer(chunk.get(), chunk->size()); 26 current_ = new net::DrainableIOBuffer(chunk.get(), chunk->size());
27 WriteCurrent(); 27 WriteCurrent();
28 } 28 }
29 } 29 }
30 30
31 void SocketTunnelConnection::BuildControlPacket(char* buffer, 31 void SocketTunnelConnection::BuildControlPacket(char* buffer,
32 int op_code) { 32 int op_code) {
33 COMPILE_ASSERT(kControlPacketSizeBytes == 3, 33 static_assert(kControlPacketSizeBytes == 3,
34 unexpected_control_packet_size); 34 "kControlPacketSizeBytes should equal 3");
35 buffer[0] = kControlConnectionId; 35 buffer[0] = kControlConnectionId;
36 buffer[1] = op_code; 36 buffer[1] = op_code;
37 buffer[2] = index_ + kMinConnectionId; 37 buffer[2] = index_ + kMinConnectionId;
38 } 38 }
39 39
40 void SocketTunnelConnection::WriteCurrent() { 40 void SocketTunnelConnection::WriteCurrent() {
41 while (true) { 41 while (true) {
42 while(current_->BytesRemaining() > 0) { 42 while(current_->BytesRemaining() > 0) {
43 int result = socket()->Write(current_.get(), current_->BytesRemaining(), 43 int result = socket()->Write(current_.get(), current_->BytesRemaining(),
44 base::Bind(&SocketTunnelConnection::OnWriteComplete, 44 base::Bind(&SocketTunnelConnection::OnWriteComplete,
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
87 void SocketTunnelConnection::OnReadComplete(int result) { 87 void SocketTunnelConnection::OnReadComplete(int result) {
88 if (result > 0) { 88 if (result > 0) {
89 OnDataPacketRead(read_buffer_->StartOfBuffer(), 89 OnDataPacketRead(read_buffer_->StartOfBuffer(),
90 read_buffer_->offset() + result); 90 read_buffer_->offset() + result);
91 } else { 91 } else {
92 OnReadError(result); 92 OnReadError(result);
93 } 93 }
94 } 94 }
95 95
96 } // namespace devtools_bridge 96 } // namespace devtools_bridge
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698