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

Side by Side Diff: components/sync/driver/resources/about.js

Issue 2374913002: [USS] Show USS counters in about:sync page (Closed)
Patch Set: re-comments Created 4 years, 2 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
OLDNEW
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 cr.define('chrome.sync.about_tab', function() { 5 cr.define('chrome.sync.about_tab', function() {
6 // Contains the latest snapshot of sync about info. 6 // Contains the latest snapshot of sync about info.
7 chrome.sync.aboutInfo = {}; 7 chrome.sync.aboutInfo = {};
8 8
9 function highlightIfChanged(node, oldVal, newVal) { 9 function highlightIfChanged(node, oldVal, newVal) {
10 function clearHighlight() { 10 function clearHighlight() {
(...skipping 14 matching lines...) Expand all
25 function refreshAboutInfo(aboutInfo) { 25 function refreshAboutInfo(aboutInfo) {
26 chrome.sync.aboutInfo = aboutInfo; 26 chrome.sync.aboutInfo = aboutInfo;
27 var aboutInfoDiv = $('about-info'); 27 var aboutInfoDiv = $('about-info');
28 jstProcess(new JsEvalContext(aboutInfo), aboutInfoDiv); 28 jstProcess(new JsEvalContext(aboutInfo), aboutInfoDiv);
29 } 29 }
30 30
31 function onAboutInfoUpdatedEvent(e) { 31 function onAboutInfoUpdatedEvent(e) {
32 refreshAboutInfo(e.details); 32 refreshAboutInfo(e.details);
33 } 33 }
34 34
35 function onAboutInfoCountersUpdated(e) {
36 var details = e.details;
37
38 var modelType = details.modelType;
39 var counters = details.counters;
40
41 var type_status_array = chrome.sync.aboutInfo.type_status;
42 type_status_array.forEach(function(row) {
43 if (row.name == modelType) {
44 row.num_entries = counters.numEntriesAndTombstones;
45 row.num_live = counters.numEntries;
46 }
47 });
48 jstProcess(
49 new JsEvalContext({ type_status: type_status_array }),
50 $('typeInfo'));
51 }
52
35 /** 53 /**
36 * Helper to determine if an element is scrolled to its bottom limit. 54 * Helper to determine if an element is scrolled to its bottom limit.
37 * @param {Element} elem element to check 55 * @param {Element} elem element to check
38 * @return {boolean} true if the element is scrolled to the bottom 56 * @return {boolean} true if the element is scrolled to the bottom
39 */ 57 */
40 function isScrolledToBottom(elem) { 58 function isScrolledToBottom(elem) {
41 return elem.scrollHeight - elem.scrollTop == elem.clientHeight; 59 return elem.scrollHeight - elem.scrollTop == elem.clientHeight;
42 } 60 }
43 61
44 /** 62 /**
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
136 $('status-text').value = 'Invalid sync status dump.'; 154 $('status-text').value = 'Invalid sync status dump.';
137 return; 155 return;
138 } 156 }
139 data = data.substr(firstBrace); 157 data = data.substr(firstBrace);
140 158
141 // Remove listeners to prevent sync events from overwriting imported data. 159 // Remove listeners to prevent sync events from overwriting imported data.
142 chrome.sync.events.removeEventListener( 160 chrome.sync.events.removeEventListener(
143 'onAboutInfoUpdated', 161 'onAboutInfoUpdated',
144 onAboutInfoUpdatedEvent); 162 onAboutInfoUpdatedEvent);
145 163
164 chrome.sync.events.removeEventListener(
165 'onCountersUpdated',
166 onAboutInfoCountersUpdated);
167
146 var aboutInfo = JSON.parse(data); 168 var aboutInfo = JSON.parse(data);
147 refreshAboutInfo(aboutInfo); 169 refreshAboutInfo(aboutInfo);
148 }); 170 });
149 } 171 }
150 172
151 /** 173 /**
152 * Toggles the given traffic event entry div's "expanded" state. 174 * Toggles the given traffic event entry div's "expanded" state.
153 * @param {MouseEvent} e the click event that triggered the toggle. 175 * @param {MouseEvent} e the click event that triggered the toggle.
154 */ 176 */
155 function expandListener(e) { 177 function expandListener(e) {
156 e.target.classList.toggle('traffic-event-entry-expanded'); 178 e.target.classList.toggle('traffic-event-entry-expanded');
157 } 179 }
158 180
159 /** 181 /**
160 * Attaches a listener to the given traffic event entry div. 182 * Attaches a listener to the given traffic event entry div.
161 * @param {HTMLElement} element the element to attach the listener to. 183 * @param {HTMLElement} element the element to attach the listener to.
162 */ 184 */
163 function addExpandListener(element) { 185 function addExpandListener(element) {
164 element.addEventListener('click', expandListener, false); 186 element.addEventListener('click', expandListener, false);
165 } 187 }
166 188
167 function onLoad() { 189 function onLoad() {
168 initStatusDumpButton(); 190 initStatusDumpButton();
169 initProtocolEventLog(); 191 initProtocolEventLog();
170 192
171 chrome.sync.events.addEventListener( 193 chrome.sync.events.addEventListener(
172 'onAboutInfoUpdated', 194 'onAboutInfoUpdated',
173 onAboutInfoUpdatedEvent); 195 onAboutInfoUpdatedEvent);
174 196
197 chrome.sync.events.addEventListener(
198 'onCountersUpdated',
199 onAboutInfoCountersUpdated);
200
175 // Register to receive a stream of event notifications. 201 // Register to receive a stream of event notifications.
176 chrome.sync.registerForEvents(); 202 chrome.sync.registerForEvents();
177 203
178 // Request an about info update event to initialize the page. 204 // Request an about info update event to initialize the page.
179 chrome.sync.requestUpdatedAboutInfo(); 205 chrome.sync.requestUpdatedAboutInfo();
180 } 206 }
181 207
182 return { 208 return {
183 onLoad: onLoad, 209 onLoad: onLoad,
184 addExpandListener: addExpandListener, 210 addExpandListener: addExpandListener,
185 highlightIfChanged: highlightIfChanged 211 highlightIfChanged: highlightIfChanged
186 }; 212 };
187 }); 213 });
188 214
189 document.addEventListener( 215 document.addEventListener(
190 'DOMContentLoaded', chrome.sync.about_tab.onLoad, false); 216 'DOMContentLoaded', chrome.sync.about_tab.onLoad, false);
OLDNEW
« no previous file with comments | « components/sync/driver/proxy_data_type_controller.cc ('k') | components/sync/driver/sync_frontend.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698