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

Side by Side Diff: net/disk_cache/simple/simple_entry_operation.cc

Issue 22859060: Fix race condition for non-open/create operations happening after a doom. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 3 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 | Annotate | Revision Log
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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/simple/simple_entry_operation.h" 5 #include "net/disk_cache/simple/simple_entry_operation.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "net/base/io_buffer.h" 8 #include "net/base/io_buffer.h"
9 #include "net/disk_cache/disk_cache.h" 9 #include "net/disk_cache/disk_cache.h"
10 #include "net/disk_cache/simple/simple_entry_impl.h" 10 #include "net/disk_cache/simple/simple_entry_impl.h"
(...skipping 10 matching lines...) Expand all
21 type_(other.type_), 21 type_(other.type_),
22 have_index_(other.have_index_), 22 have_index_(other.have_index_),
23 index_(other.index_), 23 index_(other.index_),
24 truncate_(other.truncate_), 24 truncate_(other.truncate_),
25 optimistic_(other.optimistic_), 25 optimistic_(other.optimistic_),
26 alone_in_queue_(other.alone_in_queue_) { 26 alone_in_queue_(other.alone_in_queue_) {
27 } 27 }
28 28
29 SimpleEntryOperation::~SimpleEntryOperation() {} 29 SimpleEntryOperation::~SimpleEntryOperation() {}
30 30
31 // Static. 31 // static
32 SimpleEntryOperation SimpleEntryOperation::OpenOperation( 32 SimpleEntryOperation SimpleEntryOperation::OpenOperation(
33 SimpleEntryImpl* entry, 33 SimpleEntryImpl* entry,
34 bool have_index, 34 bool have_index,
35 const CompletionCallback& callback, 35 const CompletionCallback& callback,
36 Entry** out_entry) { 36 Entry** out_entry) {
37 return SimpleEntryOperation(entry, 37 return SimpleEntryOperation(entry,
38 NULL, 38 NULL,
39 callback, 39 callback,
40 out_entry, 40 out_entry,
41 0, 41 0,
42 0, 42 0,
43 TYPE_OPEN, 43 TYPE_OPEN,
44 have_index, 44 have_index,
45 0, 45 0,
46 false, 46 false,
47 false, 47 false,
48 false); 48 false);
49 } 49 }
50 50
51 // Static. 51 // static
52 SimpleEntryOperation SimpleEntryOperation::CreateOperation( 52 SimpleEntryOperation SimpleEntryOperation::CreateOperation(
53 SimpleEntryImpl* entry, 53 SimpleEntryImpl* entry,
54 bool have_index, 54 bool have_index,
55 const CompletionCallback& callback, 55 const CompletionCallback& callback,
56 Entry** out_entry) { 56 Entry** out_entry) {
57 return SimpleEntryOperation(entry, 57 return SimpleEntryOperation(entry,
58 NULL, 58 NULL,
59 callback, 59 callback,
60 out_entry, 60 out_entry,
61 0, 61 0,
62 0, 62 0,
63 TYPE_CREATE, 63 TYPE_CREATE,
64 have_index, 64 have_index,
65 0, 65 0,
66 false, 66 false,
67 false, 67 false,
68 false); 68 false);
69 } 69 }
70 70
71 // Static. 71 // static
72 SimpleEntryOperation SimpleEntryOperation::CloseOperation( 72 SimpleEntryOperation SimpleEntryOperation::CloseOperation(
73 SimpleEntryImpl* entry) { 73 SimpleEntryImpl* entry) {
74 return SimpleEntryOperation(entry, 74 return SimpleEntryOperation(entry,
75 NULL, 75 NULL,
76 CompletionCallback(), 76 CompletionCallback(),
77 NULL, 77 NULL,
78 0, 78 0,
79 0, 79 0,
80 TYPE_CLOSE, 80 TYPE_CLOSE,
81 false, 81 false,
82 0, 82 0,
83 false, 83 false,
84 false, 84 false,
85 false); 85 false);
86 } 86 }
87 87
88 // Static. 88 // static
89 SimpleEntryOperation SimpleEntryOperation::ReadOperation( 89 SimpleEntryOperation SimpleEntryOperation::ReadOperation(
90 SimpleEntryImpl* entry, 90 SimpleEntryImpl* entry,
91 int index, 91 int index,
92 int offset, 92 int offset,
93 int length, 93 int length,
94 net::IOBuffer* buf, 94 net::IOBuffer* buf,
95 const CompletionCallback& callback, 95 const CompletionCallback& callback,
96 bool alone_in_queue) { 96 bool alone_in_queue) {
97 return SimpleEntryOperation(entry, 97 return SimpleEntryOperation(entry,
98 buf, 98 buf,
99 callback, 99 callback,
100 NULL, 100 NULL,
101 offset, 101 offset,
102 length, 102 length,
103 TYPE_READ, 103 TYPE_READ,
104 false, 104 false,
105 index, 105 index,
106 false, 106 false,
107 false, 107 false,
108 alone_in_queue); 108 alone_in_queue);
109 } 109 }
110 110
111 // Static. 111 // static
112 SimpleEntryOperation SimpleEntryOperation::WriteOperation( 112 SimpleEntryOperation SimpleEntryOperation::WriteOperation(
113 SimpleEntryImpl* entry, 113 SimpleEntryImpl* entry,
114 int index, 114 int index,
115 int offset, 115 int offset,
116 int length, 116 int length,
117 net::IOBuffer* buf, 117 net::IOBuffer* buf,
118 bool truncate, 118 bool truncate,
119 bool optimistic, 119 bool optimistic,
120 const CompletionCallback& callback) { 120 const CompletionCallback& callback) {
121 return SimpleEntryOperation(entry, 121 return SimpleEntryOperation(entry,
122 buf, 122 buf,
123 callback, 123 callback,
124 NULL, 124 NULL,
125 offset, 125 offset,
126 length, 126 length,
127 TYPE_WRITE, 127 TYPE_WRITE,
128 false, 128 false,
129 index, 129 index,
130 truncate, 130 truncate,
131 optimistic, 131 optimistic,
132 false); 132 false);
133 } 133 }
134 134
gavinp 2013/08/26 20:36:50 // static And you were so good everywhere else!
Philippe 2013/08/27 11:33:30 Ahaha :)
135 SimpleEntryOperation SimpleEntryOperation::DoomOperation(
136 SimpleEntryImpl* entry,
137 const CompletionCallback& callback) {
138 return SimpleEntryOperation(entry,
139 NULL,
140 callback,
141 NULL,
142 0,
143 0,
144 TYPE_DOOM,
145 false,
gavinp 2013/08/26 20:36:50 All these booleans make me dizzy. Can you make a c
Philippe 2013/08/27 11:33:30 Yeah I was also pretty sad to have to add this cod
146 0,
147 false,
148 false,
149 false);
150 }
151
135 bool SimpleEntryOperation::ConflictsWith( 152 bool SimpleEntryOperation::ConflictsWith(
136 const SimpleEntryOperation& other_op) const { 153 const SimpleEntryOperation& other_op) const {
137 if (type_ != TYPE_READ && type_ != TYPE_WRITE) 154 if (type_ != TYPE_READ && type_ != TYPE_WRITE)
138 return true; 155 return true;
139 if (other_op.type() != TYPE_READ && other_op.type() != TYPE_WRITE) 156 if (other_op.type() != TYPE_READ && other_op.type() != TYPE_WRITE)
140 return true; 157 return true;
141 if (type() == TYPE_READ && other_op.type() == TYPE_READ) 158 if (type() == TYPE_READ && other_op.type() == TYPE_READ)
142 return false; 159 return false;
143 if (index_ != other_op.index_) 160 if (index_ != other_op.index_)
144 return false; 161 return false;
(...skipping 30 matching lines...) Expand all
175 length_(length), 192 length_(length),
176 type_(type), 193 type_(type),
177 have_index_(have_index), 194 have_index_(have_index),
178 index_(index), 195 index_(index),
179 truncate_(truncate), 196 truncate_(truncate),
180 optimistic_(optimistic), 197 optimistic_(optimistic),
181 alone_in_queue_(alone_in_queue) { 198 alone_in_queue_(alone_in_queue) {
182 } 199 }
183 200
184 } // namespace disk_cache 201 } // namespace disk_cache
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698