OLD | NEW |
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 Loading... |
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 |
| 135 // static |
| 136 SimpleEntryOperation SimpleEntryOperation::DoomOperation( |
| 137 SimpleEntryImpl* entry, |
| 138 const CompletionCallback& callback) { |
| 139 net::IOBuffer* const buf = NULL; |
| 140 Entry** const out_entry = NULL; |
| 141 const int offset = 0; |
| 142 const int length = 0; |
| 143 const bool have_index = false; |
| 144 const int index = 0; |
| 145 const bool truncate = false; |
| 146 const bool optimistic = false; |
| 147 const bool alone_in_queue = false; |
| 148 return SimpleEntryOperation(entry, |
| 149 buf, |
| 150 callback, |
| 151 out_entry, |
| 152 offset, |
| 153 length, |
| 154 TYPE_DOOM, |
| 155 have_index, |
| 156 index, |
| 157 truncate, |
| 158 optimistic, |
| 159 alone_in_queue); |
| 160 } |
| 161 |
135 bool SimpleEntryOperation::ConflictsWith( | 162 bool SimpleEntryOperation::ConflictsWith( |
136 const SimpleEntryOperation& other_op) const { | 163 const SimpleEntryOperation& other_op) const { |
137 if (type_ != TYPE_READ && type_ != TYPE_WRITE) | 164 if (type_ != TYPE_READ && type_ != TYPE_WRITE) |
138 return true; | 165 return true; |
139 if (other_op.type() != TYPE_READ && other_op.type() != TYPE_WRITE) | 166 if (other_op.type() != TYPE_READ && other_op.type() != TYPE_WRITE) |
140 return true; | 167 return true; |
141 if (type() == TYPE_READ && other_op.type() == TYPE_READ) | 168 if (type() == TYPE_READ && other_op.type() == TYPE_READ) |
142 return false; | 169 return false; |
143 if (index_ != other_op.index_) | 170 if (index_ != other_op.index_) |
144 return false; | 171 return false; |
(...skipping 30 matching lines...) Expand all Loading... |
175 length_(length), | 202 length_(length), |
176 type_(type), | 203 type_(type), |
177 have_index_(have_index), | 204 have_index_(have_index), |
178 index_(index), | 205 index_(index), |
179 truncate_(truncate), | 206 truncate_(truncate), |
180 optimistic_(optimistic), | 207 optimistic_(optimistic), |
181 alone_in_queue_(alone_in_queue) { | 208 alone_in_queue_(alone_in_queue) { |
182 } | 209 } |
183 | 210 |
184 } // namespace disk_cache | 211 } // namespace disk_cache |
OLD | NEW |