| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/location.h" |
| 9 #include "base/pickle.h" | 10 #include "base/pickle.h" |
| 10 #include "base/run_loop.h" | 11 #include "base/run_loop.h" |
| 12 #include "base/single_thread_task_runner.h" |
| 13 #include "base/thread_task_runner_handle.h" |
| 11 #include "content/browser/appcache/appcache_response.h" | 14 #include "content/browser/appcache/appcache_response.h" |
| 12 #include "content/browser/appcache/appcache_service_impl.h" | 15 #include "content/browser/appcache/appcache_service_impl.h" |
| 13 #include "content/browser/appcache/mock_appcache_storage.h" | 16 #include "content/browser/appcache/mock_appcache_storage.h" |
| 14 #include "net/base/completion_callback.h" | 17 #include "net/base/completion_callback.h" |
| 15 #include "net/base/io_buffer.h" | 18 #include "net/base/io_buffer.h" |
| 16 #include "net/http/http_response_headers.h" | 19 #include "net/http/http_response_headers.h" |
| 17 #include "testing/gtest/include/gtest/gtest.h" | 20 #include "testing/gtest/include/gtest/gtest.h" |
| 18 | 21 |
| 19 namespace content { | 22 namespace content { |
| 20 namespace { | 23 namespace { |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 60 return; | 63 return; |
| 61 } | 64 } |
| 62 DCHECK(buf_len >= data_size_); | 65 DCHECK(buf_len >= data_size_); |
| 63 memcpy(buf->data(), data_, data_size_); | 66 memcpy(buf->data(), data_, data_size_); |
| 64 ScheduleUserCallback(data_size_); | 67 ScheduleUserCallback(data_size_); |
| 65 data_size_ = 0; | 68 data_size_ = 0; |
| 66 } | 69 } |
| 67 | 70 |
| 68 private: | 71 private: |
| 69 void ScheduleUserCallback(int result) { | 72 void ScheduleUserCallback(int result) { |
| 70 base::MessageLoop::current()->PostTask(FROM_HERE, | 73 base::ThreadTaskRunnerHandle::Get()->PostTask( |
| 71 base::Bind(&MockResponseReader::InvokeUserCompletionCallback, | 74 FROM_HERE, base::Bind(&MockResponseReader::InvokeUserCompletionCallback, |
| 72 weak_factory_.GetWeakPtr(), result)); | 75 weak_factory_.GetWeakPtr(), result)); |
| 73 } | 76 } |
| 74 | 77 |
| 75 scoped_ptr<net::HttpResponseInfo> info_; | 78 scoped_ptr<net::HttpResponseInfo> info_; |
| 76 int info_size_; | 79 int info_size_; |
| 77 const char* data_; | 80 const char* data_; |
| 78 int data_size_; | 81 int data_size_; |
| 79 }; | 82 }; |
| 80 | 83 |
| 81 } // namespace | 84 } // namespace |
| 82 | 85 |
| (...skipping 285 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 368 EXPECT_EQ(kOneHour, service->reinit_timer_.GetCurrentDelay()); | 371 EXPECT_EQ(kOneHour, service->reinit_timer_.GetCurrentDelay()); |
| 369 EXPECT_EQ(kOneHour, service->next_reinit_delay_); | 372 EXPECT_EQ(kOneHour, service->next_reinit_delay_); |
| 370 | 373 |
| 371 // Fine to delete while pending. | 374 // Fine to delete while pending. |
| 372 service.reset(NULL); | 375 service.reset(NULL); |
| 373 } | 376 } |
| 374 | 377 |
| 375 | 378 |
| 376 | 379 |
| 377 } // namespace content | 380 } // namespace content |
| OLD | NEW |