Index: net/http/test_network_transaction.cc |
diff --git a/net/http/test_network_transaction.cc b/net/http/test_network_transaction.cc |
new file mode 100644 |
index 0000000000000000000000000000000000000000..e875ae03221e06cada99563d9fd0471650b0e0af |
--- /dev/null |
+++ b/net/http/test_network_transaction.cc |
@@ -0,0 +1,134 @@ |
+// Copyright (c) 2014 The Chromium Authors. All rights reserved. |
+// Use of this source code is governed by a BSD-style license that can be |
+// found in the LICENSE file. |
+ |
+#include "net/http/test_network_transaction.h" |
+ |
+#include "base/bind.h" |
+#include "base/logging.h" |
+#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.
|
+#include "base/message_loop/message_loop.h" |
+#include "net/base/load_timing_info.h" |
+#include "net/base/upload_progress.h" |
+#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.
|
+#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.
|
+ |
+namespace net { |
+ |
+TestNetworkTransaction::TestNetworkTransaction(enum Error err) : err_(err) { |
+ 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
|
+} |
+ |
+TestNetworkTransaction::~TestNetworkTransaction() {} |
+ |
+int TestNetworkTransaction::Start(const HttpRequestInfo* request_info, |
+ const CompletionCallback& callback, |
+ const BoundNetLog& net_log) { |
+ base::MessageLoop::current()->PostTask( |
+ FROM_HERE, base::Bind(callback, err_)); |
+ return ERR_IO_PENDING; |
+} |
+ |
+int TestNetworkTransaction::RestartIgnoringLastError( |
+ const CompletionCallback& callback) { |
+ return ERR_FAILED; |
+} |
+ |
+int TestNetworkTransaction::RestartWithCertificate( |
+ X509Certificate* client_cert, |
+ const CompletionCallback& callback) { |
+ return ERR_FAILED; |
+} |
+ |
+int TestNetworkTransaction::RestartWithAuth( |
+ const AuthCredentials& credentials, |
+ const CompletionCallback& callback) { |
+ return ERR_FAILED; |
+} |
+ |
+bool TestNetworkTransaction::IsReadyToRestartForAuth() { |
+ return false; |
+} |
+ |
+int TestNetworkTransaction::Read(IOBuffer* buf, int buf_len, |
+ const CompletionCallback& callback) { |
+ NOTREACHED(); |
+ return ERR_FAILED; |
+} |
+ |
+void TestNetworkTransaction::StopCaching() {} |
+ |
+bool TestNetworkTransaction::GetFullRequestHeaders( |
+ HttpRequestHeaders* headers) const { |
+ return false; |
+} |
+ |
+int64 TestNetworkTransaction::GetTotalReceivedBytes() const { |
+ return 0; |
+} |
+ |
+void TestNetworkTransaction::DoneReading() { |
+ NOTREACHED(); |
+} |
+ |
+const HttpResponseInfo* TestNetworkTransaction::GetResponseInfo() const { |
+ return NULL; |
+} |
+ |
+LoadState TestNetworkTransaction::GetLoadState() const { |
+ return LOAD_STATE_IDLE; |
+} |
+ |
+UploadProgress TestNetworkTransaction::GetUploadProgress() const { |
+ return UploadProgress(); |
+} |
+ |
+bool TestNetworkTransaction::GetLoadTimingInfo( |
+ LoadTimingInfo* load_timing_info) const { |
+ // Shouldn't be relevant; using the minimal set from |
+ // http_transaction_unittest.cc MockNetworkTransaction::GetLoadTimingInfo(). |
+ load_timing_info->socket_reused = true; |
+ load_timing_info->send_start = base::TimeTicks::Now(); |
+ 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.
|
+ 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.
|
+} |
+ |
+void TestNetworkTransaction::SetPriority(RequestPriority priority) {} |
+ |
+void TestNetworkTransaction::SetWebSocketHandshakeStreamCreateHelper( |
+ WebSocketHandshakeStreamBase::CreateHelper* create_helper) { |
+ NOTREACHED(); |
+} |
+ |
+void TestNetworkTransaction::SetBeforeNetworkStartCallback( |
+ const BeforeNetworkStartCallback& callback) { |
+} |
+ |
+int TestNetworkTransaction::ResumeNetworkStart() { |
+ NOTREACHED(); |
+ return ERR_FAILED; |
+} |
+ |
+TestNetworkTransactionFactory::TestNetworkTransactionFactory( |
+ enum Error err) : err_(err) {} |
+ |
+TestNetworkTransactionFactory::~TestNetworkTransactionFactory() {} |
+ |
+// HttpTransactionFactory: |
+int TestNetworkTransactionFactory::CreateTransaction( |
+ RequestPriority priority, |
+ scoped_ptr<HttpTransaction>* trans) { |
+ trans->reset(new TestNetworkTransaction(err_)); |
+ return OK; |
+} |
+ |
+HttpCache* TestNetworkTransactionFactory::GetCache() { |
+ return NULL; |
+} |
+ |
+HttpNetworkSession* TestNetworkTransactionFactory::GetSession() { |
+ 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.
|
+} |
+ |
+} // namespace net |
+ |