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 "content/browser/appcache/appcache_response.h" | 5 #include "content/browser/appcache/appcache_response.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/bind_helpers.h" | 8 #include "base/bind_helpers.h" |
9 #include "base/compiler_specific.h" | 9 #include "base/compiler_specific.h" |
10 #include "base/location.h" | |
11 #include "base/logging.h" | 10 #include "base/logging.h" |
| 11 #include "base/message_loop/message_loop.h" |
12 #include "base/numerics/safe_math.h" | 12 #include "base/numerics/safe_math.h" |
13 #include "base/pickle.h" | 13 #include "base/pickle.h" |
14 #include "base/profiler/scoped_tracker.h" | 14 #include "base/profiler/scoped_tracker.h" |
15 #include "base/single_thread_task_runner.h" | |
16 #include "base/strings/string_util.h" | 15 #include "base/strings/string_util.h" |
17 #include "base/thread_task_runner_handle.h" | |
18 #include "content/browser/appcache/appcache_storage.h" | 16 #include "content/browser/appcache/appcache_storage.h" |
19 #include "net/base/completion_callback.h" | 17 #include "net/base/completion_callback.h" |
20 #include "net/base/io_buffer.h" | 18 #include "net/base/io_buffer.h" |
21 #include "net/base/net_errors.h" | 19 #include "net/base/net_errors.h" |
22 | 20 |
23 namespace content { | 21 namespace content { |
24 | 22 |
25 namespace { | 23 namespace { |
26 | 24 |
27 // Disk cache entry data indices. | 25 // Disk cache entry data indices. |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
85 buffer_len_(0), | 83 buffer_len_(0), |
86 weak_factory_(this) { | 84 weak_factory_(this) { |
87 } | 85 } |
88 | 86 |
89 AppCacheResponseIO::~AppCacheResponseIO() { | 87 AppCacheResponseIO::~AppCacheResponseIO() { |
90 if (entry_) | 88 if (entry_) |
91 entry_->Close(); | 89 entry_->Close(); |
92 } | 90 } |
93 | 91 |
94 void AppCacheResponseIO::ScheduleIOCompletionCallback(int result) { | 92 void AppCacheResponseIO::ScheduleIOCompletionCallback(int result) { |
95 base::ThreadTaskRunnerHandle::Get()->PostTask( | 93 base::MessageLoop::current()->PostTask( |
96 FROM_HERE, base::Bind(&AppCacheResponseIO::OnIOComplete, | 94 FROM_HERE, base::Bind(&AppCacheResponseIO::OnIOComplete, |
97 weak_factory_.GetWeakPtr(), result)); | 95 weak_factory_.GetWeakPtr(), result)); |
98 } | 96 } |
99 | 97 |
100 void AppCacheResponseIO::InvokeUserCompletionCallback(int result) { | 98 void AppCacheResponseIO::InvokeUserCompletionCallback(int result) { |
101 // Clear the user callback and buffers prior to invoking the callback | 99 // Clear the user callback and buffers prior to invoking the callback |
102 // so the caller can schedule additional operations in the callback. | 100 // so the caller can schedule additional operations in the callback. |
103 buffer_ = NULL; | 101 buffer_ = NULL; |
104 info_buffer_ = NULL; | 102 info_buffer_ = NULL; |
105 net::CompletionCallback cb = callback_; | 103 net::CompletionCallback cb = callback_; |
(...skipping 371 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
477 } | 475 } |
478 WriteRaw(kResponseMetadataIndex, 0, buffer_.get(), write_amount_); | 476 WriteRaw(kResponseMetadataIndex, 0, buffer_.get(), write_amount_); |
479 } | 477 } |
480 | 478 |
481 void AppCacheResponseMetadataWriter::OnIOComplete(int result) { | 479 void AppCacheResponseMetadataWriter::OnIOComplete(int result) { |
482 DCHECK(result < 0 || write_amount_ == result); | 480 DCHECK(result < 0 || write_amount_ == result); |
483 InvokeUserCompletionCallback(result); | 481 InvokeUserCompletionCallback(result); |
484 } | 482 } |
485 | 483 |
486 } // namespace content | 484 } // namespace content |
OLD | NEW |