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

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

Issue 992733002: Remove //net (except for Android test stuff) and sdch (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 5 years, 9 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
« no previous file with comments | « net/disk_cache/blockfile/file_lock.h ('k') | net/disk_cache/blockfile/file_posix.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
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 "net/disk_cache/blockfile/file_lock.h"
6
7 #include "base/atomicops.h"
8
9 namespace {
10
11 void Barrier() {
12 #if !defined(COMPILER_MSVC)
13 // VS uses memory barrier semantics for volatiles.
14 base::subtle::MemoryBarrier();
15 #endif
16 }
17
18 } // namespace
19
20 namespace disk_cache {
21
22 FileLock::FileLock(BlockFileHeader* header) {
23 updating_ = &header->updating;
24 (*updating_)++;
25 Barrier();
26 acquired_ = true;
27 }
28
29 FileLock::~FileLock() {
30 Unlock();
31 }
32
33 void FileLock::Lock() {
34 if (acquired_)
35 return;
36 (*updating_)++;
37 Barrier();
38 }
39
40 void FileLock::Unlock() {
41 if (!acquired_)
42 return;
43 Barrier();
44 (*updating_)--;
45 }
46
47 } // namespace disk_cache
OLDNEW
« no previous file with comments | « net/disk_cache/blockfile/file_lock.h ('k') | net/disk_cache/blockfile/file_posix.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698