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

Side by Side Diff: content/browser/appcache/appcache_response.cc

Issue 1154283003: Change most uses of Pickle to base::Pickle (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 6 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
OLDNEW
1 // Copyright (c) 2012 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 "content/browser/appcache/appcache_response.h" 5 #include "content/browser/appcache/appcache_response.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/compiler_specific.h" 9 #include "base/compiler_specific.h"
10 #include "base/logging.h" 10 #include "base/logging.h"
(...skipping 11 matching lines...) Expand all
22 22
23 namespace { 23 namespace {
24 24
25 // Disk cache entry data indices. 25 // Disk cache entry data indices.
26 enum { kResponseInfoIndex, kResponseContentIndex, kResponseMetadataIndex }; 26 enum { kResponseInfoIndex, kResponseContentIndex, kResponseMetadataIndex };
27 27
28 // An IOBuffer that wraps a pickle's data. Ownership of the 28 // An IOBuffer that wraps a pickle's data. Ownership of the
29 // pickle is transfered to the WrappedPickleIOBuffer object. 29 // pickle is transfered to the WrappedPickleIOBuffer object.
30 class WrappedPickleIOBuffer : public net::WrappedIOBuffer { 30 class WrappedPickleIOBuffer : public net::WrappedIOBuffer {
31 public: 31 public:
32 explicit WrappedPickleIOBuffer(const Pickle* pickle) : 32 explicit WrappedPickleIOBuffer(const base::Pickle* pickle)
33 net::WrappedIOBuffer(reinterpret_cast<const char*>(pickle->data())), 33 : net::WrappedIOBuffer(reinterpret_cast<const char*>(pickle->data())),
34 pickle_(pickle) { 34 pickle_(pickle) {
35 DCHECK(pickle->data()); 35 DCHECK(pickle->data());
36 } 36 }
37 37
38 private: 38 private:
39 ~WrappedPickleIOBuffer() override {} 39 ~WrappedPickleIOBuffer() override {}
40 40
41 scoped_ptr<const Pickle> pickle_; 41 scoped_ptr<const base::Pickle> pickle_;
42 }; 42 };
43 43
44 } // anon namespace 44 } // anon namespace
45 45
46 46
47 // AppCacheResponseInfo ---------------------------------------------- 47 // AppCacheResponseInfo ----------------------------------------------
48 48
49 AppCacheResponseInfo::AppCacheResponseInfo( 49 AppCacheResponseInfo::AppCacheResponseInfo(
50 AppCacheStorage* storage, const GURL& manifest_url, 50 AppCacheStorage* storage, const GURL& manifest_url,
51 int64 response_id, net::HttpResponseInfo* http_info, 51 int64 response_id, net::HttpResponseInfo* http_info,
(...skipping 195 matching lines...) Expand 10 before | Expand all | Expand 10 after
247 } 247 }
248 248
249 void AppCacheResponseReader::OnIOComplete(int result) { 249 void AppCacheResponseReader::OnIOComplete(int result) {
250 if (result >= 0) { 250 if (result >= 0) {
251 if (reading_metadata_size_) { 251 if (reading_metadata_size_) {
252 DCHECK(reading_metadata_size_ == result); 252 DCHECK(reading_metadata_size_ == result);
253 DCHECK(info_buffer_->http_info->metadata); 253 DCHECK(info_buffer_->http_info->metadata);
254 reading_metadata_size_ = 0; 254 reading_metadata_size_ = 0;
255 } else if (info_buffer_.get()) { 255 } else if (info_buffer_.get()) {
256 // Deserialize the http info structure, ensuring we got headers. 256 // Deserialize the http info structure, ensuring we got headers.
257 Pickle pickle(buffer_->data(), result); 257 base::Pickle pickle(buffer_->data(), result);
258 scoped_ptr<net::HttpResponseInfo> info(new net::HttpResponseInfo); 258 scoped_ptr<net::HttpResponseInfo> info(new net::HttpResponseInfo);
259 bool response_truncated = false; 259 bool response_truncated = false;
260 if (!info->InitFromPickle(pickle, &response_truncated) || 260 if (!info->InitFromPickle(pickle, &response_truncated) ||
261 !info->headers.get()) { 261 !info->headers.get()) {
262 InvokeUserCompletionCallback(net::ERR_FAILED); 262 InvokeUserCompletionCallback(net::ERR_FAILED);
263 return; 263 return;
264 } 264 }
265 DCHECK(!response_truncated); 265 DCHECK(!response_truncated);
266 info_buffer_->http_info.reset(info.release()); 266 info_buffer_->http_info.reset(info.release());
267 267
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
329 } 329 }
330 330
331 void AppCacheResponseWriter::ContinueWriteInfo() { 331 void AppCacheResponseWriter::ContinueWriteInfo() {
332 if (!entry_) { 332 if (!entry_) {
333 ScheduleIOCompletionCallback(net::ERR_FAILED); 333 ScheduleIOCompletionCallback(net::ERR_FAILED);
334 return; 334 return;
335 } 335 }
336 336
337 const bool kSkipTransientHeaders = true; 337 const bool kSkipTransientHeaders = true;
338 const bool kTruncated = false; 338 const bool kTruncated = false;
339 Pickle* pickle = new Pickle; 339 base::Pickle* pickle = new base::Pickle;
340 info_buffer_->http_info->Persist(pickle, kSkipTransientHeaders, kTruncated); 340 info_buffer_->http_info->Persist(pickle, kSkipTransientHeaders, kTruncated);
341 write_amount_ = static_cast<int>(pickle->size()); 341 write_amount_ = static_cast<int>(pickle->size());
342 buffer_ = new WrappedPickleIOBuffer(pickle); // takes ownership of pickle 342 buffer_ = new WrappedPickleIOBuffer(pickle); // takes ownership of pickle
343 WriteRaw(kResponseInfoIndex, 0, buffer_.get(), write_amount_); 343 WriteRaw(kResponseInfoIndex, 0, buffer_.get(), write_amount_);
344 } 344 }
345 345
346 void AppCacheResponseWriter::WriteData( 346 void AppCacheResponseWriter::WriteData(
347 net::IOBuffer* buf, int buf_len, const net::CompletionCallback& callback) { 347 net::IOBuffer* buf, int buf_len, const net::CompletionCallback& callback) {
348 DCHECK(!callback.is_null()); 348 DCHECK(!callback.is_null());
349 DCHECK(!IsWritePending()); 349 DCHECK(!IsWritePending());
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after
475 } 475 }
476 WriteRaw(kResponseMetadataIndex, 0, buffer_.get(), write_amount_); 476 WriteRaw(kResponseMetadataIndex, 0, buffer_.get(), write_amount_);
477 } 477 }
478 478
479 void AppCacheResponseMetadataWriter::OnIOComplete(int result) { 479 void AppCacheResponseMetadataWriter::OnIOComplete(int result) {
480 DCHECK(result < 0 || write_amount_ == result); 480 DCHECK(result < 0 || write_amount_ == result);
481 InvokeUserCompletionCallback(result); 481 InvokeUserCompletionCallback(result);
482 } 482 }
483 483
484 } // namespace content 484 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698