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

Side by Side Diff: chrome/browser/prerender/prerender_browsertest.cc

Issue 686343002: Add MaybeInterceptRedirect/Response to URLRequestInterceptor (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Added tests, removed DRP Created 6 years, 1 month 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 <deque> 5 #include <deque>
6 #include <vector> 6 #include <vector>
7 7
8 #include "base/bind.h" 8 #include "base/bind.h"
9 #include "base/command_line.h" 9 #include "base/command_line.h"
10 #include "base/files/file_path.h" 10 #include "base/files/file_path.h"
(...skipping 807 matching lines...) Expand 10 before | Expand all | Expand 10 after
818 return new HangingURLRequestJob(request, network_delegate); 818 return new HangingURLRequestJob(request, network_delegate);
819 } 819 }
820 return new net::URLRequestMockHTTPJob( 820 return new net::URLRequestMockHTTPJob(
821 request, 821 request,
822 network_delegate, 822 network_delegate,
823 file_, 823 file_,
824 BrowserThread::GetBlockingPool()->GetTaskRunnerWithShutdownBehavior( 824 BrowserThread::GetBlockingPool()->GetTaskRunnerWithShutdownBehavior(
825 base::SequencedWorkerPool::SKIP_ON_SHUTDOWN)); 825 base::SequencedWorkerPool::SKIP_ON_SHUTDOWN));
826 } 826 }
827 827
828 net::URLRequestJob* MaybeInterceptRedirect(
829 net::URLRequest* request,
830 net::NetworkDelegate* network_delegate,
831 const GURL& location) const override {
832 return NULL;
833 }
834
835 net::URLRequestJob* MaybeInterceptResponse(
836 net::URLRequest* request,
837 net::NetworkDelegate* network_delegate) const override {
838 return NULL;
839 }
840
828 private: 841 private:
829 base::FilePath file_; 842 base::FilePath file_;
830 base::Closure callback_; 843 base::Closure callback_;
831 mutable bool first_run_; 844 mutable bool first_run_;
832 }; 845 };
833 846
834 // Makes |url| never respond on the first load, and then with the contents of 847 // Makes |url| never respond on the first load, and then with the contents of
835 // |file| afterwards. When the first load has been scheduled, runs |callback| on 848 // |file| afterwards. When the first load has been scheduled, runs |callback| on
836 // the UI thread. 849 // the UI thread.
837 void CreateHangingFirstRequestInterceptorOnIO( 850 void CreateHangingFirstRequestInterceptorOnIO(
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
916 929
917 net::URLRequestJob* MaybeInterceptRequest( 930 net::URLRequestJob* MaybeInterceptRequest(
918 net::URLRequest* request, 931 net::URLRequest* request,
919 net::NetworkDelegate* network_delegate) const override { 932 net::NetworkDelegate* network_delegate) const override {
920 MockHTTPJob* job = new MockHTTPJob(request, network_delegate, file_); 933 MockHTTPJob* job = new MockHTTPJob(request, network_delegate, file_);
921 job->set_start_callback(base::Bind(&CountingInterceptor::RequestStarted, 934 job->set_start_callback(base::Bind(&CountingInterceptor::RequestStarted,
922 weak_factory_.GetWeakPtr())); 935 weak_factory_.GetWeakPtr()));
923 return job; 936 return job;
924 } 937 }
925 938
939 net::URLRequestJob* MaybeInterceptRedirect(
940 net::URLRequest* request,
941 net::NetworkDelegate* network_delegate,
942 const GURL& location) const override {
943 return NULL;
944 }
945
946 net::URLRequestJob* MaybeInterceptResponse(
947 net::URLRequest* request,
948 net::NetworkDelegate* network_delegate) const override {
949 return NULL;
950 }
951
926 void RequestStarted() { 952 void RequestStarted() {
927 BrowserThread::PostTask( 953 BrowserThread::PostTask(
928 BrowserThread::UI, FROM_HERE, 954 BrowserThread::UI, FROM_HERE,
929 base::Bind(&RequestCounter::RequestStarted, counter_)); 955 base::Bind(&RequestCounter::RequestStarted, counter_));
930 } 956 }
931 957
932 private: 958 private:
933 base::FilePath file_; 959 base::FilePath file_;
934 base::WeakPtr<RequestCounter> counter_; 960 base::WeakPtr<RequestCounter> counter_;
935 mutable base::WeakPtrFactory<CountingInterceptor> weak_factory_; 961 mutable base::WeakPtrFactory<CountingInterceptor> weak_factory_;
(...skipping 3660 matching lines...) Expand 10 before | Expand all | Expand 10 after
4596 TestShouldDisableLocalPredictorPreferenceNetworkMatrix( 4622 TestShouldDisableLocalPredictorPreferenceNetworkMatrix(
4597 true /*preference_wifi_network_wifi*/, 4623 true /*preference_wifi_network_wifi*/,
4598 true /*preference_wifi_network_4g*/, 4624 true /*preference_wifi_network_4g*/,
4599 true /*preference_always_network_wifi*/, 4625 true /*preference_always_network_wifi*/,
4600 false /*preference_always_network_4g*/, 4626 false /*preference_always_network_4g*/,
4601 true /*preference_never_network_wifi*/, 4627 true /*preference_never_network_wifi*/,
4602 true /*preference_never_network_4g*/); 4628 true /*preference_never_network_4g*/);
4603 } 4629 }
4604 4630
4605 } // namespace prerender 4631 } // namespace prerender
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698