Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(46)

Side by Side Diff: content/browser/appcache/appcache_url_request_job_unittest.cc

Issue 1549113002: Switch to standard integer types in content/browser/. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase Created 4 years, 12 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 <utility> 8 #include <utility>
7 9
8 #include "base/bind.h" 10 #include "base/bind.h"
9 #include "base/bind_helpers.h" 11 #include "base/bind_helpers.h"
10 #include "base/callback.h" 12 #include "base/callback.h"
11 #include "base/compiler_specific.h" 13 #include "base/compiler_specific.h"
12 #include "base/location.h" 14 #include "base/location.h"
13 #include "base/logging.h" 15 #include "base/logging.h"
16 #include "base/macros.h"
14 #include "base/memory/scoped_ptr.h" 17 #include "base/memory/scoped_ptr.h"
15 #include "base/memory/weak_ptr.h" 18 #include "base/memory/weak_ptr.h"
16 #include "base/pickle.h" 19 #include "base/pickle.h"
17 #include "base/single_thread_task_runner.h" 20 #include "base/single_thread_task_runner.h"
18 #include "base/synchronization/waitable_event.h" 21 #include "base/synchronization/waitable_event.h"
19 #include "base/thread_task_runner_handle.h" 22 #include "base/thread_task_runner_handle.h"
20 #include "base/threading/thread.h" 23 #include "base/threading/thread.h"
21 #include "content/browser/appcache/appcache_response.h" 24 #include "content/browser/appcache/appcache_response.h"
22 #include "content/browser/appcache/appcache_url_request_job.h" 25 #include "content/browser/appcache/appcache_url_request_job.h"
23 #include "content/browser/appcache/mock_appcache_service.h" 26 #include "content/browser/appcache/mock_appcache_service.h"
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after
122 // Test Harness ------------------------------------------------------------- 125 // Test Harness -------------------------------------------------------------
123 // TODO(michaeln): share this test harness with AppCacheResponseTest 126 // TODO(michaeln): share this test harness with AppCacheResponseTest
124 127
125 class MockStorageDelegate : public AppCacheStorage::Delegate { 128 class MockStorageDelegate : public AppCacheStorage::Delegate {
126 public: 129 public:
127 explicit MockStorageDelegate(AppCacheURLRequestJobTest* test) 130 explicit MockStorageDelegate(AppCacheURLRequestJobTest* test)
128 : loaded_info_id_(0), test_(test) { 131 : loaded_info_id_(0), test_(test) {
129 } 132 }
130 133
131 void OnResponseInfoLoaded(AppCacheResponseInfo* info, 134 void OnResponseInfoLoaded(AppCacheResponseInfo* info,
132 int64 response_id) override { 135 int64_t response_id) override {
133 loaded_info_ = info; 136 loaded_info_ = info;
134 loaded_info_id_ = response_id; 137 loaded_info_id_ = response_id;
135 test_->ScheduleNextTask(); 138 test_->ScheduleNextTask();
136 } 139 }
137 140
138 scoped_refptr<AppCacheResponseInfo> loaded_info_; 141 scoped_refptr<AppCacheResponseInfo> loaded_info_;
139 int64 loaded_info_id_; 142 int64_t loaded_info_id_;
140 AppCacheURLRequestJobTest* test_; 143 AppCacheURLRequestJobTest* test_;
141 }; 144 };
142 145
143 class MockURLRequestDelegate : public net::URLRequest::Delegate { 146 class MockURLRequestDelegate : public net::URLRequest::Delegate {
144 public: 147 public:
145 explicit MockURLRequestDelegate(AppCacheURLRequestJobTest* test) 148 explicit MockURLRequestDelegate(AppCacheURLRequestJobTest* test)
146 : test_(test), 149 : test_(test),
147 received_data_(new net::IOBuffer(kNumBlocks * kBlockSize)), 150 received_data_(new net::IOBuffer(kNumBlocks * kBlockSize)),
148 did_receive_headers_(false), amount_received_(0), 151 did_receive_headers_(false), amount_received_(0),
149 kill_after_amount_received_(0), kill_with_io_pending_(false) { 152 kill_after_amount_received_(0), kill_with_io_pending_(false) {
(...skipping 337 matching lines...) Expand 10 before | Expand all | Expand 10 after
487 nullptr, false, 490 nullptr, false,
488 base::Bind(&ExpectNotRestarted))); 491 base::Bind(&ExpectNotRestarted)));
489 job->DeliverNetworkResponse(); 492 job->DeliverNetworkResponse();
490 EXPECT_TRUE(job->is_delivering_network_response()); 493 EXPECT_TRUE(job->is_delivering_network_response());
491 EXPECT_FALSE(job->has_been_started()); 494 EXPECT_FALSE(job->has_been_started());
492 495
493 job.reset(new AppCacheURLRequestJob(request.get(), nullptr, storage, 496 job.reset(new AppCacheURLRequestJob(request.get(), nullptr, storage,
494 nullptr, false, 497 nullptr, false,
495 base::Bind(&ExpectNotRestarted))); 498 base::Bind(&ExpectNotRestarted)));
496 const GURL kManifestUrl("http://blah/"); 499 const GURL kManifestUrl("http://blah/");
497 const int64 kCacheId(1); 500 const int64_t kCacheId(1);
498 const int64 kGroupId(1); 501 const int64_t kGroupId(1);
499 const AppCacheEntry kEntry(AppCacheEntry::EXPLICIT, 1); 502 const AppCacheEntry kEntry(AppCacheEntry::EXPLICIT, 1);
500 job->DeliverAppCachedResponse(kManifestUrl, kCacheId, kGroupId, 503 job->DeliverAppCachedResponse(kManifestUrl, kCacheId, kGroupId,
501 kEntry, false); 504 kEntry, false);
502 EXPECT_FALSE(job->is_waiting()); 505 EXPECT_FALSE(job->is_waiting());
503 EXPECT_TRUE(job->is_delivering_appcache_response()); 506 EXPECT_TRUE(job->is_delivering_appcache_response());
504 EXPECT_FALSE(job->has_been_started()); 507 EXPECT_FALSE(job->has_been_started());
505 EXPECT_EQ(kManifestUrl, job->manifest_url()); 508 EXPECT_EQ(kManifestUrl, job->manifest_url());
506 EXPECT_EQ(kCacheId, job->cache_id()); 509 EXPECT_EQ(kCacheId, job->cache_id());
507 EXPECT_EQ(kGroupId, job->group_id()); 510 EXPECT_EQ(kGroupId, job->group_id());
508 EXPECT_EQ(kEntry.types(), job->entry().types()); 511 EXPECT_EQ(kEntry.types(), job->entry().types());
(...skipping 248 matching lines...) Expand 10 before | Expand all | Expand 10 after
757 void VerifyDeliverPartialResponse() { 760 void VerifyDeliverPartialResponse() {
758 EXPECT_TRUE(request_->status().is_success()); 761 EXPECT_TRUE(request_->status().is_success());
759 EXPECT_EQ(3, url_request_delegate_->amount_received_); 762 EXPECT_EQ(3, url_request_delegate_->amount_received_);
760 EXPECT_EQ(0, memcmp(kHttpBasicBody + 1, 763 EXPECT_EQ(0, memcmp(kHttpBasicBody + 1,
761 url_request_delegate_->received_data_->data(), 764 url_request_delegate_->received_data_->data(),
762 3)); 765 3));
763 net::HttpResponseHeaders* headers = 766 net::HttpResponseHeaders* headers =
764 url_request_delegate_->received_info_.headers.get(); 767 url_request_delegate_->received_info_.headers.get();
765 EXPECT_EQ(206, headers->response_code()); 768 EXPECT_EQ(206, headers->response_code());
766 EXPECT_EQ(3, headers->GetContentLength()); 769 EXPECT_EQ(3, headers->GetContentLength());
767 int64 range_start, range_end, object_size; 770 int64_t range_start, range_end, object_size;
768 EXPECT_TRUE( 771 EXPECT_TRUE(
769 headers->GetContentRange(&range_start, &range_end, &object_size)); 772 headers->GetContentRange(&range_start, &range_end, &object_size));
770 EXPECT_EQ(1, range_start); 773 EXPECT_EQ(1, range_start);
771 EXPECT_EQ(3, range_end); 774 EXPECT_EQ(3, range_end);
772 EXPECT_EQ(5, object_size); 775 EXPECT_EQ(5, object_size);
773 TestFinished(); 776 TestFinished();
774 } 777 }
775 778
776 // CancelRequest -------------------------------------- 779 // CancelRequest --------------------------------------
777 780
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
832 scoped_ptr<MockStorageDelegate> storage_delegate_; 835 scoped_ptr<MockStorageDelegate> storage_delegate_;
833 scoped_ptr<MockAppCacheService> service_; 836 scoped_ptr<MockAppCacheService> service_;
834 std::stack<std::pair<base::Closure, bool> > task_stack_; 837 std::stack<std::pair<base::Closure, bool> > task_stack_;
835 838
836 scoped_ptr<AppCacheResponseReader> reader_; 839 scoped_ptr<AppCacheResponseReader> reader_;
837 scoped_refptr<HttpResponseInfoIOBuffer> read_info_buffer_; 840 scoped_refptr<HttpResponseInfoIOBuffer> read_info_buffer_;
838 scoped_refptr<IOBuffer> read_buffer_; 841 scoped_refptr<IOBuffer> read_buffer_;
839 int expected_read_result_; 842 int expected_read_result_;
840 int reader_deletion_count_down_; 843 int reader_deletion_count_down_;
841 844
842 int64 written_response_id_; 845 int64_t written_response_id_;
843 scoped_ptr<AppCacheResponseWriter> writer_; 846 scoped_ptr<AppCacheResponseWriter> writer_;
844 scoped_refptr<HttpResponseInfoIOBuffer> write_info_buffer_; 847 scoped_refptr<HttpResponseInfoIOBuffer> write_info_buffer_;
845 scoped_refptr<IOBuffer> write_buffer_; 848 scoped_refptr<IOBuffer> write_buffer_;
846 int expected_write_result_; 849 int expected_write_result_;
847 int writer_deletion_count_down_; 850 int writer_deletion_count_down_;
848 851
849 bool restart_callback_invoked_; 852 bool restart_callback_invoked_;
850 853
851 scoped_ptr<MockURLRequestJobFactory> job_factory_; 854 scoped_ptr<MockURLRequestJobFactory> job_factory_;
852 scoped_ptr<net::URLRequestContext> empty_context_; 855 scoped_ptr<net::URLRequestContext> empty_context_;
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
889 892
890 TEST_F(AppCacheURLRequestJobTest, CancelRequest) { 893 TEST_F(AppCacheURLRequestJobTest, CancelRequest) {
891 RunTestOnIOThread(&AppCacheURLRequestJobTest::CancelRequest); 894 RunTestOnIOThread(&AppCacheURLRequestJobTest::CancelRequest);
892 } 895 }
893 896
894 TEST_F(AppCacheURLRequestJobTest, CancelRequestWithIOPending) { 897 TEST_F(AppCacheURLRequestJobTest, CancelRequestWithIOPending) {
895 RunTestOnIOThread(&AppCacheURLRequestJobTest::CancelRequestWithIOPending); 898 RunTestOnIOThread(&AppCacheURLRequestJobTest::CancelRequestWithIOPending);
896 } 899 }
897 900
898 } // namespace content 901 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/appcache/appcache_url_request_job.cc ('k') | content/browser/appcache/appcache_working_set.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698