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 <stdint.h> |
| 6 |
5 #include <string> | 7 #include <string> |
6 | 8 |
7 #include "base/bind.h" | 9 #include "base/bind.h" |
8 #include "base/bind_helpers.h" | 10 #include "base/bind_helpers.h" |
9 #include "base/location.h" | 11 #include "base/location.h" |
| 12 #include "base/macros.h" |
10 #include "base/pickle.h" | 13 #include "base/pickle.h" |
11 #include "base/run_loop.h" | 14 #include "base/run_loop.h" |
12 #include "base/single_thread_task_runner.h" | 15 #include "base/single_thread_task_runner.h" |
13 #include "base/thread_task_runner_handle.h" | 16 #include "base/thread_task_runner_handle.h" |
14 #include "content/browser/appcache/appcache_response.h" | 17 #include "content/browser/appcache/appcache_response.h" |
15 #include "content/browser/appcache/appcache_service_impl.h" | 18 #include "content/browser/appcache/appcache_service_impl.h" |
16 #include "content/browser/appcache/mock_appcache_storage.h" | 19 #include "content/browser/appcache/mock_appcache_storage.h" |
17 #include "net/base/completion_callback.h" | 20 #include "net/base/completion_callback.h" |
18 #include "net/base/io_buffer.h" | 21 #include "net/base/io_buffer.h" |
19 #include "net/http/http_response_headers.h" | 22 #include "net/http/http_response_headers.h" |
20 #include "testing/gtest/include/gtest/gtest.h" | 23 #include "testing/gtest/include/gtest/gtest.h" |
21 | 24 |
22 namespace content { | 25 namespace content { |
23 namespace { | 26 namespace { |
24 | 27 |
25 const int64 kMockGroupId = 1; | 28 const int64_t kMockGroupId = 1; |
26 const int64 kMockCacheId = 1; | 29 const int64_t kMockCacheId = 1; |
27 const int64 kMockResponseId = 1; | 30 const int64_t kMockResponseId = 1; |
28 const int64 kMissingCacheId = 5; | 31 const int64_t kMissingCacheId = 5; |
29 const int64 kMissingResponseId = 5; | 32 const int64_t kMissingResponseId = 5; |
30 const char kMockHeaders[] = | 33 const char kMockHeaders[] = |
31 "HTTP/1.0 200 OK\0Content-Length: 5\0\0"; | 34 "HTTP/1.0 200 OK\0Content-Length: 5\0\0"; |
32 const char kMockBody[] = "Hello"; | 35 const char kMockBody[] = "Hello"; |
33 const int kMockBodySize = 5; | 36 const int kMockBodySize = 5; |
34 | 37 |
35 class MockResponseReader : public AppCacheResponseReader { | 38 class MockResponseReader : public AppCacheResponseReader { |
36 public: | 39 public: |
37 MockResponseReader(int64 response_id, | 40 MockResponseReader(int64_t response_id, |
38 net::HttpResponseInfo* info, int info_size, | 41 net::HttpResponseInfo* info, |
39 const char* data, int data_size) | 42 int info_size, |
| 43 const char* data, |
| 44 int data_size) |
40 : AppCacheResponseReader(response_id, 0, NULL), | 45 : AppCacheResponseReader(response_id, 0, NULL), |
41 info_(info), info_size_(info_size), | 46 info_(info), |
42 data_(data), data_size_(data_size) { | 47 info_size_(info_size), |
43 } | 48 data_(data), |
| 49 data_size_(data_size) {} |
44 void ReadInfo(HttpResponseInfoIOBuffer* info_buf, | 50 void ReadInfo(HttpResponseInfoIOBuffer* info_buf, |
45 const net::CompletionCallback& callback) override { | 51 const net::CompletionCallback& callback) override { |
46 info_buffer_ = info_buf; | 52 info_buffer_ = info_buf; |
47 callback_ = callback; // Cleared on completion. | 53 callback_ = callback; // Cleared on completion. |
48 | 54 |
49 int rv = info_.get() ? info_size_ : net::ERR_FAILED; | 55 int rv = info_.get() ? info_size_ : net::ERR_FAILED; |
50 info_buffer_->http_info.reset(info_.release()); | 56 info_buffer_->http_info.reset(info_.release()); |
51 info_buffer_->response_data_size = data_size_; | 57 info_buffer_->response_data_size = data_size_; |
52 ScheduleUserCallback(rv); | 58 ScheduleUserCallback(rv); |
53 } | 59 } |
(...skipping 318 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
372 EXPECT_EQ(kOneHour, service->reinit_timer_.GetCurrentDelay()); | 378 EXPECT_EQ(kOneHour, service->reinit_timer_.GetCurrentDelay()); |
373 EXPECT_EQ(kOneHour, service->next_reinit_delay_); | 379 EXPECT_EQ(kOneHour, service->next_reinit_delay_); |
374 | 380 |
375 // Fine to delete while pending. | 381 // Fine to delete while pending. |
376 service.reset(NULL); | 382 service.reset(NULL); |
377 } | 383 } |
378 | 384 |
379 | 385 |
380 | 386 |
381 } // namespace content | 387 } // namespace content |
OLD | NEW |