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

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

Issue 1756019: Fix some uses of scoped_ptr.release() in net/ such that the return value is not ignored. (Closed) Base URL: http://src.chromium.org/git/chromium.git
Patch Set: add back the change that got lost in the void Created 10 years, 7 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
« no previous file with comments | « no previous file | net/disk_cache/file_posix.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2006-2009 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2006-2009 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/entry_impl.h" 5 #include "net/disk_cache/entry_impl.h"
6 6
7 #include "base/histogram.h" 7 #include "base/histogram.h"
8 #include "base/message_loop.h" 8 #include "base/message_loop.h"
9 #include "base/string_util.h" 9 #include "base/string_util.h"
10 #include "net/base/io_buffer.h" 10 #include "net/base/io_buffer.h"
(...skipping 843 matching lines...) Expand 10 before | Expand all | Expand 10 after
854 // TODO(rvargas): figure out if it's worth to re-enable posting operations. 854 // TODO(rvargas): figure out if it's worth to re-enable posting operations.
855 // Right now it is only used from GrowUserBuffer, not the destructor, and 855 // Right now it is only used from GrowUserBuffer, not the destructor, and
856 // it is not accounted for from the point of view of the total number of 856 // it is not accounted for from the point of view of the total number of
857 // pending operations of the cache. It is also racing with the actual write 857 // pending operations of the cache. It is also racing with the actual write
858 // on the GrowUserBuffer path because there is no code to exclude the range 858 // on the GrowUserBuffer path because there is no code to exclude the range
859 // that is going to be written. 859 // that is going to be written.
860 async = false; 860 async = false;
861 if (async) { 861 if (async) {
862 if (!file->PostWrite(user_buffers_[index].get(), len, offset)) 862 if (!file->PostWrite(user_buffers_[index].get(), len, offset))
863 return false; 863 return false;
864 // The buffer is deleted from the PostWrite operation.
865 ignore_result(user_buffers_[index].release());
864 } else { 866 } else {
865 if (!file->Write(user_buffers_[index].get(), len, offset, NULL, NULL)) 867 if (!file->Write(user_buffers_[index].get(), len, offset, NULL, NULL))
866 return false; 868 return false;
867 user_buffers_[index].reset(NULL); 869 user_buffers_[index].reset(NULL);
868 } 870 }
869 871
870 // The buffer is deleted from the PostWrite operation.
871 user_buffers_[index].release();
872
873 return true; 872 return true;
874 } 873 }
875 874
876 int EntryImpl::InitSparseData() { 875 int EntryImpl::InitSparseData() {
877 if (sparse_.get()) 876 if (sparse_.get())
878 return net::OK; 877 return net::OK;
879 878
880 sparse_.reset(new SparseControl(this)); 879 sparse_.reset(new SparseControl(this));
881 int result = sparse_->Init(); 880 int result = sparse_->Init();
882 if (net::OK != result) 881 if (net::OK != result)
883 sparse_.reset(); 882 sparse_.reset();
884 return result; 883 return result;
885 } 884 }
886 885
887 void EntryImpl::SetEntryFlags(uint32 flags) { 886 void EntryImpl::SetEntryFlags(uint32 flags) {
888 entry_.Data()->flags |= flags; 887 entry_.Data()->flags |= flags;
889 entry_.set_modified(); 888 entry_.set_modified();
890 } 889 }
891 890
892 uint32 EntryImpl::GetEntryFlags() { 891 uint32 EntryImpl::GetEntryFlags() {
893 return entry_.Data()->flags; 892 return entry_.Data()->flags;
894 } 893 }
895 894
896 void EntryImpl::GetData(int index, char** buffer, Addr* address) { 895 void EntryImpl::GetData(int index, char** buffer, Addr* address) {
897 if (user_buffers_[index].get()) { 896 if (user_buffers_[index].get()) {
898 // The data is already in memory, just copy it an we're done. 897 // The data is already in memory, just copy it and we're done.
899 int data_len = entry_.Data()->data_size[index]; 898 int data_len = entry_.Data()->data_size[index];
900 DCHECK(data_len <= kMaxBlockSize); 899 DCHECK(data_len <= kMaxBlockSize);
901 *buffer = new char[data_len]; 900 *buffer = new char[data_len];
902 memcpy(*buffer, user_buffers_[index].get(), data_len); 901 memcpy(*buffer, user_buffers_[index].get(), data_len);
903 return; 902 return;
904 } 903 }
905 904
906 // Bad news: we'd have to read the info from disk so instead we'll just tell 905 // Bad news: we'd have to read the info from disk so instead we'll just tell
907 // the caller where to read from. 906 // the caller where to read from.
908 *buffer = NULL; 907 *buffer = NULL;
(...skipping 16 matching lines...) Expand all
925 Trace("%s 0x%p 0x%x 0x%x", msg, reinterpret_cast<void*>(this), 924 Trace("%s 0x%p 0x%x 0x%x", msg, reinterpret_cast<void*>(this),
926 entry_.address().value(), node_.address().value()); 925 entry_.address().value(), node_.address().value());
927 926
928 Trace(" data: 0x%x 0x%x 0x%x", entry_.Data()->data_addr[0], 927 Trace(" data: 0x%x 0x%x 0x%x", entry_.Data()->data_addr[0],
929 entry_.Data()->data_addr[1], entry_.Data()->long_key); 928 entry_.Data()->data_addr[1], entry_.Data()->long_key);
930 929
931 Trace(" doomed: %d 0x%x", doomed_, dirty); 930 Trace(" doomed: %d 0x%x", doomed_, dirty);
932 } 931 }
933 932
934 } // namespace disk_cache 933 } // namespace disk_cache
OLDNEW
« no previous file with comments | « no previous file | net/disk_cache/file_posix.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698