Chromium Code Reviews| 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_synchronous_entry.h" | 5 #include "net/disk_cache/simple/simple_synchronous_entry.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <cstring> | 8 #include <cstring> |
| 9 #include <limits> | 9 #include <limits> |
| 10 | 10 |
| (...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 78 delete sync_entry; | 78 delete sync_entry; |
| 79 sync_entry = NULL; | 79 sync_entry = NULL; |
| 80 } | 80 } |
| 81 callback_runner->PostTask(FROM_HERE, base::Bind(callback, sync_entry)); | 81 callback_runner->PostTask(FROM_HERE, base::Bind(callback, sync_entry)); |
| 82 } | 82 } |
| 83 | 83 |
| 84 // static | 84 // static |
| 85 void SimpleSynchronousEntry::DoomEntry( | 85 void SimpleSynchronousEntry::DoomEntry( |
| 86 const FilePath& path, | 86 const FilePath& path, |
| 87 const std::string& key, | 87 const std::string& key, |
| 88 scoped_refptr<TaskRunner> callback_runner, | 88 const scoped_refptr<TaskRunner>& callback_runner, |
| 89 const net::CompletionCallback& callback) { | 89 const net::CompletionCallback& callback) { |
| 90 for (int i = 0; i < kSimpleEntryFileCount; ++i) { | 90 for (int i = 0; i < kSimpleEntryFileCount; ++i) { |
| 91 FilePath to_delete = path.AppendASCII(GetFilenameFromKeyAndIndex(key, i)); | 91 FilePath to_delete = path.AppendASCII(GetFilenameFromKeyAndIndex(key, i)); |
| 92 bool ALLOW_UNUSED result = file_util::Delete(to_delete, false); | 92 bool ALLOW_UNUSED result = file_util::Delete(to_delete, false); |
| 93 DLOG_IF(ERROR, !result) << "Could not delete " << to_delete.MaybeAsASCII(); | 93 DLOG_IF(ERROR, !result) << "Could not delete " << to_delete.MaybeAsASCII(); |
| 94 } | 94 } |
| 95 if (!callback.is_null()) | 95 if (!callback.is_null()) |
| 96 callback_runner->PostTask(FROM_HERE, base::Bind(callback, net::OK)); | 96 callback_runner->PostTask(FROM_HERE, base::Bind(callback, net::OK)); |
| 97 } | 97 } |
| 98 | 98 |
| (...skipping 14 matching lines...) Expand all Loading... | |
| 113 DCHECK(initialized_); | 113 DCHECK(initialized_); |
| 114 | 114 |
| 115 int64 file_offset = GetFileOffsetFromKeyAndDataOffset(key_, offset); | 115 int64 file_offset = GetFileOffsetFromKeyAndDataOffset(key_, offset); |
| 116 int bytes_read = ReadPlatformFile(files_[index], file_offset, | 116 int bytes_read = ReadPlatformFile(files_[index], file_offset, |
| 117 buf->data(), buf_len); | 117 buf->data(), buf_len); |
| 118 if (bytes_read > 0) | 118 if (bytes_read > 0) |
| 119 last_used_ = Time::Now(); | 119 last_used_ = Time::Now(); |
| 120 int result = (bytes_read >= 0) ? bytes_read : net::ERR_FAILED; | 120 int result = (bytes_read >= 0) ? bytes_read : net::ERR_FAILED; |
| 121 if (result == net::ERR_FAILED) | 121 if (result == net::ERR_FAILED) |
| 122 Doom(); | 122 Doom(); |
| 123 callback_runner_->PostTask(FROM_HERE, base::Bind(callback, result)); | 123 callback_runner_->PostTask(FROM_HERE, base::Bind(callback, result)); |
|
gavinp
2013/04/20 07:28:33
***ONE*** A context switch occurs precisely after
| |
| 124 } | 124 } |
|
gavinp
2013/04/20 07:28:33
***FIVE*** Control flow continues at this point. T
| |
| 125 | 125 |
| 126 void SimpleSynchronousEntry::WriteData( | 126 void SimpleSynchronousEntry::WriteData( |
| 127 int index, | 127 int index, |
| 128 int offset, | 128 int offset, |
| 129 net::IOBuffer* buf, | 129 net::IOBuffer* buf, |
| 130 int buf_len, | 130 int buf_len, |
| 131 const SynchronousOperationCallback& callback, | 131 const SynchronousOperationCallback& callback, |
| 132 bool truncate) { | 132 bool truncate) { |
| 133 DCHECK(initialized_); | 133 DCHECK(initialized_); |
| 134 | 134 |
| (...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 299 return net::OK; | 299 return net::OK; |
| 300 } | 300 } |
| 301 | 301 |
| 302 void SimpleSynchronousEntry::Doom() { | 302 void SimpleSynchronousEntry::Doom() { |
| 303 // TODO(gavinp): Consider if we should guard against redundant Doom() calls. | 303 // TODO(gavinp): Consider if we should guard against redundant Doom() calls. |
| 304 DoomEntry(path_, key_, | 304 DoomEntry(path_, key_, |
| 305 scoped_refptr<base::TaskRunner>(), net::CompletionCallback()); | 305 scoped_refptr<base::TaskRunner>(), net::CompletionCallback()); |
| 306 } | 306 } |
| 307 | 307 |
| 308 } // namespace disk_cache | 308 } // namespace disk_cache |
| OLD | NEW |