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

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

Issue 2519473002: Fixes the cache lock issue. (Closed)
Patch Set: Feedback addressed Created 3 years, 10 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_test_util.h ('k') | net/log/net_log_event_type_list.h » ('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 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 "net/http/http_transaction_test_util.h" 5 #include "net/http/http_transaction_test_util.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <memory>
8 #include <unordered_map> 9 #include <unordered_map>
9 #include <utility> 10 #include <utility>
11 #include <vector>
10 12
11 #include "base/bind.h" 13 #include "base/bind.h"
12 #include "base/location.h" 14 #include "base/location.h"
13 #include "base/message_loop/message_loop.h" 15 #include "base/message_loop/message_loop.h"
14 #include "base/run_loop.h" 16 #include "base/run_loop.h"
15 #include "base/single_thread_task_runner.h" 17 #include "base/single_thread_task_runner.h"
16 #include "base/strings/stringprintf.h" 18 #include "base/strings/stringprintf.h"
17 #include "base/threading/thread_task_runner_handle.h" 19 #include "base/threading/thread_task_runner_handle.h"
18 #include "base/time/clock.h" 20 #include "base/time/clock.h"
19 #include "base/time/time.h" 21 #include "base/time/time.h"
20 #include "net/base/load_flags.h" 22 #include "net/base/load_flags.h"
21 #include "net/base/load_timing_info.h" 23 #include "net/base/load_timing_info.h"
22 #include "net/base/net_errors.h" 24 #include "net/base/net_errors.h"
23 #include "net/cert/x509_certificate.h" 25 #include "net/cert/x509_certificate.h"
24 #include "net/disk_cache/disk_cache.h" 26 #include "net/disk_cache/disk_cache.h"
25 #include "net/http/http_cache.h" 27 #include "net/http/http_cache.h"
26 #include "net/http/http_request_info.h" 28 #include "net/http/http_request_info.h"
27 #include "net/http/http_response_info.h" 29 #include "net/http/http_response_info.h"
28 #include "net/http/http_transaction.h" 30 #include "net/http/http_transaction.h"
29 #include "net/log/net_log.h" 31 #include "net/log/net_log.h"
30 #include "net/log/net_log_source.h" 32 #include "net/log/net_log_source.h"
31 #include "net/log/net_log_with_source.h" 33 #include "net/log/net_log_with_source.h"
32 #include "testing/gtest/include/gtest/gtest.h" 34 #include "testing/gtest/include/gtest/gtest.h"
33 35
34 namespace net { 36 namespace net {
35 37
36 namespace { 38 namespace {
39
37 using MockTransactionMap = 40 using MockTransactionMap =
38 std::unordered_map<std::string, const MockTransaction*>; 41 std::unordered_map<std::string, const MockTransaction*>;
39 static MockTransactionMap mock_transactions; 42 static MockTransactionMap mock_transactions;
40 } // namespace 43 } // namespace
41 44
42 //----------------------------------------------------------------------------- 45 //-----------------------------------------------------------------------------
43 // mock transaction data 46 // mock transaction data
44 47
45 const MockTransaction kSimpleGET_Transaction = { 48 const MockTransaction kSimpleGET_Transaction = {
46 "http://www.google.com/", 49 "http://www.google.com/",
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after
142 mock_transactions.erase(GURL(trans->url).spec()); 145 mock_transactions.erase(GURL(trans->url).spec());
143 } 146 }
144 147
145 MockHttpRequest::MockHttpRequest(const MockTransaction& t) { 148 MockHttpRequest::MockHttpRequest(const MockTransaction& t) {
146 url = GURL(t.url); 149 url = GURL(t.url);
147 method = t.method; 150 method = t.method;
148 extra_headers.AddHeadersFromString(t.request_headers); 151 extra_headers.AddHeadersFromString(t.request_headers);
149 load_flags = t.load_flags; 152 load_flags = t.load_flags;
150 } 153 }
151 154
155 Context::Context() : result(ERR_IO_PENDING) {}
156 Context::~Context() {}
157
152 //----------------------------------------------------------------------------- 158 //-----------------------------------------------------------------------------
153 159
154 // static 160 // static
155 int TestTransactionConsumer::quit_counter_ = 0; 161 int TestTransactionConsumer::quit_counter_ = 0;
156 162
157 TestTransactionConsumer::TestTransactionConsumer( 163 TestTransactionConsumer::TestTransactionConsumer(
158 RequestPriority priority, 164 RequestPriority priority,
159 HttpTransactionFactory* factory) 165 HttpTransactionFactory* factory)
160 : state_(IDLE), error_(OK) { 166 : state_(IDLE), error_(OK) {
161 // Disregard the error code. 167 // Disregard the error code.
(...skipping 319 matching lines...) Expand 10 before | Expand all | Expand 10 after
481 void MockNetworkTransaction::SetBeforeHeadersSentCallback( 487 void MockNetworkTransaction::SetBeforeHeadersSentCallback(
482 const BeforeHeadersSentCallback& callback) {} 488 const BeforeHeadersSentCallback& callback) {}
483 489
484 int MockNetworkTransaction::ResumeNetworkStart() { 490 int MockNetworkTransaction::ResumeNetworkStart() {
485 // Should not get here. 491 // Should not get here.
486 return ERR_FAILED; 492 return ERR_FAILED;
487 } 493 }
488 494
489 void MockNetworkTransaction::GetConnectionAttempts( 495 void MockNetworkTransaction::GetConnectionAttempts(
490 ConnectionAttempts* out) const { 496 ConnectionAttempts* out) const {
491 NOTIMPLEMENTED(); 497 return;
492 } 498 }
493 499
494 void MockNetworkTransaction::CallbackLater(const CompletionCallback& callback, 500 void MockNetworkTransaction::CallbackLater(const CompletionCallback& callback,
495 int result) { 501 int result) {
496 base::ThreadTaskRunnerHandle::Get()->PostTask( 502 base::ThreadTaskRunnerHandle::Get()->PostTask(
497 FROM_HERE, base::Bind(&MockNetworkTransaction::RunCallback, 503 FROM_HERE, base::Bind(&MockNetworkTransaction::RunCallback,
498 weak_factory_.GetWeakPtr(), callback, result)); 504 weak_factory_.GetWeakPtr(), callback, result));
499 } 505 }
500 506
501 void MockNetworkTransaction::RunCallback(const CompletionCallback& callback, 507 void MockNetworkTransaction::RunCallback(const CompletionCallback& callback,
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
578 content.append(buf->data(), rv); 584 content.append(buf->data(), rv);
579 else if (rv < 0) 585 else if (rv < 0)
580 return rv; 586 return rv;
581 } while (rv > 0); 587 } while (rv > 0);
582 588
583 result->swap(content); 589 result->swap(content);
584 return OK; 590 return OK;
585 } 591 }
586 592
587 } // namespace net 593 } // namespace net
OLDNEW
« no previous file with comments | « net/http/http_transaction_test_util.h ('k') | net/log/net_log_event_type_list.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698