OLD | NEW |
---|---|
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 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_impl.h" | 5 #include "net/disk_cache/simple/simple_entry_impl.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/callback.h" | 9 #include "base/callback.h" |
10 #include "base/location.h" | 10 #include "base/location.h" |
(...skipping 21 matching lines...) Expand all Loading... | |
32 using base::MessageLoopProxy; | 32 using base::MessageLoopProxy; |
33 using base::Time; | 33 using base::Time; |
34 using base::WorkerPool; | 34 using base::WorkerPool; |
35 | 35 |
36 // static | 36 // static |
37 int SimpleEntryImpl::OpenEntry(const scoped_refptr<SimpleIndex>& index, | 37 int SimpleEntryImpl::OpenEntry(const scoped_refptr<SimpleIndex>& index, |
38 const FilePath& path, | 38 const FilePath& path, |
39 const std::string& key, | 39 const std::string& key, |
40 Entry** entry, | 40 Entry** entry, |
41 const CompletionCallback& callback) { | 41 const CompletionCallback& callback) { |
42 // TODO(gavinp): More closely unify the last_used_ in the | 42 // If entry is not known to the index, initiate fast failover to the network. |
43 // SimpleSynchronousEntry and the SimpleIndex. | 43 if (index && !index->Has(key)) |
felipeg
2013/04/18 10:05:05
This change is not related and is not necessary to
pasko-google - do not use
2013/04/18 10:16:06
thanks for review, dodged a bug here.
Since I had
| |
44 if (!index || index->UseIfExists(key)) { | 44 return net::ERR_FAILED; |
45 scoped_refptr<SimpleEntryImpl> new_entry = | 45 |
46 new SimpleEntryImpl(index, path, key); | 46 // Go down to the disk to find the entry. |
47 SynchronousCreationCallback sync_creation_callback = | 47 scoped_refptr<SimpleEntryImpl> new_entry = |
48 base::Bind(&SimpleEntryImpl::CreationOperationComplete, | 48 new SimpleEntryImpl(index, path, key); |
49 new_entry, entry, callback); | 49 SynchronousCreationCallback sync_creation_callback = |
50 WorkerPool::PostTask(FROM_HERE, | 50 base::Bind(&SimpleEntryImpl::CreationOperationComplete, |
51 base::Bind(&SimpleSynchronousEntry::OpenEntry, path, | 51 new_entry, entry, callback); |
52 key, MessageLoopProxy::current(), | 52 WorkerPool::PostTask(FROM_HERE, |
53 sync_creation_callback), | 53 base::Bind(&SimpleSynchronousEntry::OpenEntry, path, |
54 true); | 54 key, MessageLoopProxy::current(), |
55 return net::ERR_IO_PENDING; | 55 sync_creation_callback), |
56 } | 56 true); |
57 return net::ERR_FAILED; | 57 return net::ERR_IO_PENDING; |
58 } | 58 } |
59 | 59 |
60 // static | 60 // static |
61 int SimpleEntryImpl::CreateEntry(const scoped_refptr<SimpleIndex>& index, | 61 int SimpleEntryImpl::CreateEntry(const scoped_refptr<SimpleIndex>& index, |
62 const FilePath& path, | 62 const FilePath& path, |
63 const std::string& key, | 63 const std::string& key, |
64 Entry** entry, | 64 Entry** entry, |
65 const CompletionCallback& callback) { | 65 const CompletionCallback& callback) { |
66 scoped_refptr<SimpleEntryImpl> new_entry = | 66 scoped_refptr<SimpleEntryImpl> new_entry = |
67 new SimpleEntryImpl(index, path, key); | 67 new SimpleEntryImpl(index, path, key); |
(...skipping 235 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
303 // adding an IO thread index (for fast misses etc...), we can store this data | 303 // adding an IO thread index (for fast misses etc...), we can store this data |
304 // in that structure. This also solves problems with last_used() on ext4 | 304 // in that structure. This also solves problems with last_used() on ext4 |
305 // filesystems not being accurate. | 305 // filesystems not being accurate. |
306 last_used_ = synchronous_entry_->last_used(); | 306 last_used_ = synchronous_entry_->last_used(); |
307 last_modified_ = synchronous_entry_->last_modified(); | 307 last_modified_ = synchronous_entry_->last_modified(); |
308 for (int i = 0; i < kSimpleEntryFileCount; ++i) | 308 for (int i = 0; i < kSimpleEntryFileCount; ++i) |
309 data_size_[i] = synchronous_entry_->data_size(i); | 309 data_size_[i] = synchronous_entry_->data_size(i); |
310 } | 310 } |
311 | 311 |
312 } // namespace disk_cache | 312 } // namespace disk_cache |
OLD | NEW |