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 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
56 true); | 56 true); |
57 return net::ERR_IO_PENDING; | 57 return net::ERR_IO_PENDING; |
58 } | 58 } |
59 | 59 |
60 // static | 60 // static |
61 int SimpleEntryImpl::CreateEntry(SimpleIndex* index, | 61 int SimpleEntryImpl::CreateEntry(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 // See comment on OpenEntry regarding inserting the entry in the index. | |
gavinp
2013/04/19 15:58:55
This is from another CL, it should be removed here
felipeg
2013/04/19 17:10:15
Done.
| |
67 if (index) | |
68 index->Insert(key); | |
66 scoped_refptr<SimpleEntryImpl> new_entry = | 69 scoped_refptr<SimpleEntryImpl> new_entry = |
67 new SimpleEntryImpl(index, path, key); | 70 new SimpleEntryImpl(index, path, key); |
68 SynchronousCreationCallback sync_creation_callback = | 71 SynchronousCreationCallback sync_creation_callback = |
69 base::Bind(&SimpleEntryImpl::CreationOperationComplete, | 72 base::Bind(&SimpleEntryImpl::CreationOperationComplete, |
70 new_entry, entry, callback); | 73 new_entry, entry, callback); |
71 WorkerPool::PostTask(FROM_HERE, | 74 WorkerPool::PostTask(FROM_HERE, |
72 base::Bind(&SimpleSynchronousEntry::CreateEntry, path, | 75 base::Bind(&SimpleSynchronousEntry::CreateEntry, path, |
73 key, MessageLoopProxy::current(), | 76 key, MessageLoopProxy::current(), |
74 sync_creation_callback), | 77 sync_creation_callback), |
75 true); | 78 true); |
(...skipping 251 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
327 // The reference held by the Callback calling us will go out of scope and | 330 // The reference held by the Callback calling us will go out of scope and |
328 // delete |this| on leaving this scope. | 331 // delete |this| on leaving this scope. |
329 return; | 332 return; |
330 } | 333 } |
331 // The Backend interface requires us to return |this|, and keep the Entry | 334 // The Backend interface requires us to return |this|, and keep the Entry |
332 // alive until Entry::Close(). Adding a reference to self will keep |this| | 335 // alive until Entry::Close(). Adding a reference to self will keep |this| |
333 // alive after the scope of the Callback calling us is destroyed. | 336 // alive after the scope of the Callback calling us is destroyed. |
334 AddRef(); // Balanced in CloseInternal(). | 337 AddRef(); // Balanced in CloseInternal(). |
335 synchronous_entry_ = sync_entry; | 338 synchronous_entry_ = sync_entry; |
336 SetSynchronousData(); | 339 SetSynchronousData(); |
337 if (index_) | |
gavinp
2013/04/19 15:58:55
Same here?
felipeg
2013/04/19 17:10:15
Done.
| |
338 index_->Insert(key_); | |
339 *out_entry = this; | 340 *out_entry = this; |
340 completion_callback.Run(net::OK); | 341 completion_callback.Run(net::OK); |
341 } | 342 } |
342 | 343 |
343 void SimpleEntryImpl::EntryOperationComplete( | 344 void SimpleEntryImpl::EntryOperationComplete( |
344 const CompletionCallback& completion_callback, | 345 const CompletionCallback& completion_callback, |
345 int result) { | 346 int result) { |
346 DCHECK(io_thread_checker_.CalledOnValidThread()); | 347 DCHECK(io_thread_checker_.CalledOnValidThread()); |
347 DCHECK(synchronous_entry_); | 348 DCHECK(synchronous_entry_); |
348 DCHECK(operation_running_); | 349 DCHECK(operation_running_); |
(...skipping 19 matching lines...) Expand all Loading... | |
368 // adding an IO thread index (for fast misses etc...), we can store this data | 369 // adding an IO thread index (for fast misses etc...), we can store this data |
369 // in that structure. This also solves problems with last_used() on ext4 | 370 // in that structure. This also solves problems with last_used() on ext4 |
370 // filesystems not being accurate. | 371 // filesystems not being accurate. |
371 last_used_ = synchronous_entry_->last_used(); | 372 last_used_ = synchronous_entry_->last_used(); |
372 last_modified_ = synchronous_entry_->last_modified(); | 373 last_modified_ = synchronous_entry_->last_modified(); |
373 for (int i = 0; i < kSimpleEntryFileCount; ++i) | 374 for (int i = 0; i < kSimpleEntryFileCount; ++i) |
374 data_size_[i] = synchronous_entry_->data_size(i); | 375 data_size_[i] = synchronous_entry_->data_size(i); |
375 } | 376 } |
376 | 377 |
377 } // namespace disk_cache | 378 } // namespace disk_cache |
OLD | NEW |