OLD | NEW |
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 <string> | 5 #include <string> |
6 | 6 |
7 #include "base/memory/ref_counted.h" | 7 #include "base/memory/ref_counted.h" |
8 #include "base/memory/scoped_ptr.h" | 8 #include "base/memory/scoped_ptr.h" |
9 #include "base/message_loop/message_loop.h" | 9 #include "base/message_loop/message_loop.h" |
10 #include "base/run_loop.h" | 10 #include "base/run_loop.h" |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
61 if (!request_) | 61 if (!request_) |
62 request_.reset(new MockHttpRequest(mock_transaction_)); | 62 request_.reset(new MockHttpRequest(mock_transaction_)); |
63 return request_.get(); | 63 return request_.get(); |
64 } | 64 } |
65 | 65 |
66 void SetNetworkState(const std::string& client_id, bool offline) { | 66 void SetNetworkState(const std::string& client_id, bool offline) { |
67 std::vector<std::string> domains; | 67 std::vector<std::string> domains; |
68 domains.push_back(kCom); | 68 domains.push_back(kCom); |
69 scoped_refptr<DevToolsNetworkConditions> conditions; | 69 scoped_refptr<DevToolsNetworkConditions> conditions; |
70 if (offline) | 70 if (offline) |
71 conditions = new DevToolsNetworkConditions(domains); | 71 conditions = new DevToolsNetworkConditions(domains, 0.0); |
72 controller_.SetNetworkStateOnIO(client_id, conditions); | 72 controller_.SetNetworkStateOnIO(client_id, conditions); |
73 } | 73 } |
74 | 74 |
75 int Start() { | 75 int Start() { |
76 return transaction_->Start( | 76 return transaction_->Start( |
77 GetRequest(), completion_callback_, net::BoundNetLog()); | 77 GetRequest(), completion_callback_, net::BoundNetLog()); |
78 } | 78 } |
79 | 79 |
80 int Read() { | 80 int Read() { |
81 return transaction_->Read(buffer_.get(), 64, completion_callback_); | 81 return transaction_->Read(buffer_.get(), 64, completion_callback_); |
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
205 helper.mock_transaction()->url = kHttpDotOrg; | 205 helper.mock_transaction()->url = kHttpDotOrg; |
206 DevToolsNetworkController* controller = helper.controller(); | 206 DevToolsNetworkController* controller = helper.controller(); |
207 net::HttpRequestInfo* request = helper.GetRequest(); | 207 net::HttpRequestInfo* request = helper.GetRequest(); |
208 | 208 |
209 EXPECT_FALSE(controller->ShouldFail(request)); | 209 EXPECT_FALSE(controller->ShouldFail(request)); |
210 helper.SetNetworkState(kClientId, true); | 210 helper.SetNetworkState(kClientId, true); |
211 EXPECT_FALSE(controller->ShouldFail(request)); | 211 EXPECT_FALSE(controller->ShouldFail(request)); |
212 } | 212 } |
213 | 213 |
214 } // namespace test | 214 } // namespace test |
OLD | NEW |