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 "chrome/browser/ui/webui/gcm_internals_ui.h" | 5 #include "chrome/browser/ui/webui/gcm_internals_ui.h" |
6 | 6 |
7 #include <vector> | 7 #include <vector> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/bind_helpers.h" | 10 #include "base/bind_helpers.h" |
(...skipping 10 matching lines...) Expand all Loading... |
21 #include "content/public/browser/web_ui.h" | 21 #include "content/public/browser/web_ui.h" |
22 #include "content/public/browser/web_ui_controller.h" | 22 #include "content/public/browser/web_ui_controller.h" |
23 #include "content/public/browser/web_ui_data_source.h" | 23 #include "content/public/browser/web_ui_data_source.h" |
24 #include "content/public/browser/web_ui_message_handler.h" | 24 #include "content/public/browser/web_ui_message_handler.h" |
25 #include "google_apis/gcm/gcm_client.h" | 25 #include "google_apis/gcm/gcm_client.h" |
26 #include "grit/browser_resources.h" | 26 #include "grit/browser_resources.h" |
27 | 27 |
28 namespace { | 28 namespace { |
29 | 29 |
30 void SetCheckinInfo( | 30 void SetCheckinInfo( |
31 const std::vector<gcm::GCMStatsRecorder::CheckinActivity>& checkins, | 31 const std::vector<gcm::CheckinActivity>& checkins, |
32 base::ListValue* checkin_info) { | 32 base::ListValue* checkin_info) { |
33 std::vector<gcm::GCMStatsRecorder::CheckinActivity>::const_iterator it = | 33 std::vector<gcm::CheckinActivity>::const_iterator it = checkins.begin(); |
34 checkins.begin(); | |
35 for (; it < checkins.end(); ++it) { | 34 for (; it < checkins.end(); ++it) { |
36 base::ListValue* row = new base::ListValue(); | 35 base::ListValue* row = new base::ListValue(); |
37 checkin_info->Append(row); | 36 checkin_info->Append(row); |
38 | 37 |
39 row->AppendDouble(it->time.ToJsTime()); | 38 row->AppendDouble(it->time.ToJsTime()); |
40 row->AppendString(it->event); | 39 row->AppendString(it->event); |
41 row->AppendString(it->details); | 40 row->AppendString(it->details); |
42 } | 41 } |
43 } | 42 } |
44 | 43 |
45 void SetConnectionInfo( | 44 void SetConnectionInfo( |
46 const std::vector<gcm::GCMStatsRecorder::ConnectionActivity>& connections, | 45 const std::vector<gcm::ConnectionActivity>& connections, |
47 base::ListValue* connection_info) { | 46 base::ListValue* connection_info) { |
48 std::vector<gcm::GCMStatsRecorder::ConnectionActivity>::const_iterator it = | 47 std::vector<gcm::ConnectionActivity>::const_iterator it = connections.begin(); |
49 connections.begin(); | |
50 for (; it < connections.end(); ++it) { | 48 for (; it < connections.end(); ++it) { |
51 base::ListValue* row = new base::ListValue(); | 49 base::ListValue* row = new base::ListValue(); |
52 connection_info->Append(row); | 50 connection_info->Append(row); |
53 | 51 |
54 row->AppendDouble(it->time.ToJsTime()); | 52 row->AppendDouble(it->time.ToJsTime()); |
55 row->AppendString(it->event); | 53 row->AppendString(it->event); |
56 row->AppendString(it->details); | 54 row->AppendString(it->details); |
57 } | 55 } |
58 } | 56 } |
59 | 57 |
60 void SetRegistrationInfo( | 58 void SetRegistrationInfo( |
61 const std::vector<gcm::GCMStatsRecorder::RegistrationActivity>& | 59 const std::vector<gcm::RegistrationActivity>& registrations, |
62 registrations, | |
63 base::ListValue* registration_info) { | 60 base::ListValue* registration_info) { |
64 std::vector<gcm::GCMStatsRecorder::RegistrationActivity>::const_iterator it = | 61 std::vector<gcm::RegistrationActivity>::const_iterator it = |
65 registrations.begin(); | 62 registrations.begin(); |
66 for (; it < registrations.end(); ++it) { | 63 for (; it < registrations.end(); ++it) { |
67 base::ListValue* row = new base::ListValue(); | 64 base::ListValue* row = new base::ListValue(); |
68 registration_info->Append(row); | 65 registration_info->Append(row); |
69 | 66 |
70 row->AppendDouble(it->time.ToJsTime()); | 67 row->AppendDouble(it->time.ToJsTime()); |
71 row->AppendString(it->app_id); | 68 row->AppendString(it->app_id); |
72 row->AppendString(it->sender_ids); | 69 row->AppendString(it->sender_ids); |
73 row->AppendString(it->event); | 70 row->AppendString(it->event); |
74 row->AppendString(it->details); | 71 row->AppendString(it->details); |
75 } | 72 } |
76 } | 73 } |
77 | 74 |
78 void SetReceivingInfo( | 75 void SetReceivingInfo( |
79 const std::vector<gcm::GCMStatsRecorder::ReceivingActivity>& receives, | 76 const std::vector<gcm::ReceivingActivity>& receives, |
80 base::ListValue* receive_info) { | 77 base::ListValue* receive_info) { |
81 std::vector<gcm::GCMStatsRecorder::ReceivingActivity>::const_iterator it = | 78 std::vector<gcm::ReceivingActivity>::const_iterator it = receives.begin(); |
82 receives.begin(); | |
83 for (; it < receives.end(); ++it) { | 79 for (; it < receives.end(); ++it) { |
84 base::ListValue* row = new base::ListValue(); | 80 base::ListValue* row = new base::ListValue(); |
85 receive_info->Append(row); | 81 receive_info->Append(row); |
86 | 82 |
87 row->AppendDouble(it->time.ToJsTime()); | 83 row->AppendDouble(it->time.ToJsTime()); |
88 row->AppendString(it->app_id); | 84 row->AppendString(it->app_id); |
89 row->AppendString(it->from); | 85 row->AppendString(it->from); |
90 row->AppendString(base::StringPrintf("%d", it->message_byte_size)); | 86 row->AppendString(base::StringPrintf("%d", it->message_byte_size)); |
91 row->AppendString(it->event); | 87 row->AppendString(it->event); |
92 row->AppendString(it->details); | 88 row->AppendString(it->details); |
93 } | 89 } |
94 } | 90 } |
95 | 91 |
96 void SetSendingInfo( | 92 void SetSendingInfo( |
97 const std::vector<gcm::GCMStatsRecorder::SendingActivity>& sends, | 93 const std::vector<gcm::SendingActivity>& sends, |
98 base::ListValue* send_info) { | 94 base::ListValue* send_info) { |
99 std::vector<gcm::GCMStatsRecorder::SendingActivity>::const_iterator it = | 95 std::vector<gcm::SendingActivity>::const_iterator it = sends.begin(); |
100 sends.begin(); | |
101 for (; it < sends.end(); ++it) { | 96 for (; it < sends.end(); ++it) { |
102 base::ListValue* row = new base::ListValue(); | 97 base::ListValue* row = new base::ListValue(); |
103 send_info->Append(row); | 98 send_info->Append(row); |
104 | 99 |
105 row->AppendDouble(it->time.ToJsTime()); | 100 row->AppendDouble(it->time.ToJsTime()); |
106 row->AppendString(it->app_id); | 101 row->AppendString(it->app_id); |
107 row->AppendString(it->receiver_id); | 102 row->AppendString(it->receiver_id); |
108 row->AppendString(it->message_id); | 103 row->AppendString(it->message_id); |
109 row->AppendString(it->event); | 104 row->AppendString(it->event); |
110 row->AppendString(it->details); | 105 row->AppendString(it->details); |
(...skipping 202 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
313 html_source->AddResourcePath("gcm_internals.js", IDR_GCM_INTERNALS_JS); | 308 html_source->AddResourcePath("gcm_internals.js", IDR_GCM_INTERNALS_JS); |
314 html_source->SetDefaultResource(IDR_GCM_INTERNALS_HTML); | 309 html_source->SetDefaultResource(IDR_GCM_INTERNALS_HTML); |
315 | 310 |
316 Profile* profile = Profile::FromWebUI(web_ui); | 311 Profile* profile = Profile::FromWebUI(web_ui); |
317 content::WebUIDataSource::Add(profile, html_source); | 312 content::WebUIDataSource::Add(profile, html_source); |
318 | 313 |
319 web_ui->AddMessageHandler(new GcmInternalsUIMessageHandler()); | 314 web_ui->AddMessageHandler(new GcmInternalsUIMessageHandler()); |
320 } | 315 } |
321 | 316 |
322 GCMInternalsUI::~GCMInternalsUI() {} | 317 GCMInternalsUI::~GCMInternalsUI() {} |
OLD | NEW |