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 "base/location.h" | 5 #include "base/location.h" |
6 #include "base/message_loop_proxy.h" | 6 #include "base/message_loop_proxy.h" |
7 #include "base/task_runner_util.h" | 7 #include "base/task_runner_util.h" |
8 #include "net/base/io_buffer.h" | 8 #include "net/base/io_buffer.h" |
9 #include "net/base/net_errors.h" | 9 #include "net/base/net_errors.h" |
10 #include "net/disk_cache/flash/flash_entry_impl.h" | 10 #include "net/disk_cache/flash/flash_entry_impl.h" |
(...skipping 13 matching lines...) Expand all Loading... |
24 | 24 |
25 FlashEntryImpl::FlashEntryImpl(int32 id, | 25 FlashEntryImpl::FlashEntryImpl(int32 id, |
26 LogStore* store, | 26 LogStore* store, |
27 base::MessageLoopProxy* cache_thread) | 27 base::MessageLoopProxy* cache_thread) |
28 : init_(false), | 28 : init_(false), |
29 old_internal_entry_(new InternalEntry(id, store)), | 29 old_internal_entry_(new InternalEntry(id, store)), |
30 cache_thread_(cache_thread) { | 30 cache_thread_(cache_thread) { |
31 } | 31 } |
32 | 32 |
33 int FlashEntryImpl::Init(const CompletionCallback& callback) { | 33 int FlashEntryImpl::Init(const CompletionCallback& callback) { |
34 if (new_internal_entry_) { | 34 if (new_internal_entry_.get()) { |
35 DCHECK(callback.is_null()); | 35 DCHECK(callback.is_null()); |
36 init_ = true; | 36 init_ = true; |
37 return net::OK; | 37 return net::OK; |
38 } | 38 } |
39 DCHECK(!callback.is_null() && old_internal_entry_); | 39 DCHECK(!callback.is_null() && old_internal_entry_.get()); |
40 callback_ = callback; | 40 callback_ = callback; |
41 PostTaskAndReplyWithResult(cache_thread_, FROM_HERE, | 41 PostTaskAndReplyWithResult(cache_thread_.get(), |
| 42 FROM_HERE, |
42 Bind(&InternalEntry::Init, old_internal_entry_), | 43 Bind(&InternalEntry::Init, old_internal_entry_), |
43 Bind(&FlashEntryImpl::OnInitComplete, this)); | 44 Bind(&FlashEntryImpl::OnInitComplete, this)); |
44 return net::ERR_IO_PENDING; | 45 return net::ERR_IO_PENDING; |
45 } | 46 } |
46 | 47 |
47 void FlashEntryImpl::Doom() { | 48 void FlashEntryImpl::Doom() { |
48 DCHECK(init_); | 49 DCHECK(init_); |
49 NOTREACHED(); | 50 NOTREACHED(); |
50 } | 51 } |
51 | 52 |
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
140 callback_.Run(net::OK); | 141 callback_.Run(net::OK); |
141 } | 142 } |
142 } | 143 } |
143 | 144 |
144 FlashEntryImpl::~FlashEntryImpl() { | 145 FlashEntryImpl::~FlashEntryImpl() { |
145 cache_thread_->PostTask(FROM_HERE, | 146 cache_thread_->PostTask(FROM_HERE, |
146 Bind(&InternalEntry::Close, new_internal_entry_)); | 147 Bind(&InternalEntry::Close, new_internal_entry_)); |
147 } | 148 } |
148 | 149 |
149 } // namespace disk_cache | 150 } // namespace disk_cache |
OLD | NEW |