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

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

Issue 631773003: Replacing the OVERRIDE with override and FINAL with final in content/browser/appcache (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 2 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 <stack> 5 #include <stack>
6 #include <utility> 6 #include <utility>
7 7
8 #include "base/bind.h" 8 #include "base/bind.h"
9 #include "base/bind_helpers.h" 9 #include "base/bind_helpers.h"
10 #include "base/callback.h" 10 #include "base/callback.h"
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
55 } 55 }
56 56
57 bool has_job() const { 57 bool has_job() const {
58 return job_ != NULL; 58 return job_ != NULL;
59 } 59 }
60 60
61 // net::URLRequestJobFactory implementation. 61 // net::URLRequestJobFactory implementation.
62 virtual net::URLRequestJob* MaybeCreateJobWithProtocolHandler( 62 virtual net::URLRequestJob* MaybeCreateJobWithProtocolHandler(
63 const std::string& scheme, 63 const std::string& scheme,
64 net::URLRequest* request, 64 net::URLRequest* request,
65 net::NetworkDelegate* network_delegate) const OVERRIDE { 65 net::NetworkDelegate* network_delegate) const override {
66 if (job_) { 66 if (job_) {
67 net::URLRequestJob* temp = job_; 67 net::URLRequestJob* temp = job_;
68 job_ = NULL; 68 job_ = NULL;
69 return temp; 69 return temp;
70 } else { 70 } else {
71 return new net::URLRequestErrorJob(request, 71 return new net::URLRequestErrorJob(request,
72 network_delegate, 72 network_delegate,
73 net::ERR_INTERNET_DISCONNECTED); 73 net::ERR_INTERNET_DISCONNECTED);
74 } 74 }
75 } 75 }
76 76
77 virtual bool IsHandledProtocol(const std::string& scheme) const OVERRIDE { 77 virtual bool IsHandledProtocol(const std::string& scheme) const override {
78 return scheme == "http"; 78 return scheme == "http";
79 }; 79 };
80 80
81 virtual bool IsHandledURL(const GURL& url) const OVERRIDE { 81 virtual bool IsHandledURL(const GURL& url) const override {
82 return url.SchemeIs("http"); 82 return url.SchemeIs("http");
83 } 83 }
84 84
85 virtual bool IsSafeRedirectTarget(const GURL& location) const OVERRIDE { 85 virtual bool IsSafeRedirectTarget(const GURL& location) const override {
86 return false; 86 return false;
87 } 87 }
88 88
89 private: 89 private:
90 mutable net::URLRequestJob* job_; 90 mutable net::URLRequestJob* job_;
91 }; 91 };
92 92
93 class AppCacheURLRequestJobTest : public testing::Test { 93 class AppCacheURLRequestJobTest : public testing::Test {
94 public: 94 public:
95 95
96 // Test Harness ------------------------------------------------------------- 96 // Test Harness -------------------------------------------------------------
97 // TODO(michaeln): share this test harness with AppCacheResponseTest 97 // TODO(michaeln): share this test harness with AppCacheResponseTest
98 98
99 class MockStorageDelegate : public AppCacheStorage::Delegate { 99 class MockStorageDelegate : public AppCacheStorage::Delegate {
100 public: 100 public:
101 explicit MockStorageDelegate(AppCacheURLRequestJobTest* test) 101 explicit MockStorageDelegate(AppCacheURLRequestJobTest* test)
102 : loaded_info_id_(0), test_(test) { 102 : loaded_info_id_(0), test_(test) {
103 } 103 }
104 104
105 virtual void OnResponseInfoLoaded(AppCacheResponseInfo* info, 105 virtual void OnResponseInfoLoaded(AppCacheResponseInfo* info,
106 int64 response_id) OVERRIDE { 106 int64 response_id) override {
107 loaded_info_ = info; 107 loaded_info_ = info;
108 loaded_info_id_ = response_id; 108 loaded_info_id_ = response_id;
109 test_->ScheduleNextTask(); 109 test_->ScheduleNextTask();
110 } 110 }
111 111
112 scoped_refptr<AppCacheResponseInfo> loaded_info_; 112 scoped_refptr<AppCacheResponseInfo> loaded_info_;
113 int64 loaded_info_id_; 113 int64 loaded_info_id_;
114 AppCacheURLRequestJobTest* test_; 114 AppCacheURLRequestJobTest* test_;
115 }; 115 };
116 116
117 class MockURLRequestDelegate : public net::URLRequest::Delegate { 117 class MockURLRequestDelegate : public net::URLRequest::Delegate {
118 public: 118 public:
119 explicit MockURLRequestDelegate(AppCacheURLRequestJobTest* test) 119 explicit MockURLRequestDelegate(AppCacheURLRequestJobTest* test)
120 : test_(test), 120 : test_(test),
121 received_data_(new net::IOBuffer(kNumBlocks * kBlockSize)), 121 received_data_(new net::IOBuffer(kNumBlocks * kBlockSize)),
122 did_receive_headers_(false), amount_received_(0), 122 did_receive_headers_(false), amount_received_(0),
123 kill_after_amount_received_(0), kill_with_io_pending_(false) { 123 kill_after_amount_received_(0), kill_with_io_pending_(false) {
124 } 124 }
125 125
126 virtual void OnResponseStarted(net::URLRequest* request) OVERRIDE { 126 virtual void OnResponseStarted(net::URLRequest* request) override {
127 amount_received_ = 0; 127 amount_received_ = 0;
128 did_receive_headers_ = false; 128 did_receive_headers_ = false;
129 if (request->status().is_success()) { 129 if (request->status().is_success()) {
130 EXPECT_TRUE(request->response_headers()); 130 EXPECT_TRUE(request->response_headers());
131 did_receive_headers_ = true; 131 did_receive_headers_ = true;
132 received_info_ = request->response_info(); 132 received_info_ = request->response_info();
133 ReadSome(request); 133 ReadSome(request);
134 } else { 134 } else {
135 RequestComplete(); 135 RequestComplete();
136 } 136 }
137 } 137 }
138 138
139 virtual void OnReadCompleted(net::URLRequest* request, 139 virtual void OnReadCompleted(net::URLRequest* request,
140 int bytes_read) OVERRIDE { 140 int bytes_read) override {
141 if (bytes_read > 0) { 141 if (bytes_read > 0) {
142 amount_received_ += bytes_read; 142 amount_received_ += bytes_read;
143 143
144 if (kill_after_amount_received_ && !kill_with_io_pending_) { 144 if (kill_after_amount_received_ && !kill_with_io_pending_) {
145 if (amount_received_ >= kill_after_amount_received_) { 145 if (amount_received_ >= kill_after_amount_received_) {
146 request->Cancel(); 146 request->Cancel();
147 return; 147 return;
148 } 148 }
149 } 149 }
150 150
(...skipping 703 matching lines...) Expand 10 before | Expand all | Expand 10 after
854 RunTestOnIOThread(&AppCacheURLRequestJobTest::CancelRequest); 854 RunTestOnIOThread(&AppCacheURLRequestJobTest::CancelRequest);
855 } 855 }
856 856
857 TEST_F(AppCacheURLRequestJobTest, CancelRequestWithIOPending) { 857 TEST_F(AppCacheURLRequestJobTest, CancelRequestWithIOPending) {
858 RunTestOnIOThread(&AppCacheURLRequestJobTest::CancelRequestWithIOPending); 858 RunTestOnIOThread(&AppCacheURLRequestJobTest::CancelRequestWithIOPending);
859 } 859 }
860 860
861 } // namespace 861 } // namespace
862 862
863 } // namespace content 863 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/appcache/appcache_url_request_job.h ('k') | content/browser/appcache/chrome_appcache_service.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698