| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 <string> | 5 #include <string> |
| 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/message_loop.h" | 9 #include "base/message_loop.h" |
| 10 #include "base/pickle.h" | 10 #include "base/pickle.h" |
| (...skipping 22 matching lines...) Expand all Loading... |
| 33 class MockResponseReader : public AppCacheResponseReader { | 33 class MockResponseReader : public AppCacheResponseReader { |
| 34 public: | 34 public: |
| 35 MockResponseReader(int64 response_id, | 35 MockResponseReader(int64 response_id, |
| 36 net::HttpResponseInfo* info, int info_size, | 36 net::HttpResponseInfo* info, int info_size, |
| 37 const char* data, int data_size) | 37 const char* data, int data_size) |
| 38 : AppCacheResponseReader(response_id, 0, NULL), | 38 : AppCacheResponseReader(response_id, 0, NULL), |
| 39 info_(info), info_size_(info_size), | 39 info_(info), info_size_(info_size), |
| 40 data_(data), data_size_(data_size) { | 40 data_(data), data_size_(data_size) { |
| 41 } | 41 } |
| 42 virtual void ReadInfo(HttpResponseInfoIOBuffer* info_buf, | 42 virtual void ReadInfo(HttpResponseInfoIOBuffer* info_buf, |
| 43 net::OldCompletionCallback* callback) OVERRIDE { | 43 const net::CompletionCallback& callback) OVERRIDE { |
| 44 info_buffer_ = info_buf; | 44 info_buffer_ = info_buf; |
| 45 user_callback_ = callback; // Cleared on completion. | 45 callback_ = callback; // Cleared on completion. |
| 46 | 46 |
| 47 int rv = info_.get() ? info_size_ : net::ERR_FAILED; | 47 int rv = info_.get() ? info_size_ : net::ERR_FAILED; |
| 48 info_buffer_->http_info.reset(info_.release()); | 48 info_buffer_->http_info.reset(info_.release()); |
| 49 info_buffer_->response_data_size = data_size_; | 49 info_buffer_->response_data_size = data_size_; |
| 50 ScheduleUserCallback(rv); | 50 ScheduleUserCallback(rv); |
| 51 } | 51 } |
| 52 virtual void ReadData(net::IOBuffer* buf, int buf_len, | 52 virtual void ReadData(net::IOBuffer* buf, int buf_len, |
| 53 net::OldCompletionCallback* callback) OVERRIDE { | 53 const net::CompletionCallback& callback) OVERRIDE { |
| 54 buffer_ = buf; | 54 buffer_ = buf; |
| 55 buffer_len_ = buf_len; | 55 buffer_len_ = buf_len; |
| 56 user_callback_ = callback; // Cleared on completion. | 56 callback_ = callback; // Cleared on completion. |
| 57 | 57 |
| 58 if (!data_) { | 58 if (!data_) { |
| 59 ScheduleUserCallback(net::ERR_CACHE_READ_FAILURE); | 59 ScheduleUserCallback(net::ERR_CACHE_READ_FAILURE); |
| 60 return; | 60 return; |
| 61 } | 61 } |
| 62 DCHECK(buf_len >= data_size_); | 62 DCHECK(buf_len >= data_size_); |
| 63 memcpy(buf->data(), data_, data_size_); | 63 memcpy(buf->data(), data_, data_size_); |
| 64 ScheduleUserCallback(data_size_); | 64 ScheduleUserCallback(data_size_); |
| 65 data_size_ = 0; | 65 data_size_ = 0; |
| 66 } | 66 } |
| (...skipping 241 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 308 MessageLoop::current()->RunAllPending(); | 308 MessageLoop::current()->RunAllPending(); |
| 309 EXPECT_EQ(0, CountPendingHelpers()); | 309 EXPECT_EQ(0, CountPendingHelpers()); |
| 310 EXPECT_FALSE(IsGroupStored(kManifestUrl)); | 310 EXPECT_FALSE(IsGroupStored(kManifestUrl)); |
| 311 ResetStorage(); | 311 ResetStorage(); |
| 312 | 312 |
| 313 service_.reset(); // Clean up. | 313 service_.reset(); // Clean up. |
| 314 MessageLoop::current()->RunAllPending(); | 314 MessageLoop::current()->RunAllPending(); |
| 315 } | 315 } |
| 316 | 316 |
| 317 } // namespace appcache | 317 } // namespace appcache |
| OLD | NEW |