OLD | NEW |
| (Empty) |
1 // Copyright (c) 2011 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 // Run WebSocket live experiment to collect metrics about WebSocket | |
6 // availability in the real Internet. | |
7 // It tries to open WebSocket connection to websocket-experiment.chromium.org, | |
8 // send/receive some static content over the connection, and see how it works | |
9 // well. | |
10 // It must be started only if the user permits metrics reporting with the | |
11 // checkbox in the prefs. | |
12 // For more detail what the experiment is, see websocket_experiment_task.h. | |
13 | |
14 #ifndef CHROME_BROWSER_NET_WEBSOCKET_EXPERIMENT_WEBSOCKET_EXPERIMENT_RUNNER_H_ | |
15 #define CHROME_BROWSER_NET_WEBSOCKET_EXPERIMENT_WEBSOCKET_EXPERIMENT_RUNNER_H_ | |
16 #pragma once | |
17 | |
18 #include "base/basictypes.h" | |
19 #include "base/memory/linked_ptr.h" | |
20 #include "base/memory/ref_counted.h" | |
21 #include "base/memory/scoped_ptr.h" | |
22 #include "chrome/browser/net/websocket_experiment/websocket_experiment_task.h" | |
23 #include "net/base/completion_callback.h" | |
24 | |
25 namespace chrome_browser_net_websocket_experiment { | |
26 | |
27 class WebSocketExperimentRunner | |
28 : public base::RefCountedThreadSafe<WebSocketExperimentRunner> { | |
29 public: | |
30 class Config { | |
31 public: | |
32 Config() | |
33 : initial_delay_ms(0), | |
34 next_delay_ms(0) {} | |
35 | |
36 int64 initial_delay_ms; | |
37 int64 next_delay_ms; | |
38 WebSocketExperimentTask::Config ws_config[6]; | |
39 }; | |
40 static void Start(); | |
41 static void Stop(); | |
42 | |
43 void Run(); | |
44 void Cancel(); | |
45 | |
46 private: | |
47 enum State { | |
48 STATE_NONE, | |
49 STATE_IDLE, | |
50 STATE_RUN_WS, | |
51 STATE_RUN_WSS, | |
52 STATE_RUN_WS_NODEFAULT_PORT, | |
53 STATE_RUN_WS_DRAFT75, | |
54 STATE_RUN_WSS_DRAFT75, | |
55 STATE_RUN_WS_NODEFAULT_PORT_DRAFT75, | |
56 NUM_STATES, | |
57 }; | |
58 WebSocketExperimentRunner(); | |
59 virtual ~WebSocketExperimentRunner(); | |
60 friend class base::RefCountedThreadSafe<WebSocketExperimentRunner>; | |
61 | |
62 void InitConfig(); | |
63 void DoLoop(); | |
64 void OnTaskCompleted(int result); | |
65 void UpdateTaskResultHistogram(const WebSocketExperimentTask* task); | |
66 | |
67 Config config_; | |
68 State next_state_; | |
69 State task_state_; | |
70 scoped_ptr<WebSocketExperimentTask> task_; | |
71 net::CompletionCallbackImpl<WebSocketExperimentRunner> task_callback_; | |
72 | |
73 DISALLOW_COPY_AND_ASSIGN(WebSocketExperimentRunner); | |
74 }; | |
75 | |
76 } // namespace chrome_browser_net_websocket_experiment | |
77 | |
78 #endif // CHROME_BROWSER_NET_WEBSOCKET_EXPERIMENT_WEBSOCKET_EXPERIMENT_RUNNER_H
_ | |
OLD | NEW |