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

Side by Side Diff: net/http/http_transaction_unittest.cc

Issue 12701011: [Net] Propagate priority changes from URLRequest to HttpTransaction (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix leaks Created 7 years, 9 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
« no previous file with comments | « net/http/http_transaction_unittest.h ('k') | net/net.gyp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/http/http_transaction_unittest.h" 5 #include "net/http/http_transaction_unittest.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/message_loop.h" 10 #include "base/message_loop.h"
(...skipping 203 matching lines...) Expand 10 before | Expand all | Expand 10 after
214 default: 214 default:
215 NOTREACHED(); 215 NOTREACHED();
216 } 216 }
217 } 217 }
218 218
219 MockNetworkTransaction::MockNetworkTransaction( 219 MockNetworkTransaction::MockNetworkTransaction(
220 net::RequestPriority priority, 220 net::RequestPriority priority,
221 MockNetworkLayer* factory) 221 MockNetworkLayer* factory)
222 : ALLOW_THIS_IN_INITIALIZER_LIST(weak_factory_(this)), 222 : ALLOW_THIS_IN_INITIALIZER_LIST(weak_factory_(this)),
223 data_cursor_(0), 223 data_cursor_(0),
224 priority_(priority),
224 transaction_factory_(factory->AsWeakPtr()) { 225 transaction_factory_(factory->AsWeakPtr()) {
225 } 226 }
226 227
227 MockNetworkTransaction::~MockNetworkTransaction() {} 228 MockNetworkTransaction::~MockNetworkTransaction() {}
228 229
229 int MockNetworkTransaction::Start(const net::HttpRequestInfo* request, 230 int MockNetworkTransaction::Start(const net::HttpRequestInfo* request,
230 const net::CompletionCallback& callback, 231 const net::CompletionCallback& callback,
231 const net::BoundNetLog& net_log) { 232 const net::BoundNetLog& net_log) {
232 const MockTransaction* t = FindMockTransaction(request->url); 233 const MockTransaction* t = FindMockTransaction(request->url);
233 if (!t) 234 if (!t)
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
321 322
322 net::UploadProgress MockNetworkTransaction::GetUploadProgress() const { 323 net::UploadProgress MockNetworkTransaction::GetUploadProgress() const {
323 return net::UploadProgress(); 324 return net::UploadProgress();
324 } 325 }
325 326
326 bool MockNetworkTransaction::GetLoadTimingInfo( 327 bool MockNetworkTransaction::GetLoadTimingInfo(
327 net::LoadTimingInfo* load_timing_info) const { 328 net::LoadTimingInfo* load_timing_info) const {
328 return false; 329 return false;
329 } 330 }
330 331
332 void MockNetworkTransaction::SetPriority(net::RequestPriority priority) {
333 priority_ = priority;
334 }
335
331 void MockNetworkTransaction::CallbackLater( 336 void MockNetworkTransaction::CallbackLater(
332 const net::CompletionCallback& callback, int result) { 337 const net::CompletionCallback& callback, int result) {
333 MessageLoop::current()->PostTask( 338 MessageLoop::current()->PostTask(
334 FROM_HERE, base::Bind(&MockNetworkTransaction::RunCallback, 339 FROM_HERE, base::Bind(&MockNetworkTransaction::RunCallback,
335 weak_factory_.GetWeakPtr(), callback, result)); 340 weak_factory_.GetWeakPtr(), callback, result));
336 } 341 }
337 342
338 void MockNetworkTransaction::RunCallback( 343 void MockNetworkTransaction::RunCallback(
339 const net::CompletionCallback& callback, int result) { 344 const net::CompletionCallback& callback, int result) {
340 callback.Run(result); 345 callback.Run(result);
341 } 346 }
342 347
343 MockNetworkLayer::MockNetworkLayer() 348 MockNetworkLayer::MockNetworkLayer()
344 : transaction_count_(0), done_reading_called_(false) {} 349 : transaction_count_(0),
350 done_reading_called_(false),
351 last_create_transaction_priority_(net::DEFAULT_PRIORITY) {}
345 352
346 MockNetworkLayer::~MockNetworkLayer() {} 353 MockNetworkLayer::~MockNetworkLayer() {}
347 354
348 void MockNetworkLayer::TransactionDoneReading() { 355 void MockNetworkLayer::TransactionDoneReading() {
349 done_reading_called_ = true; 356 done_reading_called_ = true;
350 } 357 }
351 358
352 int MockNetworkLayer::CreateTransaction( 359 int MockNetworkLayer::CreateTransaction(
353 net::RequestPriority priority, 360 net::RequestPriority priority,
354 scoped_ptr<net::HttpTransaction>* trans, 361 scoped_ptr<net::HttpTransaction>* trans,
355 net::HttpTransactionDelegate* delegate) { 362 net::HttpTransactionDelegate* delegate) {
356 transaction_count_++; 363 transaction_count_++;
357 trans->reset(new MockNetworkTransaction(priority, this)); 364 last_create_transaction_priority_ = priority;
365 scoped_ptr<MockNetworkTransaction> mock_transaction(
366 new MockNetworkTransaction(priority, this));
367 last_transaction_ = mock_transaction->AsWeakPtr();
368 *trans = mock_transaction.Pass();
358 return net::OK; 369 return net::OK;
359 } 370 }
360 371
361 net::HttpCache* MockNetworkLayer::GetCache() { 372 net::HttpCache* MockNetworkLayer::GetCache() {
362 return NULL; 373 return NULL;
363 } 374 }
364 375
365 net::HttpNetworkSession* MockNetworkLayer::GetSession() { 376 net::HttpNetworkSession* MockNetworkLayer::GetSession() {
366 return NULL; 377 return NULL;
367 } 378 }
(...skipping 15 matching lines...) Expand all
383 394
384 if (rv > 0) 395 if (rv > 0)
385 content.append(buf->data(), rv); 396 content.append(buf->data(), rv);
386 else if (rv < 0) 397 else if (rv < 0)
387 return rv; 398 return rv;
388 } while (rv > 0); 399 } while (rv > 0);
389 400
390 result->swap(content); 401 result->swap(content);
391 return net::OK; 402 return net::OK;
392 } 403 }
OLDNEW
« no previous file with comments | « net/http/http_transaction_unittest.h ('k') | net/net.gyp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698