OLD | NEW |
---|---|
(Empty) | |
1 // Copyright (c) 2014 The Chromium Authors. All rights reserved. | |
2 // Use of this source code is governed by a BSD-style license that can be | |
3 // found in the LICENSE file. | |
4 | |
5 #include "net/http/test_network_transaction.h" | |
6 | |
7 #include "base/bind.h" | |
8 #include "base/logging.h" | |
9 #include "base/memory/scoped_ptr.h" | |
mmenke
2014/01/23 20:40:52
This is needed in the header file, rather than her
Randy Smith (Not in Mondays)
2014/01/23 22:12:33
Done.
| |
10 #include "base/message_loop/message_loop.h" | |
11 #include "net/base/load_timing_info.h" | |
12 #include "net/base/upload_progress.h" | |
13 #include "net/http/http_cache.h" | |
mmenke
2014/01/23 20:40:52
Don't need this, though may want to forward declar
Randy Smith (Not in Mondays)
2014/01/23 22:12:33
Done.
| |
14 #include "net/url_request/url_request_context_getter.h" | |
mmenke
2014/01/23 20:40:52
Not needed
Randy Smith (Not in Mondays)
2014/01/23 22:12:33
Done.
| |
15 | |
16 namespace net { | |
17 | |
18 TestNetworkTransaction::TestNetworkTransaction(enum Error err) : err_(err) { | |
19 DCHECK_NE(OK, err); | |
mmenke
2014/01/23 20:59:19
This should be a CHECK, so it surfaces during rele
mmenke
2014/01/23 20:59:19
Should have a similar check on creation of the fac
Randy Smith (Not in Mondays)
2014/01/23 22:12:33
Done.
Randy Smith (Not in Mondays)
2014/01/23 22:12:33
Quite right. Done.
rvargas (doing something else)
2014/01/23 23:24:49
I would actually argue for readability as opposed
mmenke
2014/01/23 23:27:18
Positive values generally indicate success. What
rvargas (doing something else)
2014/01/24 02:10:00
That doesn't match the definition of Start (the me
rvargas (doing something else)
2014/01/24 16:18:42
I guess what I said doesn't make a lot of sense, s
Randy Smith (Not in Mondays)
2014/01/25 21:11:31
With regard to the ordering, I'm happy to yield to
| |
20 } | |
21 | |
22 TestNetworkTransaction::~TestNetworkTransaction() {} | |
23 | |
24 int TestNetworkTransaction::Start(const HttpRequestInfo* request_info, | |
25 const CompletionCallback& callback, | |
26 const BoundNetLog& net_log) { | |
27 base::MessageLoop::current()->PostTask( | |
28 FROM_HERE, base::Bind(callback, err_)); | |
29 return ERR_IO_PENDING; | |
30 } | |
31 | |
32 int TestNetworkTransaction::RestartIgnoringLastError( | |
33 const CompletionCallback& callback) { | |
34 return ERR_FAILED; | |
35 } | |
36 | |
37 int TestNetworkTransaction::RestartWithCertificate( | |
38 X509Certificate* client_cert, | |
39 const CompletionCallback& callback) { | |
40 return ERR_FAILED; | |
41 } | |
42 | |
43 int TestNetworkTransaction::RestartWithAuth( | |
44 const AuthCredentials& credentials, | |
45 const CompletionCallback& callback) { | |
46 return ERR_FAILED; | |
47 } | |
48 | |
49 bool TestNetworkTransaction::IsReadyToRestartForAuth() { | |
50 return false; | |
51 } | |
52 | |
53 int TestNetworkTransaction::Read(IOBuffer* buf, int buf_len, | |
54 const CompletionCallback& callback) { | |
55 NOTREACHED(); | |
56 return ERR_FAILED; | |
57 } | |
58 | |
59 void TestNetworkTransaction::StopCaching() {} | |
60 | |
61 bool TestNetworkTransaction::GetFullRequestHeaders( | |
62 HttpRequestHeaders* headers) const { | |
63 return false; | |
64 } | |
65 | |
66 int64 TestNetworkTransaction::GetTotalReceivedBytes() const { | |
67 return 0; | |
68 } | |
69 | |
70 void TestNetworkTransaction::DoneReading() { | |
71 NOTREACHED(); | |
72 } | |
73 | |
74 const HttpResponseInfo* TestNetworkTransaction::GetResponseInfo() const { | |
75 return NULL; | |
76 } | |
77 | |
78 LoadState TestNetworkTransaction::GetLoadState() const { | |
79 return LOAD_STATE_IDLE; | |
80 } | |
81 | |
82 UploadProgress TestNetworkTransaction::GetUploadProgress() const { | |
83 return UploadProgress(); | |
84 } | |
85 | |
86 bool TestNetworkTransaction::GetLoadTimingInfo( | |
87 LoadTimingInfo* load_timing_info) const { | |
88 // Shouldn't be relevant; using the minimal set from | |
89 // http_transaction_unittest.cc MockNetworkTransaction::GetLoadTimingInfo(). | |
90 load_timing_info->socket_reused = true; | |
91 load_timing_info->send_start = base::TimeTicks::Now(); | |
92 load_timing_info->send_end = base::TimeTicks::Now(); | |
mmenke
2014/01/23 20:40:52
Suggest just:
*load_timing_info = LoadTimingInfo(
Randy Smith (Not in Mondays)
2014/01/23 22:12:33
I'm wary of doing that, just because I don't know
mmenke
2014/01/23 22:30:14
It's for HAR file generation, the navigation timin
Randy Smith (Not in Mondays)
2014/01/25 21:11:31
returning false.
| |
93 return true; | |
rvargas (doing something else)
2014/01/23 23:24:49
don't do anything and return false?
Randy Smith (Not in Mondays)
2014/01/25 21:11:31
Done.
| |
94 } | |
95 | |
96 void TestNetworkTransaction::SetPriority(RequestPriority priority) {} | |
97 | |
98 void TestNetworkTransaction::SetWebSocketHandshakeStreamCreateHelper( | |
99 WebSocketHandshakeStreamBase::CreateHelper* create_helper) { | |
100 NOTREACHED(); | |
101 } | |
102 | |
103 void TestNetworkTransaction::SetBeforeNetworkStartCallback( | |
104 const BeforeNetworkStartCallback& callback) { | |
105 } | |
106 | |
107 int TestNetworkTransaction::ResumeNetworkStart() { | |
108 NOTREACHED(); | |
109 return ERR_FAILED; | |
110 } | |
111 | |
112 TestNetworkTransactionFactory::TestNetworkTransactionFactory( | |
113 enum Error err) : err_(err) {} | |
114 | |
115 TestNetworkTransactionFactory::~TestNetworkTransactionFactory() {} | |
116 | |
117 // HttpTransactionFactory: | |
118 int TestNetworkTransactionFactory::CreateTransaction( | |
119 RequestPriority priority, | |
120 scoped_ptr<HttpTransaction>* trans) { | |
121 trans->reset(new TestNetworkTransaction(err_)); | |
122 return OK; | |
123 } | |
124 | |
125 HttpCache* TestNetworkTransactionFactory::GetCache() { | |
126 return NULL; | |
127 } | |
128 | |
129 HttpNetworkSession* TestNetworkTransactionFactory::GetSession() { | |
130 return NULL; // TODO(rdsmith): Is this really safe? | |
mmenke
2014/01/23 20:40:52
Can't we just pass in a real session? Seems the s
Randy Smith (Not in Mondays)
2014/01/25 21:11:31
Done.
| |
131 } | |
132 | |
133 } // namespace net | |
134 | |
OLD | NEW |