OLD | NEW |
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/in_flight_backend_io.h" | 5 #include "net/disk_cache/blockfile/in_flight_backend_io.h" |
6 | 6 |
7 #include <utility> | 7 #include <utility> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/bind_helpers.h" | 10 #include "base/bind_helpers.h" |
11 #include "base/compiler_specific.h" | 11 #include "base/compiler_specific.h" |
12 #include "base/logging.h" | 12 #include "base/logging.h" |
13 #include "base/single_thread_task_runner.h" | 13 #include "base/single_thread_task_runner.h" |
| 14 #include "base/trace_event/trace_event.h" |
14 #include "net/base/net_errors.h" | 15 #include "net/base/net_errors.h" |
15 #include "net/disk_cache/blockfile/backend_impl.h" | 16 #include "net/disk_cache/blockfile/backend_impl.h" |
16 #include "net/disk_cache/blockfile/entry_impl.h" | 17 #include "net/disk_cache/blockfile/entry_impl.h" |
17 #include "net/disk_cache/blockfile/histogram_macros.h" | 18 #include "net/disk_cache/blockfile/histogram_macros.h" |
18 | 19 |
19 // Provide a BackendImpl object to macros from histogram_macros.h. | 20 // Provide a BackendImpl object to macros from histogram_macros.h. |
20 #define CACHE_UMA_BACKEND_IMPL_OBJ backend_ | 21 #define CACHE_UMA_BACKEND_IMPL_OBJ backend_ |
21 | 22 |
22 namespace disk_cache { | 23 namespace disk_cache { |
23 | 24 |
(...skipping 203 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
227 return operation_ == OP_OPEN || operation_ == OP_CREATE || | 228 return operation_ == OP_OPEN || operation_ == OP_CREATE || |
228 operation_ == OP_OPEN_NEXT; | 229 operation_ == OP_OPEN_NEXT; |
229 } | 230 } |
230 | 231 |
231 base::TimeDelta BackendIO::ElapsedTime() const { | 232 base::TimeDelta BackendIO::ElapsedTime() const { |
232 return base::TimeTicks::Now() - start_time_; | 233 return base::TimeTicks::Now() - start_time_; |
233 } | 234 } |
234 | 235 |
235 // Runs on the background thread. | 236 // Runs on the background thread. |
236 void BackendIO::ExecuteBackendOperation() { | 237 void BackendIO::ExecuteBackendOperation() { |
| 238 TRACE_EVENT0("net", "net::BackendIO::ExecuteBackendOperation"); |
237 switch (operation_) { | 239 switch (operation_) { |
238 case OP_INIT: | 240 case OP_INIT: |
239 result_ = backend_->SyncInit(); | 241 result_ = backend_->SyncInit(); |
240 break; | 242 break; |
241 case OP_OPEN: | 243 case OP_OPEN: |
242 result_ = backend_->SyncOpenEntry(key_, entry_ptr_); | 244 result_ = backend_->SyncOpenEntry(key_, entry_ptr_); |
243 break; | 245 break; |
244 case OP_CREATE: | 246 case OP_CREATE: |
245 result_ = backend_->SyncCreateEntry(key_, entry_ptr_); | 247 result_ = backend_->SyncCreateEntry(key_, entry_ptr_); |
246 break; | 248 break; |
(...skipping 288 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
535 background_thread_->PostTask( | 537 background_thread_->PostTask( |
536 FROM_HERE, base::Bind(&BackendIO::ExecuteOperation, operation)); | 538 FROM_HERE, base::Bind(&BackendIO::ExecuteOperation, operation)); |
537 OnOperationPosted(operation); | 539 OnOperationPosted(operation); |
538 } | 540 } |
539 | 541 |
540 base::WeakPtr<InFlightBackendIO> InFlightBackendIO::GetWeakPtr() { | 542 base::WeakPtr<InFlightBackendIO> InFlightBackendIO::GetWeakPtr() { |
541 return ptr_factory_.GetWeakPtr(); | 543 return ptr_factory_.GetWeakPtr(); |
542 } | 544 } |
543 | 545 |
544 } // namespace | 546 } // namespace |
OLD | NEW |