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

Side by Side Diff: chrome/browser/devtools/devtools_network_interceptor.h

Issue 346503002: DevTools: emulate latency network condition. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@twin
Patch Set: Rebase Created 6 years, 6 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 | « no previous file | chrome/browser/devtools/devtools_network_interceptor.cc » ('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 #ifndef CHROME_BROWSER_DEVTOOLS_DEVTOOLS_NETWORK_INTERCEPTOR_H_ 5 #ifndef CHROME_BROWSER_DEVTOOLS_DEVTOOLS_NETWORK_INTERCEPTOR_H_
6 #define CHROME_BROWSER_DEVTOOLS_DEVTOOLS_NETWORK_INTERCEPTOR_H_ 6 #define CHROME_BROWSER_DEVTOOLS_DEVTOOLS_NETWORK_INTERCEPTOR_H_
7 7
8 #include <set> 8 #include <set>
9 #include <string> 9 #include <string>
10 #include <utility>
10 #include <vector> 11 #include <vector>
11 12
12 #include "base/macros.h" 13 #include "base/macros.h"
13 #include "base/memory/ref_counted.h" 14 #include "base/memory/ref_counted.h"
14 #include "base/timer/timer.h" 15 #include "base/timer/timer.h"
15 16
16 class DevToolsNetworkConditions; 17 class DevToolsNetworkConditions;
17 class DevToolsNetworkTransaction; 18 class DevToolsNetworkTransaction;
18 19
19 namespace base { 20 namespace base {
(...skipping 13 matching lines...) Expand all
33 34
34 // Applies network emulation configuration. 35 // Applies network emulation configuration.
35 void UpdateConditions( 36 void UpdateConditions(
36 const scoped_refptr<DevToolsNetworkConditions> conditions); 37 const scoped_refptr<DevToolsNetworkConditions> conditions);
37 38
38 void AddTransaction(DevToolsNetworkTransaction* transaction); 39 void AddTransaction(DevToolsNetworkTransaction* transaction);
39 void RemoveTransaction(DevToolsNetworkTransaction* transaction); 40 void RemoveTransaction(DevToolsNetworkTransaction* transaction);
40 41
41 bool ShouldFail(const DevToolsNetworkTransaction* transaction); 42 bool ShouldFail(const DevToolsNetworkTransaction* transaction);
42 bool ShouldThrottle(const DevToolsNetworkTransaction* transaction); 43 bool ShouldThrottle(const DevToolsNetworkTransaction* transaction);
43 void ThrottleTransaction(DevToolsNetworkTransaction* transaction); 44 void ThrottleTransaction(DevToolsNetworkTransaction* transaction, bool start);
44 45
45 const DevToolsNetworkConditions* conditions() const { 46 const DevToolsNetworkConditions* conditions() const {
46 return conditions_.get(); 47 return conditions_.get();
47 } 48 }
48 49
49 private: 50 private:
50 scoped_refptr<DevToolsNetworkConditions> conditions_; 51 scoped_refptr<DevToolsNetworkConditions> conditions_;
51 52
52 void UpdateThrottles(); 53 void UpdateThrottledTransactions(base::TimeTicks now);
53 void ArmTimer(); 54 void UpdateSuspendedTransactions(base::TimeTicks now);
55 void ArmTimer(base::TimeTicks now);
54 void OnTimer(); 56 void OnTimer();
55 57
56 typedef std::set<DevToolsNetworkTransaction*> Transactions; 58 typedef std::set<DevToolsNetworkTransaction*> Transactions;
57 Transactions transactions_; 59 Transactions transactions_;
58 60
61 // Transactions suspended for a "latency" period.
62 typedef std::pair<DevToolsNetworkTransaction*, int64_t> SuspendedTransaction;
63 typedef std::vector<SuspendedTransaction> SuspendedTransactions;
64 SuspendedTransactions suspended_transactions_;
65
66 // Transactions waiting certain amount of transfer to be "accounted".
59 std::vector<DevToolsNetworkTransaction*> throttled_transactions_; 67 std::vector<DevToolsNetworkTransaction*> throttled_transactions_;
68
60 base::OneShotTimer<DevToolsNetworkInterceptor> timer_; 69 base::OneShotTimer<DevToolsNetworkInterceptor> timer_;
61 base::TimeTicks offset_; 70 base::TimeTicks offset_;
62 base::TimeDelta tick_length_; 71 base::TimeDelta tick_length_;
72 base::TimeDelta latency_length_;
63 uint64_t last_tick_; 73 uint64_t last_tick_;
64 74
65 base::WeakPtrFactory<DevToolsNetworkInterceptor> weak_ptr_factory_; 75 base::WeakPtrFactory<DevToolsNetworkInterceptor> weak_ptr_factory_;
66 76
67 DISALLOW_COPY_AND_ASSIGN(DevToolsNetworkInterceptor); 77 DISALLOW_COPY_AND_ASSIGN(DevToolsNetworkInterceptor);
68 }; 78 };
69 79
70 #endif // CHROME_BROWSER_DEVTOOLS_DEVTOOLS_NETWORK_INTERCEPTOR_H_ 80 #endif // CHROME_BROWSER_DEVTOOLS_DEVTOOLS_NETWORK_INTERCEPTOR_H_
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/devtools/devtools_network_interceptor.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698