diff options
Diffstat (limited to 'net')
-rw-r--r-- | net/disk_cache/entry_impl.cc | 7 | ||||
-rw-r--r-- | net/disk_cache/file_posix.cc | 4 | ||||
-rw-r--r-- | net/socket/client_socket_pool_base.cc | 15 | ||||
-rw-r--r-- | net/socket/client_socket_pool_base.h | 12 | ||||
-rw-r--r-- | net/socket/socks_client_socket_pool_unittest.cc | 7 |
5 files changed, 19 insertions, 26 deletions
diff --git a/net/disk_cache/entry_impl.cc b/net/disk_cache/entry_impl.cc index 67fa32b..a1e0b32 100644 --- a/net/disk_cache/entry_impl.cc +++ b/net/disk_cache/entry_impl.cc @@ -861,15 +861,14 @@ bool EntryImpl::Flush(int index, int size, bool async) { if (async) { if (!file->PostWrite(user_buffers_[index].get(), len, offset)) return false; + // The buffer is deleted from the PostWrite operation. + ignore_result(user_buffers_[index].release()); } else { if (!file->Write(user_buffers_[index].get(), len, offset, NULL, NULL)) return false; user_buffers_[index].reset(NULL); } - // The buffer is deleted from the PostWrite operation. - user_buffers_[index].release(); - return true; } @@ -895,7 +894,7 @@ uint32 EntryImpl::GetEntryFlags() { void EntryImpl::GetData(int index, char** buffer, Addr* address) { if (user_buffers_[index].get()) { - // The data is already in memory, just copy it an we're done. + // The data is already in memory, just copy it and we're done. int data_len = entry_.Data()->data_size[index]; DCHECK(data_len <= kMaxBlockSize); *buffer = new char[data_len]; diff --git a/net/disk_cache/file_posix.cc b/net/disk_cache/file_posix.cc index bfaad59..cf621f4 100644 --- a/net/disk_cache/file_posix.cc +++ b/net/disk_cache/file_posix.cc @@ -122,8 +122,8 @@ class InFlightIO { void PostRead(disk_cache::File* file, void* buf, size_t buf_len, size_t offset, disk_cache::FileIOCallback* callback); void PostWrite(disk_cache::File* file, const void* buf, size_t buf_len, - size_t offset, disk_cache::FileIOCallback* callback, - bool delete_buffer); + size_t offset, disk_cache::FileIOCallback* callback, + bool delete_buffer); // Blocks the current thread until all IO operations tracked by this object // complete. diff --git a/net/socket/client_socket_pool_base.cc b/net/socket/client_socket_pool_base.cc index 739bb82..9fe07d3 100644 --- a/net/socket/client_socket_pool_base.cc +++ b/net/socket/client_socket_pool_base.cc @@ -175,10 +175,12 @@ int ClientSocketPoolBaseHelper::RequestSocket( request->net_log().BeginEvent(NetLog::TYPE_SOCKET_POOL, NULL); Group& group = group_map_[group_name]; int rv = RequestSocketInternal(group_name, request); - if (rv != ERR_IO_PENDING) + if (rv != ERR_IO_PENDING) { request->net_log().EndEvent(NetLog::TYPE_SOCKET_POOL, NULL); - else + delete request; + } else { InsertRequestIntoQueue(request, &group.pending_requests); + } return rv; } @@ -654,21 +656,18 @@ void ClientSocketPoolBaseHelper::OnAvailableSocketSlot( void ClientSocketPoolBaseHelper::ProcessPendingRequest( const std::string& group_name, Group* group) { - scoped_ptr<const Request> r(*group->pending_requests.begin()); - int rv = RequestSocketInternal(group_name, r.get()); + int rv = RequestSocketInternal(group_name, *group->pending_requests.begin()); if (rv != ERR_IO_PENDING) { + scoped_ptr<const Request> r(RemoveRequestFromQueue( + group->pending_requests.begin(), &group->pending_requests)); r->net_log().EndEvent(NetLog::TYPE_SOCKET_POOL, NULL); - RemoveRequestFromQueue(group->pending_requests.begin(), - &group->pending_requests); r->callback()->Run(rv); if (rv != OK) { // |group| may be invalid after the callback, we need to search // |group_map_| again. MaybeOnAvailableSocketSlot(group_name); } - } else { - r.release(); } } diff --git a/net/socket/client_socket_pool_base.h b/net/socket/client_socket_pool_base.h index ce25463..91289d8 100644 --- a/net/socket/client_socket_pool_base.h +++ b/net/socket/client_socket_pool_base.h @@ -176,8 +176,8 @@ class ClientSocketPoolBaseHelper NetworkChangeNotifier* network_change_notifier); // See ClientSocketPool::RequestSocket for documentation on this function. - // Note that |request| must be heap allocated. If ERR_IO_PENDING is returned, - // then ClientSocketPoolBaseHelper takes ownership of |request|. + // ClientSocketPoolBaseHelper takes ownership of |request|, which must be + // heap allocated. int RequestSocket(const std::string& group_name, const Request* request); // See ClientSocketPool::CancelRequest for documentation on this function. @@ -526,12 +526,8 @@ class ClientSocketPoolBase { ClientSocketHandle* handle, CompletionCallback* callback, const BoundNetLog& net_log) { - scoped_ptr<Request> request( - new Request(handle, callback, priority, params, net_log)); - int rv = helper_->RequestSocket(group_name, request.get()); - if (rv == ERR_IO_PENDING) - request.release(); - return rv; + Request* request = new Request(handle, callback, priority, params, net_log); + return helper_->RequestSocket(group_name, request); } void CancelRequest(const std::string& group_name, diff --git a/net/socket/socks_client_socket_pool_unittest.cc b/net/socket/socks_client_socket_pool_unittest.cc index 89530f6..6072ad3 100644 --- a/net/socket/socks_client_socket_pool_unittest.cc +++ b/net/socket/socks_client_socket_pool_unittest.cc @@ -49,7 +49,7 @@ class MockTCPClientSocketPool : public TCPClientSocketPool { bool CancelHandle(const ClientSocketHandle* handle) { if (handle != handle_) return false; - socket_.reset(NULL); + socket_.reset(); handle_ = NULL; user_callback_ = NULL; return true; @@ -60,11 +60,10 @@ class MockTCPClientSocketPool : public TCPClientSocketPool { if (!socket_.get()) return; if (rv == OK) - handle_->set_socket(socket_.get()); + handle_->set_socket(socket_.release()); else - socket_.reset(NULL); + socket_.reset(); - socket_.release(); handle_ = NULL; if (user_callback_) { |