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

Side by Side Diff: sky/framework/inspector/inspector.sky

Issue 951673003: Remove outdated examples and framework pieces (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 5 years, 10 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 | « sky/framework/inspector/indexeddb-agent.sky ('k') | sky/framework/inspector/page-agent.sky » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 <import src="/gen/mojo/public/interfaces/application/shell.mojom.sky" as="shellM ojom" />
2 <import src="/gen/mojo/public/sky/connection.sky" as="connection" />
3 <import src="/gen/mojo/public/sky/core.sky" as="core" />
4 <import src="/gen/mojo/public/sky/support.sky" as="support" />
5 <import src="/gen/mojo/services/public/sky/shell.sky" as="shell" />
6 <import src="/gen/sky/services/inspector/inspector.mojom.sky" as="inspector" />
7 <import src="console-agent.sky" as="ConsoleAgent" />
8 <import src="css-agent.sky" as="CSSAgent" />
9 <import src="dom-agent.sky" as="DOMAgent" />
10 <import src="indexeddb-agent.sky" as="IndexedDBAgent" />
11 <import src="page-agent.sky" as="PageAgent" />
12 <import src="runtime-agent.sky" as="RuntimeAgent" />
13 <import src="worker-agent.sky" as="WorkerAgent" />
14 <script>
15 class InspectorBackend extends inspector.InspectorBackend.stubClass {
16 constructor(frontend) {
17 var domAgent = new DOMAgent(this);
18 this.agents = {
19 Console: new ConsoleAgent(),
20 DOM: domAgent,
21 Page: new PageAgent(this),
22 Worker: new WorkerAgent(),
23 Runtime: new RuntimeAgent(this),
24 CSS: new CSSAgent(domAgent),
25 IndexedDB: new IndexedDBAgent(),
26 };
27 this.missingNames_ = {};
28 this.unansweredMessages_ = [];
29
30 this.IMPLEMENTED_IN_CPP = "IMPLEMENTED_IN_CPP";
31 this.ASYNC_RESPONSE = "ASYNC_RESPONSE";
32 this.MESSAGE_TIMEOUT_MS = 30000;
33
34 Object.preventExtensions(this);
35 }
36
37 onConnect() {
38 }
39
40 onDisconnect() {
41 }
42
43 logMissing_(name) {
44 if (name in this.missingNames_)
45 return;
46 this.missingNames_[name] = true;
47 console.log("InspectorBackend missing " + name);
48 }
49
50 dispatch_(descriptor, params, message_id) {
51 var parsed = descriptor.split('.');
52
53 var agentName = parsed[0];
54 var methodName = parsed[1];
55
56 // Debugger is implemented in c++.
57 if (agentName == "Debugger")
58 return this.IMPLEMENTED_IN_CPP;
59
60 if (!(agentName in this.agents)) {
61 this.logMissing_(agentName);
62 return {};
63 }
64
65 var agent = this.agents[agentName];
66
67 if (!(methodName in agent)) {
68 this.logMissing_(descriptor);
69 return {};
70 }
71
72 try {
73 return agent[methodName](params, message_id);
74 } catch(ex) {
75 console.log(descriptor + ": " + ex);
76 }
77 }
78
79 onMessage(data) {
80 var message = JSON.parse(data);
81 var result = this.dispatch_(message.method, message.params, message.id);
82 if (result === this.IMPLEMENTED_IN_CPP)
83 return;
84 this.unansweredMessages_.push(message.id);
85 // FIXME: This magic return value is kinda hacky.
86 if (result !== this.ASYNC_RESPONSE)
87 this.sendResponse(message.id, result);
88 else {
89 window.setTimeout(function() {
90 if (this.unansweredMessages_.indexOf(message.id) == -1)
91 return;
92 console.log("Error, failed to reply to message id " + message.id);
93 }.bind(this), this.MESSAGE_TIMEOUT_MS);
94 }
95 }
96
97 sendResponse(message_id, result) {
98 var messageIndex = this.unansweredMessages_.indexOf(message_id);
99 if (messageIndex != -1)
100 this.unansweredMessages_.splice(messageIndex, 1);
101 else
102 console.log("Error, responding to unknown message id " + message_id);
103 var response = {
104 id: message_id,
105 };
106 if (typeof result !== "undefined")
107 response.result = result;
108 window.frontend.sendMessage(JSON.stringify(response));
109 }
110
111 sendMessage(method, params) {
112 var message = JSON.stringify({
113 method: method,
114 params: params,
115 });
116 window.frontend.sendMessage(message);
117 }
118 }
119
120 (function() {
121 var shellHandle = internals.takeShellProxyHandle();
122 var shellProxy = connection.bindHandleToProxy(shellHandle, shellMojom.Shell);
123 var myShell = new shell.Shell(shellProxy)
124 var tracingApp = myShell.connectToApplication("mojo:sky_inspector_server");
125 tracingApp.provideService(inspector.InspectorBackend, InspectorBackend);
126
127 window.frontend = tracingApp.requestService(inspector.InspectorFrontend);
128 })();
129 </script>
OLDNEW
« no previous file with comments | « sky/framework/inspector/indexeddb-agent.sky ('k') | sky/framework/inspector/page-agent.sky » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698