OLD | NEW |
---|---|
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 //------------------------------------------------------------------------------ | 5 //------------------------------------------------------------------------------ |
6 // Description of the life cycle of a instance of MetricsService. | 6 // Description of the life cycle of a instance of MetricsService. |
7 // | 7 // |
8 // OVERVIEW | 8 // OVERVIEW |
9 // | 9 // |
10 // A MetricsService instance is typically created at application startup. It is | 10 // A MetricsService instance is typically created at application startup. It is |
11 // the central controller for the acquisition of log data, and the automatic | 11 // the central controller for the acquisition of log data, and the automatic |
12 // transmission of that log data to an external server. Its major job is to | 12 // transmission of that log data to an external server. Its major job is to |
13 // manage logs, grouping them for transmission, and transmitting them. As part | 13 // manage logs, grouping them for transmission, and transmitting them. As part |
14 // of its grouping, MS finalizes logs by including some just-in-time gathered | 14 // of its grouping, MS finalizes logs by including some just-in-time gathered |
15 // memory statistics, snapshotting the current stats of numerous histograms, | 15 // memory statistics, snapshotting the current stats of numerous histograms, |
16 // closing the logs, translating to protocol buffer format, and compressing the | 16 // closing the logs, translating to protocol buffer format, and compressing the |
17 // results for transmission. Transmission includes submitting a compressed log | 17 // results for transmission. Transmission includes submitting a compressed log |
18 // as data in a URL-post, and retransmitting (or retaining at process | 18 // as data in a URL-post, and retransmitting (or retaining at process |
19 // termination) if the attempted transmission failed. Retention across process | 19 // termination) if the attempted transmission failed. Retention across process |
20 // terminations is done using the the PrefServices facilities. The retained logs | 20 // terminations is done using the the PrefServices facilities. The retained logs |
21 // (the ones that never got transmitted) are compressed and base64-encoded | 21 // (the ones that never got transmitted) are compressed and base64-encoded |
22 // before being persisted. | 22 // before being persisted. |
23 // | 23 // |
24 // Logs fall into one of two categories: "initial logs," and "ongoing logs." | 24 // Logs fall into one of two categories: "initial logs," and "ongoing logs." |
25 // There is at most one initial log sent for each complete run of the chromium | 25 // There is at most one initial log sent for each complete run of Chrome (from |
26 // product (from startup, to browser shutdown). An initial log is generally | 26 // startup, to browser shutdown). An initial log is generally transmitted some |
27 // transmitted some short time (1 minute?) after startup, and includes stats | 27 // short time (1 minute?) after startup, and includes stats such as recent crash |
28 // such as recent crash info, the number and types of plugins, etc. The | 28 // info, the number and types of plugins, etc. The external server's response |
29 // external server's response to the initial log conceptually tells this MS if | 29 // to the initial log conceptually tells this MS if it should continue |
30 // it should continue transmitting logs (during this session). The server | 30 // transmitting logs (during this session). The server response can actually be |
31 // response can actually be much more detailed, and always includes (at a | 31 // much more detailed, and always includes (at a minimum) how often additional |
32 // minimum) how often additional ongoing logs should be sent. | 32 // ongoing logs should be sent. |
33 // | 33 // |
34 // After the above initial log, a series of ongoing logs will be transmitted. | 34 // After the above initial log, a series of ongoing logs will be transmitted. |
35 // The first ongoing log actually begins to accumulate information stating when | 35 // The first ongoing log actually begins to accumulate information stating when |
36 // the MS was first constructed. Note that even though the initial log is | 36 // the MS was first constructed. Note that even though the initial log is |
37 // commonly sent a full minute after startup, the initial log does not include | 37 // commonly sent a full minute after startup, the initial log does not include |
38 // much in the way of user stats. The most common interlog period (delay) | 38 // much in the way of user stats. The most common interlog period (delay) |
39 // is 30 minutes. That time period starts when the first user action causes a | 39 // is 30 minutes. That time period starts when the first user action causes a |
40 // logging event. This means that if there is no user action, there may be long | 40 // logging event. This means that if there is no user action, there may be long |
41 // periods without any (ongoing) log transmissions. Ongoing logs typically | 41 // periods without any (ongoing) log transmissions. Ongoing logs typically |
42 // contain very detailed records of user activities (ex: opened tab, closed | 42 // contain very detailed records of user activities (ex: opened tab, closed |
43 // tab, fetched URL, maximized window, etc.) In addition, just before an | 43 // tab, fetched URL, maximized window, etc.) In addition, just before an |
44 // ongoing log is closed out, a call is made to gather memory statistics. Those | 44 // ongoing log is closed out, a call is made to gather memory statistics. Those |
45 // memory statistics are deposited into a histogram, and the log finalization | 45 // memory statistics are deposited into a histogram, and the log finalization |
46 // code is then called. In the finalization, a call to a Histogram server | 46 // code is then called. In the finalization, a call to a Histogram server |
47 // acquires a list of all local histograms that have been flagged for upload | 47 // acquires a list of all local histograms that have been flagged for upload |
48 // to the UMA server. The finalization also acquires a the most recent number | 48 // to the UMA server. The finalization also acquires the most recent number |
49 // of page loads, along with any counts of renderer or plugin crashes. | 49 // of page loads, along with any counts of renderer or plugin crashes. |
50 // | 50 // |
51 // When the browser shuts down, there will typically be a fragment of an ongoing | 51 // When the browser shuts down, there will typically be a fragment of an ongoing |
52 // log that has not yet been transmitted. At shutdown time, that fragment | 52 // log that has not yet been transmitted. At shutdown time, that fragment is |
53 // is closed (including snapshotting histograms), and persisted, for | 53 // closed (including snapshotting histograms), and persisted, for potential |
54 // potential transmission during a future run of the product. | 54 // transmission during a future run of the product. |
55 // | 55 // |
56 // There are two slightly abnormal shutdown conditions. There is a | 56 // There are two slightly abnormal shutdown conditions. There is a |
57 // "disconnected scenario," and a "really fast startup and shutdown" scenario. | 57 // "disconnected scenario," and a "really fast startup and shutdown" scenario. |
58 // In the "never connected" situation, the user has (during the running of the | 58 // In the "never connected" situation, the user has (during the running of the |
59 // process) never established an internet connection. As a result, attempts to | 59 // process) never established an internet connection. As a result, attempts to |
60 // transmit the initial log have failed, and a lot(?) of data has accumulated in | 60 // transmit the initial log have failed, and a lot(?) of data has accumulated in |
61 // the ongoing log (which didn't yet get closed, because there was never even a | 61 // the ongoing log (which didn't yet get closed, because there was never even a |
62 // contemplation of sending it). There is also a kindred "lost connection" | 62 // contemplation of sending it). There is also a kindred "lost connection" |
63 // situation, where a loss of connection prevented an ongoing log from being | 63 // situation, where a loss of connection prevented an ongoing log from being |
64 // transmitted, and a (still open) log was stuck accumulating a lot(?) of data, | 64 // transmitted, and a (still open) log was stuck accumulating a lot(?) of data, |
65 // while the earlier log retried its transmission. In both of these | 65 // while the earlier log retried its transmission. In both of these |
66 // disconnected situations, two logs need to be, and are, persistently stored | 66 // disconnected situations, two logs need to be, and are, persistently stored |
67 // for future transmission. | 67 // for future transmission. |
68 // | 68 // |
69 // The other unusual shutdown condition, termed "really fast startup and | 69 // The other unusual shutdown condition, termed "really fast startup and |
70 // shutdown," involves the deliberate user termination of the process before | 70 // shutdown," involves the deliberate user termination of the process before |
71 // the initial log is even formed or transmitted. In that situation, no logging | 71 // the initial log is even formed or transmitted. In that situation, no logging |
72 // is done, but the historical crash statistics remain (unlogged) for inclusion | 72 // is done, but the historical crash statistics remain (unlogged) for inclusion |
73 // in a future run's initial log. (i.e., we don't lose crash stats). | 73 // in a future run's initial log. (i.e., we don't lose crash stats). |
74 // | 74 // |
75 // With the above overview, we can now describe the state machine's various | 75 // With the above overview, we can now describe the state machine's various |
76 // stats, based on the State enum specified in the state_ member. Those states | 76 // states, based on the State enum specified in the state_ member. Those states |
77 // are: | 77 // are: |
78 // | 78 // |
79 // INITIALIZED, // Constructor was called. | 79 // INITIALIZED, // Constructor was called. |
80 // INIT_TASK_SCHEDULED, // Waiting for deferred init tasks to complete. | 80 // INIT_TASK_SCHEDULED, // Waiting for deferred init tasks to finish. |
Ilya Sherman
2013/12/06 06:21:26
nit: Note that you still have "tasks" here, but yo
Alexei Svitkine (slow)
2013/12/06 17:59:22
Done.
| |
81 // INIT_TASK_DONE, // Waiting for timer to send initial log. | 81 // INIT_TASK_DONE, // Waiting for timer to send initial log. |
82 // INITIAL_LOG_READY, // Initial log generated, and waiting for reply. | 82 // SENDING_INITIAL_STABILITY_LOG, // Initial stability log being sent. |
83 // SENDING_OLD_LOGS, // Sending unsent logs from previous session. | 83 // SENDING_INITIAL_METRICS_LOG, // Initial metrics log being sent. |
84 // SENDING_CURRENT_LOGS, // Sending standard current logs as they accrue. | 84 // SENDING_OLD_LOGS, // Sending unsent logs from previous session. |
85 // SENDING_CURRENT_LOGS, // Sending ongoing logs as they acrue. | |
85 // | 86 // |
86 // In more detail, we have: | 87 // In more detail, we have: |
87 // | 88 // |
88 // INITIALIZED, // Constructor was called. | 89 // INITIALIZED, // Constructor was called. |
89 // The MS has been constructed, but has taken no actions to compose the | 90 // The MS has been constructed, but has taken no actions to compose the |
90 // initial log. | 91 // initial log. |
91 // | 92 // |
92 // INIT_TASK_SCHEDULED, // Waiting for deferred init tasks to complete. | 93 // INIT_TASK_SCHEDULED, // Waiting for deferred init task to complete. |
93 // Typically about 30 seconds after startup, a task is sent to a second thread | 94 // Typically about 30 seconds after startup, a task is sent to a second thread |
94 // (the file thread) to perform deferred (lower priority and slower) | 95 // (the file thread) to perform deferred (lower priority and slower) |
95 // initialization steps such as getting the list of plugins. That task will | 96 // initialization steps such as getting the list of plugins. That task will |
96 // (when complete) make an async callback (via a Task) to indicate the | 97 // (when complete) make an async callback (via a Task) to indicate the |
97 // completion. | 98 // completion. |
98 // | 99 // |
99 // INIT_TASK_DONE, // Waiting for timer to send initial log. | 100 // INIT_TASK_DONE, // Waiting for timer to send initial log. |
100 // The callback has arrived, and it is now possible for an initial log to be | 101 // The callback has arrived, and it is now possible for an initial log to be |
101 // created. This callback typically arrives back less than one second after | 102 // created. This callback typically arrives back less than one second after |
102 // the deferred init task is dispatched. | 103 // the deferred init task is dispatched. |
103 // | 104 // |
104 // INITIAL_LOG_READY, // Initial log generated, and waiting for reply. | 105 // SENDING_INITIAL_STABILITY_LOG, // Initial stability log being sent. |
105 // This state is entered only after an initial log has been composed, and | 106 // During initialization, if a crash occurred during the previous session, an |
106 // prepared for transmission. It is also the case that any previously unsent | 107 // initial stability log will be generated and registered with the log manager. |
107 // logs have been loaded into instance variables for possible transmission. | 108 // This state will be entered if there's such a stability log waiting to be |
Ilya Sherman
2013/12/06 06:21:26
nit: What does it mean for there to be a stability
Alexei Svitkine (slow)
2013/12/06 17:59:22
Done.
| |
109 // transmitted when its time to sent up the first log (per the reporting | |
Ilya Sherman
2013/12/06 06:21:26
nit: "its" -> "it's"
Ilya Sherman
2013/12/06 06:21:26
nit: "sent" -> "send"
Alexei Svitkine (slow)
2013/12/06 17:59:22
Done.
Alexei Svitkine (slow)
2013/12/06 17:59:22
Done.
| |
110 // scheduler). If there is no initial stability log (e.g. there was no previous | |
111 // crash), then this state will be skipped and the state will advance to | |
112 // SENDING_INITIAL_METRICS_LOG. | |
113 // | |
114 // SENDING_INITIAL_METRICS_LOG, // Initial metrics log being sent. | |
115 // This state is entered once the initial metrics log has been composed, and | |
116 // prepared for transmission and after sending the initial stability log, if | |
117 // any. It is also the case that any previously unsent logs have been loaded | |
Ilya Sherman
2013/12/06 06:21:26
nit: This first sentence is a bit hard to parse; c
Alexei Svitkine (slow)
2013/12/06 17:59:22
Done.
| |
118 // into instance variables for possible transmission. | |
108 // | 119 // |
109 // SENDING_OLD_LOGS, // Sending unsent logs from previous session. | 120 // SENDING_OLD_LOGS, // Sending unsent logs from previous session. |
110 // This state indicates that the initial log for this session has been | 121 // This state indicates that the initial log for this session has been |
111 // successfully sent and it is now time to send any logs that were | 122 // successfully sent and it is now time to send any logs that were |
112 // saved from previous sessions. All such logs will be transmitted before | 123 // saved from previous sessions. All such logs will be transmitted before |
113 // exiting this state, and proceeding with ongoing logs from the current session | 124 // exiting this state, and proceeding with ongoing logs from the current session |
114 // (see next state). | 125 // (see next state). |
115 // | 126 // |
116 // SENDING_CURRENT_LOGS, // Sending standard current logs as they accrue. | 127 // SENDING_CURRENT_LOGS, // Sending standard current logs as they accrue. |
117 // Current logs are being accumulated. Typically every 20 minutes a log is | 128 // Current logs are being accumulated. Typically every 20 minutes a log is |
(...skipping 212 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
330 | 341 |
331 void MarkAppCleanShutdownAndCommit() { | 342 void MarkAppCleanShutdownAndCommit() { |
332 PrefService* pref = g_browser_process->local_state(); | 343 PrefService* pref = g_browser_process->local_state(); |
333 pref->SetBoolean(prefs::kStabilityExitedCleanly, true); | 344 pref->SetBoolean(prefs::kStabilityExitedCleanly, true); |
334 pref->SetInteger(prefs::kStabilityExecutionPhase, | 345 pref->SetInteger(prefs::kStabilityExecutionPhase, |
335 MetricsService::SHUTDOWN_COMPLETE); | 346 MetricsService::SHUTDOWN_COMPLETE); |
336 // Start writing right away (write happens on a different thread). | 347 // Start writing right away (write happens on a different thread). |
337 pref->CommitPendingWrite(); | 348 pref->CommitPendingWrite(); |
338 } | 349 } |
339 | 350 |
351 // Returns whether initial stability metrics should be sent in a separate log. | |
352 bool SendSeparateInitialStabilityLog() { | |
353 return base::FieldTrialList::FindFullName("UMAStability") == "SeparateLog"; | |
354 } | |
355 | |
340 } // namespace | 356 } // namespace |
341 | 357 |
342 | 358 |
343 SyntheticTrialGroup::SyntheticTrialGroup(uint32 trial, | 359 SyntheticTrialGroup::SyntheticTrialGroup(uint32 trial, |
344 uint32 group, | 360 uint32 group, |
345 base::TimeTicks start) | 361 base::TimeTicks start) |
346 : start_time(start) { | 362 : start_time(start) { |
347 id.name = trial; | 363 id.name = trial; |
348 id.group = group; | 364 id.group = group; |
349 } | 365 } |
(...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
496 local_state->ClearPref(prefs::kMetricsOngoingLogs); | 512 local_state->ClearPref(prefs::kMetricsOngoingLogs); |
497 } | 513 } |
498 | 514 |
499 MetricsService::MetricsService() | 515 MetricsService::MetricsService() |
500 : recording_active_(false), | 516 : recording_active_(false), |
501 reporting_active_(false), | 517 reporting_active_(false), |
502 test_mode_active_(false), | 518 test_mode_active_(false), |
503 state_(INITIALIZED), | 519 state_(INITIALIZED), |
504 low_entropy_source_(kLowEntropySourceNotSet), | 520 low_entropy_source_(kLowEntropySourceNotSet), |
505 idle_since_last_transmission_(false), | 521 idle_since_last_transmission_(false), |
522 session_id_(-1), | |
506 next_window_id_(0), | 523 next_window_id_(0), |
507 self_ptr_factory_(this), | 524 self_ptr_factory_(this), |
508 state_saver_factory_(this), | 525 state_saver_factory_(this), |
509 waiting_for_asynchronous_reporting_step_(false), | 526 waiting_for_asynchronous_reporting_step_(false), |
510 num_async_histogram_fetches_in_progress_(0), | 527 num_async_histogram_fetches_in_progress_(0), |
511 entropy_source_returned_(LAST_ENTROPY_NONE) { | 528 entropy_source_returned_(LAST_ENTROPY_NONE) { |
512 DCHECK(IsSingleThreaded()); | 529 DCHECK(IsSingleThreaded()); |
513 InitializeMetricsState(); | |
514 | |
515 base::Closure callback = base::Bind(&MetricsService::StartScheduledUpload, | |
516 self_ptr_factory_.GetWeakPtr()); | |
517 scheduler_.reset(new MetricsReportingScheduler(callback)); | |
518 log_manager_.set_log_serializer(new MetricsLogSerializer()); | |
519 log_manager_.set_max_ongoing_log_store_size(kUploadLogAvoidRetransmitSize); | |
520 | 530 |
521 BrowserChildProcessObserver::Add(this); | 531 BrowserChildProcessObserver::Add(this); |
522 } | 532 } |
523 | 533 |
524 MetricsService::~MetricsService() { | 534 MetricsService::~MetricsService() { |
525 DisableRecording(); | 535 DisableRecording(); |
526 | 536 |
527 BrowserChildProcessObserver::Remove(this); | 537 BrowserChildProcessObserver::Remove(this); |
528 } | 538 } |
529 | 539 |
540 void MetricsService::InitializeMetricsRecordingState( | |
541 bool reporting_will_be_enabled) { | |
542 InitializeMetricsState(reporting_will_be_enabled); | |
543 | |
544 base::Closure callback = base::Bind(&MetricsService::StartScheduledUpload, | |
545 self_ptr_factory_.GetWeakPtr()); | |
546 scheduler_.reset(new MetricsReportingScheduler(callback)); | |
547 log_manager_.set_log_serializer(new MetricsLogSerializer()); | |
548 log_manager_.set_max_ongoing_log_store_size(kUploadLogAvoidRetransmitSize); | |
549 } | |
550 | |
530 void MetricsService::Start() { | 551 void MetricsService::Start() { |
531 HandleIdleSinceLastTransmission(false); | 552 HandleIdleSinceLastTransmission(false); |
532 EnableRecording(); | 553 EnableRecording(); |
533 EnableReporting(); | 554 EnableReporting(); |
534 } | 555 } |
535 | 556 |
536 void MetricsService::StartRecordingForTests() { | 557 void MetricsService::StartRecordingForTests() { |
537 test_mode_active_ = true; | 558 test_mode_active_ = true; |
538 EnableRecording(); | 559 EnableRecording(); |
539 DisableReporting(); | 560 DisableReporting(); |
(...skipping 241 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
781 #if defined(OS_ANDROID) || defined(OS_IOS) | 802 #if defined(OS_ANDROID) || defined(OS_IOS) |
782 void MetricsService::OnAppEnterBackground() { | 803 void MetricsService::OnAppEnterBackground() { |
783 scheduler_->Stop(); | 804 scheduler_->Stop(); |
784 | 805 |
785 MarkAppCleanShutdownAndCommit(); | 806 MarkAppCleanShutdownAndCommit(); |
786 | 807 |
787 // At this point, there's no way of knowing when the process will be | 808 // At this point, there's no way of knowing when the process will be |
788 // killed, so this has to be treated similar to a shutdown, closing and | 809 // killed, so this has to be treated similar to a shutdown, closing and |
789 // persisting all logs. Unlinke a shutdown, the state is primed to be ready | 810 // persisting all logs. Unlinke a shutdown, the state is primed to be ready |
790 // to continue logging and uploading if the process does return. | 811 // to continue logging and uploading if the process does return. |
791 if (recording_active() && state_ >= INITIAL_LOG_READY) { | 812 if (recording_active() && state_ >= SENDING_INITIAL_STABILITY_LOG) { |
792 PushPendingLogsToPersistentStorage(); | 813 PushPendingLogsToPersistentStorage(); |
793 // Persisting logs closes the current log, so start recording a new log | 814 // Persisting logs closes the current log, so start recording a new log |
794 // immediately to capture any background work that might be done before the | 815 // immediately to capture any background work that might be done before the |
795 // process is killed. | 816 // process is killed. |
796 OpenNewLog(); | 817 OpenNewLog(); |
797 } | 818 } |
798 } | 819 } |
799 | 820 |
800 void MetricsService::OnAppEnterForeground() { | 821 void MetricsService::OnAppEnterForeground() { |
801 PrefService* pref = g_browser_process->local_state(); | 822 PrefService* pref = g_browser_process->local_state(); |
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
886 #endif // defined(OS_WIN) | 907 #endif // defined(OS_WIN) |
887 | 908 |
888 //------------------------------------------------------------------------------ | 909 //------------------------------------------------------------------------------ |
889 // private methods | 910 // private methods |
890 //------------------------------------------------------------------------------ | 911 //------------------------------------------------------------------------------ |
891 | 912 |
892 | 913 |
893 //------------------------------------------------------------------------------ | 914 //------------------------------------------------------------------------------ |
894 // Initialization methods | 915 // Initialization methods |
895 | 916 |
896 void MetricsService::InitializeMetricsState() { | 917 void MetricsService::InitializeMetricsState(bool reporting_will_be_enabled) { |
897 #if defined(OS_POSIX) | 918 #if defined(OS_POSIX) |
898 network_stats_server_ = chrome_common_net::kEchoTestServerLocation; | 919 network_stats_server_ = chrome_common_net::kEchoTestServerLocation; |
899 http_pipelining_test_server_ = chrome_common_net::kPipelineTestServerBaseUrl; | 920 http_pipelining_test_server_ = chrome_common_net::kPipelineTestServerBaseUrl; |
900 #else | 921 #else |
901 BrowserDistribution* dist = BrowserDistribution::GetDistribution(); | 922 BrowserDistribution* dist = BrowserDistribution::GetDistribution(); |
902 network_stats_server_ = dist->GetNetworkStatsServer(); | 923 network_stats_server_ = dist->GetNetworkStatsServer(); |
903 http_pipelining_test_server_ = dist->GetHttpPipeliningTestServer(); | 924 http_pipelining_test_server_ = dist->GetHttpPipeliningTestServer(); |
904 #endif | 925 #endif |
905 | 926 |
906 PrefService* pref = g_browser_process->local_state(); | 927 PrefService* pref = g_browser_process->local_state(); |
907 DCHECK(pref); | 928 DCHECK(pref); |
908 | 929 |
930 // TODO(asvitkine): Kill this logic when SendSeparateInitialStabilityLog() is | |
931 // is made the default behavior. | |
909 if ((pref->GetInt64(prefs::kStabilityStatsBuildTime) | 932 if ((pref->GetInt64(prefs::kStabilityStatsBuildTime) |
910 != MetricsLog::GetBuildTime()) || | 933 != MetricsLog::GetBuildTime()) || |
911 (pref->GetString(prefs::kStabilityStatsVersion) | 934 (pref->GetString(prefs::kStabilityStatsVersion) |
912 != MetricsLog::GetVersionString())) { | 935 != MetricsLog::GetVersionString())) { |
913 // This is a new version, so we don't want to confuse the stats about the | 936 // This is a new version, so we don't want to confuse the stats about the |
914 // old version with info that we upload. | 937 // old version with info that we upload. |
915 DiscardOldStabilityStats(pref); | 938 DiscardOldStabilityStats(pref); |
916 pref->SetString(prefs::kStabilityStatsVersion, | 939 pref->SetString(prefs::kStabilityStatsVersion, |
917 MetricsLog::GetVersionString()); | 940 MetricsLog::GetVersionString()); |
918 pref->SetInt64(prefs::kStabilityStatsBuildTime, | 941 pref->SetInt64(prefs::kStabilityStatsBuildTime, |
919 MetricsLog::GetBuildTime()); | 942 MetricsLog::GetBuildTime()); |
920 } | 943 } |
921 | 944 |
922 // Update session ID | 945 // Initialize uptime counters. |
946 const base::TimeDelta startup_uptime = GetIncrementalUptime(pref); | |
947 DCHECK_EQ(0, startup_uptime.InMicroseconds()); | |
Ilya Sherman
2013/12/06 06:21:26
Hmm, why does this need to happen earlier now?
Alexei Svitkine (slow)
2013/12/06 17:59:22
In a previous version of this I used startup_uptim
| |
923 session_id_ = pref->GetInteger(prefs::kMetricsSessionID); | 948 session_id_ = pref->GetInteger(prefs::kMetricsSessionID); |
924 ++session_id_; | |
925 pref->SetInteger(prefs::kMetricsSessionID, session_id_); | |
926 | |
927 // Stability bookkeeping | |
928 IncrementPrefValue(prefs::kStabilityLaunchCount); | |
929 | 949 |
930 if (!pref->GetBoolean(prefs::kStabilityExitedCleanly)) { | 950 if (!pref->GetBoolean(prefs::kStabilityExitedCleanly)) { |
931 IncrementPrefValue(prefs::kStabilityCrashCount); | 951 IncrementPrefValue(prefs::kStabilityCrashCount); |
932 // Reset flag, and wait until we call LogNeedForCleanShutdown() before | 952 // Reset flag, and wait until we call LogNeedForCleanShutdown() before |
933 // monitoring. | 953 // monitoring. |
934 pref->SetBoolean(prefs::kStabilityExitedCleanly, true); | 954 pref->SetBoolean(prefs::kStabilityExitedCleanly, true); |
935 | 955 |
936 // TODO(rtenneti): On windows, consider saving/getting execution_phase from | 956 // TODO(rtenneti): On windows, consider saving/getting execution_phase from |
937 // the registry. | 957 // the registry. |
938 int execution_phase = pref->GetInteger(prefs::kStabilityExecutionPhase); | 958 int execution_phase = pref->GetInteger(prefs::kStabilityExecutionPhase); |
939 UMA_HISTOGRAM_SPARSE_SLOWLY("Chrome.Browser.CrashedExecutionPhase", | 959 UMA_HISTOGRAM_SPARSE_SLOWLY("Chrome.Browser.CrashedExecutionPhase", |
940 execution_phase); | 960 execution_phase); |
961 | |
962 // If the previous session didn't exit cleanly, then prepare an initial | |
963 // stability log if UMA is enabled. | |
964 if (reporting_will_be_enabled && SendSeparateInitialStabilityLog()) | |
965 PrepareInitialStabilityLog(); | |
941 } | 966 } |
967 | |
968 // Update session ID. | |
969 ++session_id_; | |
970 pref->SetInteger(prefs::kMetricsSessionID, session_id_); | |
971 | |
972 // Stability bookkeeping | |
973 IncrementPrefValue(prefs::kStabilityLaunchCount); | |
974 | |
942 DCHECK_EQ(UNINITIALIZED_PHASE, execution_phase_); | 975 DCHECK_EQ(UNINITIALIZED_PHASE, execution_phase_); |
943 SetExecutionPhase(START_METRICS_RECORDING); | 976 SetExecutionPhase(START_METRICS_RECORDING); |
944 | 977 |
945 #if defined(OS_WIN) | 978 #if defined(OS_WIN) |
946 CountBrowserCrashDumpAttempts(); | 979 CountBrowserCrashDumpAttempts(); |
947 #endif // defined(OS_WIN) | 980 #endif // defined(OS_WIN) |
948 | 981 |
949 if (!pref->GetBoolean(prefs::kStabilitySessionEndCompleted)) { | 982 if (!pref->GetBoolean(prefs::kStabilitySessionEndCompleted)) { |
950 IncrementPrefValue(prefs::kStabilityIncompleteSessionEndCount); | 983 IncrementPrefValue(prefs::kStabilityIncompleteSessionEndCount); |
951 // This is marked false when we get a WM_ENDSESSION. | 984 // This is marked false when we get a WM_ENDSESSION. |
952 pref->SetBoolean(prefs::kStabilitySessionEndCompleted, true); | 985 pref->SetBoolean(prefs::kStabilitySessionEndCompleted, true); |
953 } | 986 } |
954 | 987 |
955 // Initialize uptime counters. | |
956 const base::TimeDelta startup_uptime = GetIncrementalUptime(pref); | |
957 DCHECK_EQ(0, startup_uptime.InMicroseconds()); | |
958 // For backwards compatibility, leave this intact in case Omaha is checking | 988 // For backwards compatibility, leave this intact in case Omaha is checking |
959 // them. prefs::kStabilityLastTimestampSec may also be useless now. | 989 // them. prefs::kStabilityLastTimestampSec may also be useless now. |
960 // TODO(jar): Delete these if they have no uses. | 990 // TODO(jar): Delete these if they have no uses. |
961 pref->SetInt64(prefs::kStabilityLaunchTimeSec, Time::Now().ToTimeT()); | 991 pref->SetInt64(prefs::kStabilityLaunchTimeSec, Time::Now().ToTimeT()); |
962 | 992 |
963 // Bookkeeping for the uninstall metrics. | 993 // Bookkeeping for the uninstall metrics. |
964 IncrementLongPrefsValue(prefs::kUninstallLaunchCount); | 994 IncrementLongPrefsValue(prefs::kUninstallLaunchCount); |
965 | 995 |
966 // Get stats on use of command line. | 996 // Get stats on use of command line. |
967 const CommandLine* command_line(CommandLine::ForCurrentProcess()); | 997 const CommandLine* command_line(CommandLine::ForCurrentProcess()); |
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1080 HandleIdleSinceLastTransmission(false); | 1110 HandleIdleSinceLastTransmission(false); |
1081 } | 1111 } |
1082 | 1112 |
1083 void MetricsService::ReceivedProfilerData( | 1113 void MetricsService::ReceivedProfilerData( |
1084 const tracked_objects::ProcessDataSnapshot& process_data, | 1114 const tracked_objects::ProcessDataSnapshot& process_data, |
1085 int process_type) { | 1115 int process_type) { |
1086 DCHECK_EQ(INIT_TASK_SCHEDULED, state_); | 1116 DCHECK_EQ(INIT_TASK_SCHEDULED, state_); |
1087 | 1117 |
1088 // Upon the first callback, create the initial log so that we can immediately | 1118 // Upon the first callback, create the initial log so that we can immediately |
1089 // save the profiler data. | 1119 // save the profiler data. |
1090 if (!initial_log_.get()) | 1120 if (!initial_metrics_log_.get()) |
1091 initial_log_.reset(new MetricsLog(client_id_, session_id_)); | 1121 initial_metrics_log_.reset(new MetricsLog(client_id_, session_id_)); |
1092 | 1122 |
1093 initial_log_->RecordProfilerData(process_data, process_type); | 1123 initial_metrics_log_->RecordProfilerData(process_data, process_type); |
1094 } | 1124 } |
1095 | 1125 |
1096 void MetricsService::FinishedReceivingProfilerData() { | 1126 void MetricsService::FinishedReceivingProfilerData() { |
1097 DCHECK_EQ(INIT_TASK_SCHEDULED, state_); | 1127 DCHECK_EQ(INIT_TASK_SCHEDULED, state_); |
1098 state_ = INIT_TASK_DONE; | 1128 state_ = INIT_TASK_DONE; |
1099 scheduler_->InitTaskComplete(); | 1129 scheduler_->InitTaskComplete(); |
1100 } | 1130 } |
1101 | 1131 |
1102 base::TimeDelta MetricsService::GetIncrementalUptime(PrefService* pref) { | 1132 base::TimeDelta MetricsService::GetIncrementalUptime(PrefService* pref) { |
1103 base::TimeTicks now = base::TimeTicks::Now(); | 1133 base::TimeTicks now = base::TimeTicks::Now(); |
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1240 PrefService* pref = g_browser_process->local_state(); | 1270 PrefService* pref = g_browser_process->local_state(); |
1241 current_log->RecordStabilityMetrics(GetIncrementalUptime(pref), | 1271 current_log->RecordStabilityMetrics(GetIncrementalUptime(pref), |
1242 MetricsLog::ONGOING_LOG); | 1272 MetricsLog::ONGOING_LOG); |
1243 | 1273 |
1244 RecordCurrentHistograms(); | 1274 RecordCurrentHistograms(); |
1245 | 1275 |
1246 log_manager_.FinishCurrentLog(); | 1276 log_manager_.FinishCurrentLog(); |
1247 } | 1277 } |
1248 | 1278 |
1249 void MetricsService::PushPendingLogsToPersistentStorage() { | 1279 void MetricsService::PushPendingLogsToPersistentStorage() { |
1250 if (state_ < INITIAL_LOG_READY) | 1280 if (state_ < SENDING_INITIAL_STABILITY_LOG) |
1251 return; // We didn't and still don't have time to get plugin list etc. | 1281 return; // We didn't and still don't have time to get plugin list etc. |
1252 | 1282 |
1253 if (log_manager_.has_staged_log()) { | 1283 if (log_manager_.has_staged_log()) { |
1254 // We may race here, and send second copy of the log later. | 1284 // We may race here, and send second copy of the log later. |
1255 MetricsLogManager::StoreType store_type; | 1285 MetricsLogManager::StoreType store_type; |
1256 if (current_fetch_.get()) | 1286 if (current_fetch_.get()) |
1257 store_type = MetricsLogManager::PROVISIONAL_STORE; | 1287 store_type = MetricsLogManager::PROVISIONAL_STORE; |
1258 else | 1288 else |
1259 store_type = MetricsLogManager::NORMAL_STORE; | 1289 store_type = MetricsLogManager::NORMAL_STORE; |
1260 log_manager_.StoreStagedLogAsUnsent(store_type); | 1290 log_manager_.StoreStagedLogAsUnsent(store_type); |
(...skipping 12 matching lines...) Expand all Loading... | |
1273 // Transmission of logs methods | 1303 // Transmission of logs methods |
1274 | 1304 |
1275 void MetricsService::StartSchedulerIfNecessary() { | 1305 void MetricsService::StartSchedulerIfNecessary() { |
1276 // Never schedule cutting or uploading of logs in test mode. | 1306 // Never schedule cutting or uploading of logs in test mode. |
1277 if (test_mode_active_) | 1307 if (test_mode_active_) |
1278 return; | 1308 return; |
1279 | 1309 |
1280 // Even if reporting is disabled, the scheduler is needed to trigger the | 1310 // Even if reporting is disabled, the scheduler is needed to trigger the |
1281 // creation of the initial log, which must be done in order for any logs to be | 1311 // creation of the initial log, which must be done in order for any logs to be |
1282 // persisted on shutdown or backgrounding. | 1312 // persisted on shutdown or backgrounding. |
1283 if (recording_active() && (reporting_active() || state_ < INITIAL_LOG_READY)) | 1313 if (recording_active() && |
1314 (reporting_active() || state_ < SENDING_INITIAL_STABILITY_LOG)) { | |
1284 scheduler_->Start(); | 1315 scheduler_->Start(); |
1316 } | |
1285 } | 1317 } |
1286 | 1318 |
1287 void MetricsService::StartScheduledUpload() { | 1319 void MetricsService::StartScheduledUpload() { |
1288 // If we're getting no notifications, then the log won't have much in it, and | 1320 // If we're getting no notifications, then the log won't have much in it, and |
1289 // it's possible the computer is about to go to sleep, so don't upload and | 1321 // it's possible the computer is about to go to sleep, so don't upload and |
1290 // stop the scheduler. | 1322 // stop the scheduler. |
1291 // If recording has been turned off, the scheduler doesn't need to run. | 1323 // If recording has been turned off, the scheduler doesn't need to run. |
1292 // If reporting is off, proceed if the initial log hasn't been created, since | 1324 // If reporting is off, proceed if the initial log hasn't been created, since |
1293 // that has to happen in order for logs to be cut and stored when persisting. | 1325 // that has to happen in order for logs to be cut and stored when persisting. |
1294 // TODO(stuartmorgan): Call Stop() on the schedule when reporting and/or | 1326 // TODO(stuartmorgan): Call Stop() on the schedule when reporting and/or |
1295 // recording are turned off instead of letting it fire and then aborting. | 1327 // recording are turned off instead of letting it fire and then aborting. |
1296 if (idle_since_last_transmission_ || | 1328 if (idle_since_last_transmission_ || |
1297 !recording_active() || | 1329 !recording_active() || |
1298 (!reporting_active() && state_ >= INITIAL_LOG_READY)) { | 1330 (!reporting_active() && state_ >= SENDING_INITIAL_STABILITY_LOG)) { |
1299 scheduler_->Stop(); | 1331 scheduler_->Stop(); |
1300 scheduler_->UploadCancelled(); | 1332 scheduler_->UploadCancelled(); |
1301 return; | 1333 return; |
1302 } | 1334 } |
1303 | 1335 |
1304 // If the callback was to upload an old log, but there no longer is one, | 1336 // If the callback was to upload an old log, but there no longer is one, |
1305 // just report success back to the scheduler to begin the ongoing log | 1337 // just report success back to the scheduler to begin the ongoing log |
1306 // callbacks. | 1338 // callbacks. |
1307 // TODO(stuartmorgan): Consider removing the distinction between | 1339 // TODO(stuartmorgan): Consider removing the distinction between |
1308 // SENDING_OLD_LOGS and SENDING_CURRENT_LOGS to simplify the state machine | 1340 // SENDING_OLD_LOGS and SENDING_CURRENT_LOGS to simplify the state machine |
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1427 if (!reporting_active()) { | 1459 if (!reporting_active()) { |
1428 scheduler_->Stop(); | 1460 scheduler_->Stop(); |
1429 scheduler_->UploadCancelled(); | 1461 scheduler_->UploadCancelled(); |
1430 return; | 1462 return; |
1431 } | 1463 } |
1432 | 1464 |
1433 SendStagedLog(); | 1465 SendStagedLog(); |
1434 } | 1466 } |
1435 | 1467 |
1436 void MetricsService::StageNewLog() { | 1468 void MetricsService::StageNewLog() { |
1437 if (log_manager_.has_staged_log()) | 1469 if (state_ != INIT_TASK_DONE && log_manager_.has_staged_log()) |
1438 return; | 1470 return; |
1439 | 1471 |
1440 switch (state_) { | 1472 switch (state_) { |
1441 case INITIALIZED: | 1473 case INITIALIZED: |
1442 case INIT_TASK_SCHEDULED: // We should be further along by now. | 1474 case INIT_TASK_SCHEDULED: // We should be further along by now. |
1443 NOTREACHED(); | 1475 NOTREACHED(); |
1444 return; | 1476 return; |
1445 | 1477 |
1446 case INIT_TASK_DONE: | 1478 case INIT_TASK_DONE: |
1447 PrepareInitialLog(); | 1479 if (log_manager_.has_staged_log()) { |
1448 DCHECK_EQ(INIT_TASK_DONE, state_); | 1480 // There's an initial stability log, ready to send. |
1449 log_manager_.LoadPersistedUnsentLogs(); | 1481 state_ = SENDING_INITIAL_STABILITY_LOG; |
1450 state_ = INITIAL_LOG_READY; | 1482 } else { |
1483 // TODO(asvitkine): When the field trial is removed, the |log_type| | |
1484 // arg should be removed and PrepareInitialMetricsLog() should always | |
1485 // use ONGOING_LOG. Use INITIAL_LOG only to match to the old behavior | |
1486 // when the field trial is off. | |
1487 MetricsLog::LogType log_type = SendSeparateInitialStabilityLog() ? | |
1488 MetricsLog::ONGOING_LOG : MetricsLog::INITIAL_LOG; | |
1489 PrepareInitialMetricsLog(log_type); | |
1490 state_ = SENDING_INITIAL_METRICS_LOG; | |
1491 } | |
1451 break; | 1492 break; |
1452 | 1493 |
1453 case SENDING_OLD_LOGS: | 1494 case SENDING_OLD_LOGS: |
1454 NOTREACHED(); // Shouldn't be staging a new log during old log sending. | 1495 NOTREACHED(); // Shouldn't be staging a new log during old log sending. |
1455 return; | 1496 return; |
1456 | 1497 |
1457 case SENDING_CURRENT_LOGS: | 1498 case SENDING_CURRENT_LOGS: |
1458 CloseCurrentLog(); | 1499 CloseCurrentLog(); |
1459 OpenNewLog(); | 1500 OpenNewLog(); |
1460 log_manager_.StageNextLogForUpload(); | 1501 log_manager_.StageNextLogForUpload(); |
1461 break; | 1502 break; |
1462 | 1503 |
1463 default: | 1504 default: |
1464 NOTREACHED(); | 1505 NOTREACHED(); |
1465 return; | 1506 return; |
1466 } | 1507 } |
1467 | 1508 |
1468 DCHECK(log_manager_.has_staged_log()); | 1509 DCHECK(log_manager_.has_staged_log()); |
1469 } | 1510 } |
1470 | 1511 |
1471 void MetricsService::PrepareInitialLog() { | 1512 void MetricsService::PrepareInitialStabilityLog() { |
1472 DCHECK_EQ(INIT_TASK_DONE, state_); | 1513 DCHECK_EQ(INITIALIZED, state_); |
Ilya Sherman
2013/12/06 06:21:26
nit: Please preserve some flavor of this DCHECK.
Alexei Svitkine (slow)
2013/12/06 17:59:22
Done (in PrepareInitialMetricsLog()).
| |
1473 | 1514 |
1474 DCHECK(initial_log_.get()); | 1515 scoped_ptr<MetricsLog> initial_stability_log( |
1475 initial_log_->set_hardware_class(hardware_class_); | 1516 new MetricsLog(client_id_, session_id_)); |
1517 if (!initial_stability_log->LoadSavedEnvironmentFromPrefs()) | |
1518 return; | |
1519 initial_stability_log->RecordStabilityMetrics(base::TimeDelta(), | |
1520 MetricsLog::INITIAL_LOG); | |
1521 | |
1522 log_manager_.PauseCurrentLog(); | |
1523 log_manager_.BeginLoggingWithLog(initial_stability_log.release(), | |
1524 MetricsLog::INITIAL_LOG); | |
1525 log_manager_.FinishCurrentLog(); | |
1526 log_manager_.ResumePausedLog(); | |
1527 // TODO(asvitkine): It would be nice to defer StageNextLogForUpload() until | |
1528 // the log is ready to be actually sent. This way, the initial stability log | |
1529 // can be kept around in unsent logs (and saved to prefs) in case there's a | |
1530 // crash. However, this would require loading existing unsent logs earlier - | |
1531 // which is currently done in PrepareInitialMetricsLog(). | |
Ilya Sherman
2013/12/06 06:21:26
I think it's important to get this right, i.e. to
Alexei Svitkine (slow)
2013/12/06 17:59:22
Okay - that's why I put the comment here to raise
Ilya Sherman
2013/12/07 06:51:53
Hmm. Could you possibly measure the actual perfor
Alexei Svitkine (slow)
2013/12/09 21:17:02
Agreed. I've added histograms to measure how long
Ilya Sherman
2013/12/10 06:02:10
Yeah, that sounds reasonable. Thanks! :)
| |
1532 log_manager_.StageNextLogForUpload(); | |
1533 } | |
1534 | |
1535 void MetricsService::PrepareInitialMetricsLog(MetricsLog::LogType log_type) { | |
1536 DCHECK(initial_metrics_log_.get()); | |
Ilya Sherman
2013/12/06 06:21:26
nit: No need for .get()
Alexei Svitkine (slow)
2013/12/06 17:59:22
I actually just deleted this line now. If it's nul
| |
1537 initial_metrics_log_->set_hardware_class(hardware_class_); | |
1476 | 1538 |
1477 std::vector<chrome_variations::ActiveGroupId> synthetic_trials; | 1539 std::vector<chrome_variations::ActiveGroupId> synthetic_trials; |
1478 GetCurrentSyntheticFieldTrials(&synthetic_trials); | 1540 GetCurrentSyntheticFieldTrials(&synthetic_trials); |
1479 initial_log_->RecordEnvironment(plugins_, google_update_metrics_, | 1541 initial_metrics_log_->RecordEnvironment(plugins_, google_update_metrics_, |
1480 synthetic_trials); | 1542 synthetic_trials); |
1481 PrefService* pref = g_browser_process->local_state(); | 1543 PrefService* pref = g_browser_process->local_state(); |
1482 initial_log_->RecordStabilityMetrics(GetIncrementalUptime(pref), | 1544 initial_metrics_log_->RecordStabilityMetrics(GetIncrementalUptime(pref), |
1483 MetricsLog::INITIAL_LOG); | 1545 log_type); |
1484 | 1546 |
1485 // Histograms only get written to the current log, so make the new log current | 1547 // Histograms only get written to the current log, so make the new log current |
1486 // before writing them. | 1548 // before writing them. |
1487 log_manager_.PauseCurrentLog(); | 1549 log_manager_.PauseCurrentLog(); |
1488 log_manager_.BeginLoggingWithLog(initial_log_.release(), | 1550 log_manager_.BeginLoggingWithLog(initial_metrics_log_.release(), log_type); |
1489 MetricsLog::INITIAL_LOG); | |
1490 RecordCurrentHistograms(); | 1551 RecordCurrentHistograms(); |
1491 log_manager_.FinishCurrentLog(); | 1552 log_manager_.FinishCurrentLog(); |
1492 log_manager_.ResumePausedLog(); | 1553 log_manager_.ResumePausedLog(); |
1493 | 1554 |
1494 DCHECK(!log_manager_.has_staged_log()); | 1555 DCHECK(!log_manager_.has_staged_log()); |
1495 log_manager_.StageNextLogForUpload(); | 1556 log_manager_.StageNextLogForUpload(); |
1557 log_manager_.LoadPersistedUnsentLogs(); | |
Ilya Sherman
2013/12/06 06:21:26
nit: It seems more appropriate to leave this where
Alexei Svitkine (slow)
2013/12/06 17:59:22
See my comment above about moving this call earlie
| |
1496 } | 1558 } |
1497 | 1559 |
1498 void MetricsService::StoreUnsentLogs() { | 1560 void MetricsService::StoreUnsentLogs() { |
1499 if (state_ < INITIAL_LOG_READY) | 1561 if (state_ < SENDING_INITIAL_STABILITY_LOG) |
1500 return; // We never Recalled the prior unsent logs. | 1562 return; // We never Recalled the prior unsent logs. |
1501 | 1563 |
1502 log_manager_.PersistUnsentLogs(); | 1564 log_manager_.PersistUnsentLogs(); |
1503 } | 1565 } |
1504 | 1566 |
1505 void MetricsService::SendStagedLog() { | 1567 void MetricsService::SendStagedLog() { |
1506 DCHECK(log_manager_.has_staged_log()); | 1568 DCHECK(log_manager_.has_staged_log()); |
1507 | 1569 |
1508 PrepareFetchWithStagedLog(); | 1570 PrepareFetchWithStagedLog(); |
1509 | 1571 |
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1600 discard_log = true; | 1662 discard_log = true; |
1601 } | 1663 } |
1602 | 1664 |
1603 if (upload_succeeded || discard_log) | 1665 if (upload_succeeded || discard_log) |
1604 log_manager_.DiscardStagedLog(); | 1666 log_manager_.DiscardStagedLog(); |
1605 | 1667 |
1606 waiting_for_asynchronous_reporting_step_ = false; | 1668 waiting_for_asynchronous_reporting_step_ = false; |
1607 | 1669 |
1608 if (!log_manager_.has_staged_log()) { | 1670 if (!log_manager_.has_staged_log()) { |
1609 switch (state_) { | 1671 switch (state_) { |
1610 case INITIAL_LOG_READY: | 1672 case SENDING_INITIAL_STABILITY_LOG: |
1673 PrepareInitialMetricsLog(MetricsLog::ONGOING_LOG); | |
1674 SendStagedLog(); | |
1675 state_ = SENDING_INITIAL_METRICS_LOG; | |
1676 break; | |
1677 | |
1678 case SENDING_INITIAL_METRICS_LOG: | |
1611 state_ = log_manager_.has_unsent_logs() ? SENDING_OLD_LOGS | 1679 state_ = log_manager_.has_unsent_logs() ? SENDING_OLD_LOGS |
1612 : SENDING_CURRENT_LOGS; | 1680 : SENDING_CURRENT_LOGS; |
1613 break; | 1681 break; |
1614 | 1682 |
1615 case SENDING_OLD_LOGS: | 1683 case SENDING_OLD_LOGS: |
1616 // Store the updated list to disk now that the removed log is uploaded. | 1684 // Store the updated list to disk now that the removed log is uploaded. |
1617 StoreUnsentLogs(); | 1685 StoreUnsentLogs(); |
1618 if (!log_manager_.has_unsent_logs()) | 1686 if (!log_manager_.has_unsent_logs()) |
1619 state_ = SENDING_CURRENT_LOGS; | 1687 state_ = SENDING_CURRENT_LOGS; |
1620 break; | 1688 break; |
1621 | 1689 |
1622 case SENDING_CURRENT_LOGS: | 1690 case SENDING_CURRENT_LOGS: |
1623 break; | 1691 break; |
1624 | 1692 |
1625 default: | 1693 default: |
1626 NOTREACHED(); | 1694 NOTREACHED(); |
1627 break; | 1695 break; |
1628 } | 1696 } |
1629 | 1697 |
1630 if (log_manager_.has_unsent_logs()) | 1698 if (log_manager_.has_unsent_logs()) |
1631 DCHECK_LT(state_, SENDING_CURRENT_LOGS); | 1699 DCHECK_LT(state_, SENDING_CURRENT_LOGS); |
1632 } | 1700 } |
1633 | 1701 |
1634 // Error 400 indicates a problem with the log, not with the server, so | |
1635 // don't consider that a sign that the server is in trouble. | |
1636 bool server_is_healthy = upload_succeeded || response_code == 400; | 1702 bool server_is_healthy = upload_succeeded || response_code == 400; |
1637 scheduler_->UploadFinished(server_is_healthy, log_manager_.has_unsent_logs()); | 1703 // Don't notify the scheduler that the upload is finished if we've only sent |
1704 // the initial stability log, but not yet the initial metrics log (treat the | |
1705 // two as a single unit of work as far as the scheduler is concerned). | |
1706 if (state_ != SENDING_INITIAL_METRICS_LOG) { | |
1707 // Error 400 indicates a problem with the log, not with the server, so | |
1708 // don't consider that a sign that the server is in trouble. | |
Ilya Sherman
2013/12/06 06:21:26
nit: This comment still belongs above line 1702 IM
Alexei Svitkine (slow)
2013/12/06 17:59:22
Done.
| |
1709 scheduler_->UploadFinished(server_is_healthy, | |
1710 log_manager_.has_unsent_logs()); | |
1711 } | |
1638 | 1712 |
1639 // Collect network stats if UMA upload succeeded. | 1713 // Collect network stats if UMA upload succeeded. |
1640 IOThread* io_thread = g_browser_process->io_thread(); | 1714 IOThread* io_thread = g_browser_process->io_thread(); |
1641 if (server_is_healthy && io_thread) { | 1715 if (server_is_healthy && io_thread) { |
1642 chrome_browser_net::CollectNetworkStats(network_stats_server_, io_thread); | 1716 chrome_browser_net::CollectNetworkStats(network_stats_server_, io_thread); |
1643 chrome_browser_net::CollectPipeliningCapabilityStatsOnUIThread( | 1717 chrome_browser_net::CollectPipeliningCapabilityStatsOnUIThread( |
1644 http_pipelining_test_server_, io_thread); | 1718 http_pipelining_test_server_, io_thread); |
1645 #if defined(OS_WIN) | 1719 #if defined(OS_WIN) |
1646 chrome::CollectTimeTicksStats(); | 1720 chrome::CollectTimeTicksStats(); |
1647 #endif | 1721 #endif |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1693 } | 1767 } |
1694 | 1768 |
1695 UMA_HISTOGRAM_PERCENTAGE("BrowserRenderProcessHost.ChildCrashes", | 1769 UMA_HISTOGRAM_PERCENTAGE("BrowserRenderProcessHost.ChildCrashes", |
1696 was_extension_process ? 2 : 1); | 1770 was_extension_process ? 2 : 1); |
1697 } else if (status == base::TERMINATION_STATUS_PROCESS_WAS_KILLED) { | 1771 } else if (status == base::TERMINATION_STATUS_PROCESS_WAS_KILLED) { |
1698 UMA_HISTOGRAM_PERCENTAGE("BrowserRenderProcessHost.ChildKills", | 1772 UMA_HISTOGRAM_PERCENTAGE("BrowserRenderProcessHost.ChildKills", |
1699 was_extension_process ? 2 : 1); | 1773 was_extension_process ? 2 : 1); |
1700 } else if (status == base::TERMINATION_STATUS_STILL_RUNNING) { | 1774 } else if (status == base::TERMINATION_STATUS_STILL_RUNNING) { |
1701 UMA_HISTOGRAM_PERCENTAGE("BrowserRenderProcessHost.DisconnectedAlive", | 1775 UMA_HISTOGRAM_PERCENTAGE("BrowserRenderProcessHost.DisconnectedAlive", |
1702 was_extension_process ? 2 : 1); | 1776 was_extension_process ? 2 : 1); |
1703 } | |
1704 } | 1777 } |
1778 } | |
1705 | 1779 |
1706 void MetricsService::LogRendererHang() { | 1780 void MetricsService::LogRendererHang() { |
1707 IncrementPrefValue(prefs::kStabilityRendererHangCount); | 1781 IncrementPrefValue(prefs::kStabilityRendererHangCount); |
1708 } | 1782 } |
1709 | 1783 |
1710 bool MetricsService::UmaMetricsProperlyShutdown() { | 1784 bool MetricsService::UmaMetricsProperlyShutdown() { |
1711 CHECK(clean_shutdown_status_ == CLEANLY_SHUTDOWN || | 1785 CHECK(clean_shutdown_status_ == CLEANLY_SHUTDOWN || |
1712 clean_shutdown_status_ == NEED_TO_SHUTDOWN); | 1786 clean_shutdown_status_ == NEED_TO_SHUTDOWN); |
1713 return clean_shutdown_status_ == CLEANLY_SHUTDOWN; | 1787 return clean_shutdown_status_ == CLEANLY_SHUTDOWN; |
1714 } | 1788 } |
(...skipping 217 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1932 if (local_state) { | 2006 if (local_state) { |
1933 const PrefService::Preference* uma_pref = | 2007 const PrefService::Preference* uma_pref = |
1934 local_state->FindPreference(prefs::kMetricsReportingEnabled); | 2008 local_state->FindPreference(prefs::kMetricsReportingEnabled); |
1935 if (uma_pref) { | 2009 if (uma_pref) { |
1936 bool success = uma_pref->GetValue()->GetAsBoolean(&result); | 2010 bool success = uma_pref->GetValue()->GetAsBoolean(&result); |
1937 DCHECK(success); | 2011 DCHECK(success); |
1938 } | 2012 } |
1939 } | 2013 } |
1940 return result; | 2014 return result; |
1941 } | 2015 } |
OLD | NEW |