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

Side by Side Diff: base/sync_socket_win.cc

Issue 1467003002: Switch to static_assert in base/. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: / 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
« no previous file with comments | « base/sync_socket_unittest.cc ('k') | base/template_util_unittest.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 (c) 2012 The Chromium Authors. All rights reserved. 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 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 "base/sync_socket.h" 5 #include "base/sync_socket.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "base/rand_util.h" 8 #include "base/rand_util.h"
9 #include "base/threading/thread_restrictions.h" 9 #include "base/threading/thread_restrictions.h"
10 #include "base/win/scoped_handle.h" 10 #include "base/win/scoped_handle.h"
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after
114 size_t CancelableFileOperation(Function operation, 114 size_t CancelableFileOperation(Function operation,
115 HANDLE file, 115 HANDLE file,
116 BufferType* buffer, 116 BufferType* buffer,
117 size_t length, 117 size_t length,
118 WaitableEvent* io_event, 118 WaitableEvent* io_event,
119 WaitableEvent* cancel_event, 119 WaitableEvent* cancel_event,
120 CancelableSyncSocket* socket, 120 CancelableSyncSocket* socket,
121 DWORD timeout_in_ms) { 121 DWORD timeout_in_ms) {
122 ThreadRestrictions::AssertIOAllowed(); 122 ThreadRestrictions::AssertIOAllowed();
123 // The buffer must be byte size or the length check won't make much sense. 123 // The buffer must be byte size or the length check won't make much sense.
124 COMPILE_ASSERT(sizeof(buffer[0]) == sizeof(char), incorrect_buffer_type); 124 static_assert(sizeof(buffer[0]) == sizeof(char), "incorrect buffer type");
125 DCHECK_GT(length, 0u); 125 DCHECK_GT(length, 0u);
126 DCHECK_LE(length, kMaxMessageLength); 126 DCHECK_LE(length, kMaxMessageLength);
127 DCHECK_NE(file, SyncSocket::kInvalidHandle); 127 DCHECK_NE(file, SyncSocket::kInvalidHandle);
128 128
129 // Track the finish time so we can calculate the timeout as data is read. 129 // Track the finish time so we can calculate the timeout as data is read.
130 TimeTicks current_time, finish_time; 130 TimeTicks current_time, finish_time;
131 if (timeout_in_ms != INFINITE) { 131 if (timeout_in_ms != INFINITE) {
132 current_time = TimeTicks::Now(); 132 current_time = TimeTicks::Now();
133 finish_time = 133 finish_time =
134 current_time + base::TimeDelta::FromMilliseconds(timeout_in_ms); 134 current_time + base::TimeDelta::FromMilliseconds(timeout_in_ms);
(...skipping 198 matching lines...) Expand 10 before | Expand all | Expand 10 after
333 static_cast<DWORD>(timeout.InMilliseconds())); 333 static_cast<DWORD>(timeout.InMilliseconds()));
334 } 334 }
335 335
336 // static 336 // static
337 bool CancelableSyncSocket::CreatePair(CancelableSyncSocket* socket_a, 337 bool CancelableSyncSocket::CreatePair(CancelableSyncSocket* socket_a,
338 CancelableSyncSocket* socket_b) { 338 CancelableSyncSocket* socket_b) {
339 return CreatePairImpl(&socket_a->handle_, &socket_b->handle_, true); 339 return CreatePairImpl(&socket_a->handle_, &socket_b->handle_, true);
340 } 340 }
341 341
342 } // namespace base 342 } // namespace base
OLDNEW
« no previous file with comments | « base/sync_socket_unittest.cc ('k') | base/template_util_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698