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

Side by Side Diff: net/disk_cache/blockfile/file_win.cc

Issue 826973002: replace COMPILE_ASSERT with static_assert in net/ (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase on master Created 5 years, 11 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 (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 "net/disk_cache/blockfile/file.h" 5 #include "net/disk_cache/blockfile/file.h"
6 6
7 #include "base/files/file_path.h" 7 #include "base/files/file_path.h"
8 #include "base/lazy_instance.h" 8 #include "base/lazy_instance.h"
9 #include "base/message_loop/message_loop.h" 9 #include "base/message_loop/message_loop.h"
10 #include "net/base/net_errors.h" 10 #include "net/base/net_errors.h"
11 #include "net/disk_cache/disk_cache.h" 11 #include "net/disk_cache/disk_cache.h"
12 12
13 namespace { 13 namespace {
14 14
15 // Structure used for asynchronous operations. 15 // Structure used for asynchronous operations.
16 struct MyOverlapped { 16 struct MyOverlapped {
17 MyOverlapped(disk_cache::File* file, size_t offset, 17 MyOverlapped(disk_cache::File* file, size_t offset,
18 disk_cache::FileIOCallback* callback); 18 disk_cache::FileIOCallback* callback);
19 ~MyOverlapped() {} 19 ~MyOverlapped() {}
20 OVERLAPPED* overlapped() { 20 OVERLAPPED* overlapped() {
21 return &context_.overlapped; 21 return &context_.overlapped;
22 } 22 }
23 23
24 base::MessageLoopForIO::IOContext context_; 24 base::MessageLoopForIO::IOContext context_;
25 scoped_refptr<disk_cache::File> file_; 25 scoped_refptr<disk_cache::File> file_;
26 disk_cache::FileIOCallback* callback_; 26 disk_cache::FileIOCallback* callback_;
27 }; 27 };
28 28
29 COMPILE_ASSERT(!offsetof(MyOverlapped, context_), starts_with_overlapped); 29 static_assert(!offsetof(MyOverlapped, context_),
Deprecated (see juliatuttle) 2015/01/05 22:22:39 This would be clearer as "offsetof(...) == 0", if
Mostyn Bramley-Moore 2015/01/06 00:07:07 Done.
30 "should start with overlapped");
30 31
31 // Helper class to handle the IO completion notifications from the message loop. 32 // Helper class to handle the IO completion notifications from the message loop.
32 class CompletionHandler : public base::MessageLoopForIO::IOHandler { 33 class CompletionHandler : public base::MessageLoopForIO::IOHandler {
33 virtual void OnIOCompleted(base::MessageLoopForIO::IOContext* context, 34 virtual void OnIOCompleted(base::MessageLoopForIO::IOContext* context,
34 DWORD actual_bytes, 35 DWORD actual_bytes,
35 DWORD error); 36 DWORD error);
36 }; 37 };
37 38
38 static base::LazyInstance<CompletionHandler> g_completion_handler = 39 static base::LazyInstance<CompletionHandler> g_completion_handler =
39 LAZY_INSTANCE_INITIALIZER; 40 LAZY_INSTANCE_INITIALIZER;
(...skipping 208 matching lines...) Expand 10 before | Expand all | Expand 10 after
248 base::MessageLoopForIO::IOHandler* handler = g_completion_handler.Pointer(); 249 base::MessageLoopForIO::IOHandler* handler = g_completion_handler.Pointer();
249 base::MessageLoopForIO::current()->WaitForIOCompletion(100, handler); 250 base::MessageLoopForIO::current()->WaitForIOCompletion(100, handler);
250 } 251 }
251 } 252 }
252 253
253 // Static. 254 // Static.
254 void File::DropPendingIO() { 255 void File::DropPendingIO() {
255 } 256 }
256 257
257 } // namespace disk_cache 258 } // namespace disk_cache
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698