Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1180)

Side by Side Diff: net/disk_cache/file_posix.cc

Issue 9702059: Disk cache: Remove all non essential synchronization from the cache destructor. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Sans style Created 8 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2011 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 "net/disk_cache/file.h" 5 #include "net/disk_cache/file.h"
6 6
7 #include <fcntl.h> 7 #include <fcntl.h>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/location.h" 10 #include "base/location.h"
11 #include "base/logging.h" 11 #include "base/logging.h"
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
90 90
91 // --------------------------------------------------------------------------- 91 // ---------------------------------------------------------------------------
92 92
93 // Runs on a worker thread. 93 // Runs on a worker thread.
94 void FileBackgroundIO::Read() { 94 void FileBackgroundIO::Read() {
95 if (file_->Read(const_cast<void*>(buf_), buf_len_, offset_)) { 95 if (file_->Read(const_cast<void*>(buf_), buf_len_, offset_)) {
96 result_ = static_cast<int>(buf_len_); 96 result_ = static_cast<int>(buf_len_);
97 } else { 97 } else {
98 result_ = net::ERR_CACHE_READ_FAILURE; 98 result_ = net::ERR_CACHE_READ_FAILURE;
99 } 99 }
100 controller_->OnIOComplete(this); 100 NotifyController();
101 } 101 }
102 102
103 // Runs on a worker thread. 103 // Runs on a worker thread.
104 void FileBackgroundIO::Write() { 104 void FileBackgroundIO::Write() {
105 bool rv = file_->Write(buf_, buf_len_, offset_); 105 bool rv = file_->Write(buf_, buf_len_, offset_);
106 106
107 result_ = rv ? static_cast<int>(buf_len_) : net::ERR_CACHE_WRITE_FAILURE; 107 result_ = rv ? static_cast<int>(buf_len_) : net::ERR_CACHE_WRITE_FAILURE;
108 controller_->OnIOComplete(this); 108 NotifyController();
109 } 109 }
110 110
111 // --------------------------------------------------------------------------- 111 // ---------------------------------------------------------------------------
112 112
113 void FileInFlightIO::PostRead(disk_cache::File *file, void* buf, size_t buf_len, 113 void FileInFlightIO::PostRead(disk_cache::File *file, void* buf, size_t buf_len,
114 size_t offset, disk_cache::FileIOCallback *callback) { 114 size_t offset, disk_cache::FileIOCallback *callback) {
115 scoped_refptr<FileBackgroundIO> operation( 115 scoped_refptr<FileBackgroundIO> operation(
116 new FileBackgroundIO(file, buf, buf_len, offset, callback, this)); 116 new FileBackgroundIO(file, buf, buf_len, offset, callback, this));
117 file->AddRef(); // Balanced on OnOperationComplete() 117 file->AddRef(); // Balanced on OnOperationComplete()
118 118
(...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after
294 return false; 294 return false;
295 295
296 GetFileInFlightIO()->PostWrite(this, buffer, buffer_len, offset, callback); 296 GetFileInFlightIO()->PostWrite(this, buffer, buffer_len, offset, callback);
297 297
298 if (completed) 298 if (completed)
299 *completed = false; 299 *completed = false;
300 return true; 300 return true;
301 } 301 }
302 302
303 } // namespace disk_cache 303 } // namespace disk_cache
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698