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 286 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
369 EXPECT_EQ(kOneHour, service->reinit_timer_.GetCurrentDelay()); | 372 EXPECT_EQ(kOneHour, service->reinit_timer_.GetCurrentDelay()); |
370 EXPECT_EQ(kOneHour, service->next_reinit_delay_); | 373 EXPECT_EQ(kOneHour, service->next_reinit_delay_); |
371 | 374 |
372 // Fine to delete while pending. | 375 // Fine to delete while pending. |
373 service.reset(NULL); | 376 service.reset(NULL); |
374 } | 377 } |
375 | 378 |
376 | 379 |
377 | 380 |
378 } // namespace content | 381 } // namespace content |
OLD | NEW |