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

Side by Side Diff: webkit/appcache/appcache_request_handler_unittest.cc

Issue 10534100: Decouple URLRequestJob from URLRequestContext; access NetworkDelegate as a contructor parameter. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Created 8 years, 6 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 (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 <string> 6 #include <string>
7 #include <vector> 7 #include <vector>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/bind_helpers.h" 10 #include "base/bind_helpers.h"
11 #include "base/callback.h" 11 #include "base/callback.h"
12 #include "base/message_loop.h" 12 #include "base/message_loop.h"
13 #include "base/threading/thread.h" 13 #include "base/threading/thread.h"
14 #include "base/synchronization/waitable_event.h" 14 #include "base/synchronization/waitable_event.h"
15 #include "net/base/net_errors.h" 15 #include "net/base/net_errors.h"
16 #include "net/http/http_response_headers.h" 16 #include "net/http/http_response_headers.h"
17 #include "net/url_request/url_request.h" 17 #include "net/url_request/url_request.h"
18 #include "net/url_request/url_request_context.h"
18 #include "net/url_request/url_request_error_job.h" 19 #include "net/url_request/url_request_error_job.h"
19 #include "testing/gtest/include/gtest/gtest.h" 20 #include "testing/gtest/include/gtest/gtest.h"
20 #include "webkit/appcache/appcache.h" 21 #include "webkit/appcache/appcache.h"
21 #include "webkit/appcache/appcache_backend_impl.h" 22 #include "webkit/appcache/appcache_backend_impl.h"
22 #include "webkit/appcache/appcache_request_handler.h" 23 #include "webkit/appcache/appcache_request_handler.h"
23 #include "webkit/appcache/appcache_url_request_job.h" 24 #include "webkit/appcache/appcache_url_request_job.h"
24 #include "webkit/appcache/mock_appcache_policy.h" 25 #include "webkit/appcache/mock_appcache_policy.h"
25 #include "webkit/appcache/mock_appcache_service.h" 26 #include "webkit/appcache/mock_appcache_service.h"
26 27
27 namespace appcache { 28 namespace appcache {
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
67 68
68 class MockURLRequestDelegate : public net::URLRequest::Delegate { 69 class MockURLRequestDelegate : public net::URLRequest::Delegate {
69 virtual void OnResponseStarted(net::URLRequest* request) {} 70 virtual void OnResponseStarted(net::URLRequest* request) {}
70 virtual void OnReadCompleted(net::URLRequest* request, int bytes_read) {} 71 virtual void OnReadCompleted(net::URLRequest* request, int bytes_read) {}
71 }; 72 };
72 73
73 class MockURLRequestJob : public net::URLRequestJob { 74 class MockURLRequestJob : public net::URLRequestJob {
74 public: 75 public:
75 MockURLRequestJob(net::URLRequest* request, 76 MockURLRequestJob(net::URLRequest* request,
76 int response_code) 77 int response_code)
77 : net::URLRequestJob(request), 78 : net::URLRequestJob(request, request->context()->network_delegate()),
78 response_code_(response_code), 79 response_code_(response_code),
79 has_response_info_(false) {} 80 has_response_info_(false) {}
80 MockURLRequestJob(net::URLRequest* request, 81 MockURLRequestJob(net::URLRequest* request,
81 const net::HttpResponseInfo& info) 82 const net::HttpResponseInfo& info)
82 : net::URLRequestJob(request), 83 : net::URLRequestJob(request,
84 request->context()->network_delegate()),
83 response_code_(info.headers->response_code()), 85 response_code_(info.headers->response_code()),
84 has_response_info_(true), 86 has_response_info_(true),
85 response_info_(info) {} 87 response_info_(info) {}
86 88
87 protected: 89 protected:
88 virtual ~MockURLRequestJob() {} 90 virtual ~MockURLRequestJob() {}
89 virtual void Start() OVERRIDE { 91 virtual void Start() OVERRIDE {
90 NotifyHeadersComplete(); 92 NotifyHeadersComplete();
91 } 93 }
92 virtual int GetResponseCode() const OVERRIDE { 94 virtual int GetResponseCode() const OVERRIDE {
(...skipping 801 matching lines...) Expand 10 before | Expand all | Expand 10 after
894 896
895 TEST_F(AppCacheRequestHandlerTest, WorkerRequest) { 897 TEST_F(AppCacheRequestHandlerTest, WorkerRequest) {
896 RunTestOnIOThread(&AppCacheRequestHandlerTest::WorkerRequest); 898 RunTestOnIOThread(&AppCacheRequestHandlerTest::WorkerRequest);
897 } 899 }
898 900
899 TEST_F(AppCacheRequestHandlerTest, MainResource_Blocked) { 901 TEST_F(AppCacheRequestHandlerTest, MainResource_Blocked) {
900 RunTestOnIOThread(&AppCacheRequestHandlerTest::MainResource_Blocked); 902 RunTestOnIOThread(&AppCacheRequestHandlerTest::MainResource_Blocked);
901 } 903 }
902 904
903 } // namespace appcache 905 } // namespace appcache
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698