| 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 <stack> | 7 #include <stack> |
| 6 #include <string> | 8 #include <string> |
| 7 #include <utility> | 9 #include <utility> |
| 8 | 10 |
| 9 #include "base/bind.h" | 11 #include "base/bind.h" |
| 10 #include "base/bind_helpers.h" | 12 #include "base/bind_helpers.h" |
| 11 #include "base/callback.h" | 13 #include "base/callback.h" |
| 12 #include "base/compiler_specific.h" | 14 #include "base/compiler_specific.h" |
| 13 #include "base/location.h" | 15 #include "base/location.h" |
| 16 #include "base/macros.h" |
| 14 #include "base/pickle.h" | 17 #include "base/pickle.h" |
| 15 #include "base/single_thread_task_runner.h" | 18 #include "base/single_thread_task_runner.h" |
| 16 #include "base/synchronization/waitable_event.h" | 19 #include "base/synchronization/waitable_event.h" |
| 17 #include "base/thread_task_runner_handle.h" | 20 #include "base/thread_task_runner_handle.h" |
| 18 #include "base/threading/thread.h" | 21 #include "base/threading/thread.h" |
| 19 #include "content/browser/appcache/appcache_response.h" | 22 #include "content/browser/appcache/appcache_response.h" |
| 20 #include "content/browser/appcache/mock_appcache_service.h" | 23 #include "content/browser/appcache/mock_appcache_service.h" |
| 21 #include "net/base/io_buffer.h" | 24 #include "net/base/io_buffer.h" |
| 22 #include "net/base/net_errors.h" | 25 #include "net/base/net_errors.h" |
| 23 #include "net/http/http_response_headers.h" | 26 #include "net/http/http_response_headers.h" |
| (...skipping 13 matching lines...) Expand all Loading... |
| 37 // Test Harness ------------------------------------------------------------- | 40 // Test Harness ------------------------------------------------------------- |
| 38 | 41 |
| 39 // Helper class used to verify test results | 42 // Helper class used to verify test results |
| 40 class MockStorageDelegate : public AppCacheStorage::Delegate { | 43 class MockStorageDelegate : public AppCacheStorage::Delegate { |
| 41 public: | 44 public: |
| 42 explicit MockStorageDelegate(AppCacheResponseTest* test) | 45 explicit MockStorageDelegate(AppCacheResponseTest* test) |
| 43 : loaded_info_id_(0), test_(test) { | 46 : loaded_info_id_(0), test_(test) { |
| 44 } | 47 } |
| 45 | 48 |
| 46 void OnResponseInfoLoaded(AppCacheResponseInfo* info, | 49 void OnResponseInfoLoaded(AppCacheResponseInfo* info, |
| 47 int64 response_id) override { | 50 int64_t response_id) override { |
| 48 loaded_info_ = info; | 51 loaded_info_ = info; |
| 49 loaded_info_id_ = response_id; | 52 loaded_info_id_ = response_id; |
| 50 test_->ScheduleNextTask(); | 53 test_->ScheduleNextTask(); |
| 51 } | 54 } |
| 52 | 55 |
| 53 scoped_refptr<AppCacheResponseInfo> loaded_info_; | 56 scoped_refptr<AppCacheResponseInfo> loaded_info_; |
| 54 int64 loaded_info_id_; | 57 int64_t loaded_info_id_; |
| 55 AppCacheResponseTest* test_; | 58 AppCacheResponseTest* test_; |
| 56 }; | 59 }; |
| 57 | 60 |
| 58 // Helper callback to run a test on our io_thread. The io_thread is spun up | 61 // Helper callback to run a test on our io_thread. The io_thread is spun up |
| 59 // once and reused for all tests. | 62 // once and reused for all tests. |
| 60 template <class Method> | 63 template <class Method> |
| 61 void MethodWrapper(Method method) { | 64 void MethodWrapper(Method method) { |
| 62 SetUpTest(); | 65 SetUpTest(); |
| 63 (this->*method)(); | 66 (this->*method)(); |
| 64 } | 67 } |
| (...skipping 694 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 759 std::stack<std::pair<base::Closure, bool> > task_stack_; | 762 std::stack<std::pair<base::Closure, bool> > task_stack_; |
| 760 | 763 |
| 761 scoped_ptr<AppCacheResponseReader> reader_; | 764 scoped_ptr<AppCacheResponseReader> reader_; |
| 762 scoped_refptr<HttpResponseInfoIOBuffer> read_info_buffer_; | 765 scoped_refptr<HttpResponseInfoIOBuffer> read_info_buffer_; |
| 763 scoped_refptr<IOBuffer> read_buffer_; | 766 scoped_refptr<IOBuffer> read_buffer_; |
| 764 int expected_read_result_; | 767 int expected_read_result_; |
| 765 bool should_delete_reader_in_completion_callback_; | 768 bool should_delete_reader_in_completion_callback_; |
| 766 int reader_deletion_count_down_; | 769 int reader_deletion_count_down_; |
| 767 bool read_callback_was_called_; | 770 bool read_callback_was_called_; |
| 768 | 771 |
| 769 int64 written_response_id_; | 772 int64_t written_response_id_; |
| 770 scoped_ptr<AppCacheResponseWriter> writer_; | 773 scoped_ptr<AppCacheResponseWriter> writer_; |
| 771 scoped_ptr<AppCacheResponseMetadataWriter> metadata_writer_; | 774 scoped_ptr<AppCacheResponseMetadataWriter> metadata_writer_; |
| 772 scoped_refptr<HttpResponseInfoIOBuffer> write_info_buffer_; | 775 scoped_refptr<HttpResponseInfoIOBuffer> write_info_buffer_; |
| 773 scoped_refptr<IOBuffer> write_buffer_; | 776 scoped_refptr<IOBuffer> write_buffer_; |
| 774 int expected_write_result_; | 777 int expected_write_result_; |
| 775 bool should_delete_writer_in_completion_callback_; | 778 bool should_delete_writer_in_completion_callback_; |
| 776 int writer_deletion_count_down_; | 779 int writer_deletion_count_down_; |
| 777 bool write_callback_was_called_; | 780 bool write_callback_was_called_; |
| 778 | 781 |
| 779 static scoped_ptr<base::Thread> io_thread_; | 782 static scoped_ptr<base::Thread> io_thread_; |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 812 | 815 |
| 813 TEST_F(AppCacheResponseTest, DeleteWithinCallbacks) { | 816 TEST_F(AppCacheResponseTest, DeleteWithinCallbacks) { |
| 814 RunTestOnIOThread(&AppCacheResponseTest::DeleteWithinCallbacks); | 817 RunTestOnIOThread(&AppCacheResponseTest::DeleteWithinCallbacks); |
| 815 } | 818 } |
| 816 | 819 |
| 817 TEST_F(AppCacheResponseTest, DeleteWithIOPending) { | 820 TEST_F(AppCacheResponseTest, DeleteWithIOPending) { |
| 818 RunTestOnIOThread(&AppCacheResponseTest::DeleteWithIOPending); | 821 RunTestOnIOThread(&AppCacheResponseTest::DeleteWithIOPending); |
| 819 } | 822 } |
| 820 | 823 |
| 821 } // namespace content | 824 } // namespace content |
| OLD | NEW |