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 transaction_.reset(new DevToolsNetworkTransaction( | 61 transaction_.reset(new DevToolsNetworkTransaction( |
62 &controller_, network_transaction.Pass())); | 62 &controller_, network_transaction.Pass())); |
63 } | 63 } |
64 | 64 |
65 net::HttpRequestInfo* GetRequest() { | 65 net::HttpRequestInfo* GetRequest() { |
66 if (!request_) | 66 if (!request_) |
67 request_.reset(new MockHttpRequest(mock_transaction_)); | 67 request_.reset(new MockHttpRequest(mock_transaction_)); |
68 return request_.get(); | 68 return request_.get(); |
69 } | 69 } |
70 | 70 |
71 void SetNetworkState(const std::string id, bool offline) { | 71 void SetNetworkState(const std::string& id, bool offline) { |
72 scoped_ptr<DevToolsNetworkConditions> conditions( | 72 scoped_ptr<DevToolsNetworkConditions> conditions( |
73 new DevToolsNetworkConditions(offline)); | 73 new DevToolsNetworkConditions(offline)); |
74 controller_.SetNetworkState(id, conditions.Pass()); | 74 controller_.SetNetworkState(id, conditions.Pass()); |
75 } | 75 } |
76 | 76 |
77 int Start() { | 77 int Start() { |
78 return transaction_->Start( | 78 return transaction_->Start( |
79 GetRequest(), completion_callback_, net::BoundNetLog()); | 79 GetRequest(), completion_callback_, net::BoundNetLog()); |
80 } | 80 } |
81 | 81 |
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
205 "X-DevTools-Emulate-Network-Conditions-Client-Id: 42\r\n" | 205 "X-DevTools-Emulate-Network-Conditions-Client-Id: 42\r\n" |
206 "X-DevTools-Request-Initiator: frontend\r\n"; | 206 "X-DevTools-Request-Initiator: frontend\r\n"; |
207 helper.Start(); | 207 helper.Start(); |
208 | 208 |
209 EXPECT_FALSE(helper.ShouldFail()); | 209 EXPECT_FALSE(helper.ShouldFail()); |
210 helper.SetNetworkState(kClientId, true); | 210 helper.SetNetworkState(kClientId, true); |
211 EXPECT_FALSE(helper.ShouldFail()); | 211 EXPECT_FALSE(helper.ShouldFail()); |
212 } | 212 } |
213 | 213 |
214 } // namespace test | 214 } // namespace test |
OLD | NEW |