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

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

Issue 2872023002: [Sync] Add a simple UI to sync-internals to create UserEvents. (Closed)
Patch Set: Rebase Created 3 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 | « components/sync/driver/about_sync_util.cc ('k') | components/sync/driver/resources/index.html » ('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 (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 // require cr.js 5 // require cr.js
6 // require cr/event_target.js 6 // require cr/event_target.js
7 // require cr/util.js 7 // require cr/util.js
8 8
9 cr.define('chrome.sync', function() { 9 cr.define('chrome.sync', function() {
10 'use strict'; 10 'use strict';
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
71 71
72 /** 72 /**
73 * Asks the browser to send us the list of registered types. Should result 73 * Asks the browser to send us the list of registered types. Should result
74 * in an onReceivedListOfTypes event being emitted. 74 * in an onReceivedListOfTypes event being emitted.
75 */ 75 */
76 var requestListOfTypes = function() { 76 var requestListOfTypes = function() {
77 chrome.send('requestListOfTypes'); 77 chrome.send('requestListOfTypes');
78 }; 78 };
79 79
80 /** 80 /**
81 * Asks the browser if we should show the User Events tab or not.
82 */
83 var requestUserEventsVisibility = function() {
84 chrome.send('requestUserEventsVisibility');
85 };
86
87 /**
88 * Sends data to construct a user event that should be committed.
89 *
90 * @param {string} eventTimeUsec Timestamp for the new event.
91 * @param {string} navigationId Timestamp of linked sessions navigation.
92 */
93 var writeUserEvent = function(eventTimeUsec, navigationId) {
94 chrome.send('writeUserEvent', [eventTimeUsec, navigationId]);
95 };
96
97 /**
81 * Counter to uniquely identify requests while they're in progress. 98 * Counter to uniquely identify requests while they're in progress.
82 * Used in the implementation of GetAllNodes. 99 * Used in the implementation of GetAllNodes.
83 */ 100 */
84 var requestId = 0; 101 var requestId = 0;
85 102
86 /** 103 /**
87 * A map from counter values to asynchronous request callbacks. 104 * A map from counter values to asynchronous request callbacks.
88 * Used in the implementation of GetAllNodes. 105 * Used in the implementation of GetAllNodes.
89 * @type {{number: !Function}} 106 * @type {{number: !Function}}
90 */ 107 */
91 var requestCallbacks = {}; 108 var requestCallbacks = {};
92 109
93 /** 110 /**
94 * Asks the browser to send us a copy of all existing sync nodes. 111 * Asks the browser to send us a copy of all existing sync nodes.
95 * Will eventually invoke the given callback with the results. 112 * Will eventually invoke the given callback with the results.
96 * 113 *
97 * @param {function(!Object)} callback The function to call with the response. 114 * @param {function(!Object)} callback The function to call with the response.
98 */ 115 */
99 var getAllNodes = function(callback) { 116 var getAllNodes = function(callback) {
100 requestId++; 117 requestId++;
101 requestCallbacks[requestId] = callback; 118 requestCallbacks[requestId] = callback;
102 chrome.send('getAllNodes', [requestId]); 119 chrome.send('getAllNodes', [requestId]);
103 }; 120 };
104 121
105 /** 122 /**
106 * Called from C++ with the response to a getAllNodes request. 123 * Called from C++ with the response to a getAllNodes request.
124 *
107 * @param {number} id The requestId passed in with the request. 125 * @param {number} id The requestId passed in with the request.
108 * @param {Object} response The response to the request. 126 * @param {Object} response The response to the request.
109 */ 127 */
110 var getAllNodesCallback = function(id, response) { 128 var getAllNodesCallback = function(id, response) {
111 requestCallbacks[id](response); 129 requestCallbacks[id](response);
112 requestCallbacks[id] = undefined; 130 requestCallbacks[id] = undefined;
113 }; 131 };
114 132
115 return { 133 return {
116 makeTimer: makeTimer, 134 makeTimer: makeTimer,
117 dispatchEvent: dispatchEvent, 135 dispatchEvent: dispatchEvent,
118 events: new cr.EventTarget(), 136 events: new cr.EventTarget(),
119 getAllNodes: getAllNodes, 137 getAllNodes: getAllNodes,
120 getAllNodesCallback: getAllNodesCallback, 138 getAllNodesCallback: getAllNodesCallback,
121 registerForEvents: registerForEvents, 139 registerForEvents: registerForEvents,
122 registerForPerTypeCounters: registerForPerTypeCounters, 140 registerForPerTypeCounters: registerForPerTypeCounters,
123 requestUpdatedAboutInfo: requestUpdatedAboutInfo, 141 requestUpdatedAboutInfo: requestUpdatedAboutInfo,
124 requestListOfTypes: requestListOfTypes, 142 requestListOfTypes: requestListOfTypes,
143 requestUserEventsVisibility: requestUserEventsVisibility,
144 writeUserEvent: writeUserEvent,
125 }; 145 };
126 }); 146 });
OLDNEW
« no previous file with comments | « components/sync/driver/about_sync_util.cc ('k') | components/sync/driver/resources/index.html » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698