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

Side by Side Diff: net/url_request/url_request_test_job.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: Merged with latest sync Created 8 years, 5 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 "net/url_request/url_request_test_job.h" 5 #include "net/url_request/url_request_test_job.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <list> 8 #include <list>
9 9
10 #include "base/bind.h" 10 #include "base/bind.h"
11 #include "base/compiler_specific.h" 11 #include "base/compiler_specific.h"
12 #include "base/lazy_instance.h" 12 #include "base/lazy_instance.h"
13 #include "base/message_loop.h" 13 #include "base/message_loop.h"
14 #include "base/string_util.h" 14 #include "base/string_util.h"
15 #include "net/base/io_buffer.h" 15 #include "net/base/io_buffer.h"
16 #include "net/base/net_errors.h" 16 #include "net/base/net_errors.h"
17 #include "net/http/http_response_headers.h" 17 #include "net/http/http_response_headers.h"
18 #include "net/url_request/url_request.h" 18 #include "net/url_request/url_request.h"
19 #include "net/url_request/url_request_context.h"
19 20
20 namespace net { 21 namespace net {
21 22
22 namespace { 23 namespace {
23 24
24 typedef std::list<URLRequestTestJob*> URLRequestJobList; 25 typedef std::list<URLRequestTestJob*> URLRequestJobList;
25 base::LazyInstance<URLRequestJobList>::Leaky 26 base::LazyInstance<URLRequestJobList>::Leaky
26 g_pending_jobs = LAZY_INSTANCE_INITIALIZER; 27 g_pending_jobs = LAZY_INSTANCE_INITIALIZER;
27 28
28 } // namespace 29 } // namespace
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
78 return std::string(kHeaders, arraysize(kHeaders)); 79 return std::string(kHeaders, arraysize(kHeaders));
79 } 80 }
80 81
81 // static 82 // static
82 URLRequestJob* URLRequestTestJob::Factory(URLRequest* request, 83 URLRequestJob* URLRequestTestJob::Factory(URLRequest* request,
83 const std::string& scheme) { 84 const std::string& scheme) {
84 return new URLRequestTestJob(request); 85 return new URLRequestTestJob(request);
85 } 86 }
86 87
87 URLRequestTestJob::URLRequestTestJob(URLRequest* request) 88 URLRequestTestJob::URLRequestTestJob(URLRequest* request)
88 : URLRequestJob(request), 89 : URLRequestJob(request, request->context()->network_delegate()),
89 auto_advance_(false), 90 auto_advance_(false),
90 stage_(WAITING), 91 stage_(WAITING),
91 offset_(0), 92 offset_(0),
92 async_buf_(NULL), 93 async_buf_(NULL),
93 async_buf_size_(0), 94 async_buf_size_(0),
94 ALLOW_THIS_IN_INITIALIZER_LIST(weak_factory_(this)) { 95 ALLOW_THIS_IN_INITIALIZER_LIST(weak_factory_(this)) {
95 } 96 }
96 97
97 URLRequestTestJob::URLRequestTestJob(URLRequest* request, 98 URLRequestTestJob::URLRequestTestJob(URLRequest* request,
98 bool auto_advance) 99 bool auto_advance)
99 : URLRequestJob(request), 100 : URLRequestJob(request, request->context()->network_delegate()),
100 auto_advance_(auto_advance), 101 auto_advance_(auto_advance),
101 stage_(WAITING), 102 stage_(WAITING),
102 offset_(0), 103 offset_(0),
103 async_buf_(NULL), 104 async_buf_(NULL),
104 async_buf_size_(0), 105 async_buf_size_(0),
105 ALLOW_THIS_IN_INITIALIZER_LIST(weak_factory_(this)) { 106 ALLOW_THIS_IN_INITIALIZER_LIST(weak_factory_(this)) {
106 } 107 }
107 108
108 URLRequestTestJob::URLRequestTestJob(URLRequest* request, 109 URLRequestTestJob::URLRequestTestJob(URLRequest* request,
109 const std::string& response_headers, 110 const std::string& response_headers,
110 const std::string& response_data, 111 const std::string& response_data,
111 bool auto_advance) 112 bool auto_advance)
112 : URLRequestJob(request), 113 : URLRequestJob(request, request->context()->network_delegate()),
113 auto_advance_(auto_advance), 114 auto_advance_(auto_advance),
114 stage_(WAITING), 115 stage_(WAITING),
115 response_headers_(new HttpResponseHeaders(response_headers)), 116 response_headers_(new HttpResponseHeaders(response_headers)),
116 response_data_(response_data), 117 response_data_(response_data),
117 offset_(0), 118 offset_(0),
118 async_buf_(NULL), 119 async_buf_(NULL),
119 async_buf_size_(0), 120 async_buf_size_(0),
120 ALLOW_THIS_IN_INITIALIZER_LIST(weak_factory_(this)) { 121 ALLOW_THIS_IN_INITIALIZER_LIST(weak_factory_(this)) {
121 } 122 }
122 123
(...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after
291 292
292 URLRequestTestJob* next_job(g_pending_jobs.Get().front()); 293 URLRequestTestJob* next_job(g_pending_jobs.Get().front());
293 g_pending_jobs.Get().pop_front(); 294 g_pending_jobs.Get().pop_front();
294 295
295 DCHECK(!next_job->auto_advance()); // auto_advance jobs should be in this q 296 DCHECK(!next_job->auto_advance()); // auto_advance jobs should be in this q
296 next_job->ProcessNextOperation(); 297 next_job->ProcessNextOperation();
297 return true; 298 return true;
298 } 299 }
299 300
300 } // namespace net 301 } // namespace net
OLDNEW
« no previous file with comments | « net/url_request/url_request_simple_job.cc ('k') | webkit/appcache/appcache_request_handler_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698