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

Side by Side Diff: extensions/renderer/resources/messaging.js

Issue 1413543005: Use FrameTreeNode ID as frameId in extension APIs (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: s/:/ / Created 4 years, 11 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 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 // chrome.runtime.messaging API implementation. 5 // chrome.runtime.messaging API implementation.
6 6
7 // TODO(kalman): factor requiring chrome out of here. 7 // TODO(kalman): factor requiring chrome out of here.
8 var chrome = requireNative('chrome').GetChrome(); 8 var chrome = requireNative('chrome').GetChrome();
9 var Event = require('event_bindings').Event; 9 var Event = require('event_bindings').Event;
10 var lastError = require('lastError'); 10 var lastError = require('lastError');
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
69 PortImpl.prototype.disconnect = function() { 69 PortImpl.prototype.disconnect = function() {
70 messagingNatives.CloseChannel(this.portId_, true); 70 messagingNatives.CloseChannel(this.portId_, true);
71 this.destroy_(); 71 this.destroy_();
72 }; 72 };
73 73
74 PortImpl.prototype.destroy_ = function() { 74 PortImpl.prototype.destroy_ = function() {
75 if (this.onDestroy_) 75 if (this.onDestroy_)
76 this.onDestroy_(); 76 this.onDestroy_();
77 privates(this.onDisconnect).impl.destroy_(); 77 privates(this.onDisconnect).impl.destroy_();
78 privates(this.onMessage).impl.destroy_(); 78 privates(this.onMessage).impl.destroy_();
79 // TODO(robwu): Remove port lifetime management because it is completely
80 // handled in the browser. The renderer's only roles are
81 // 1) rejecting ports so that the browser knows that the renderer is not
82 // interested in the port (this is merely an optimization)
83 // 2) acknowledging port creations, so that the browser knows that the port
84 // was successfully created (from the perspective of the extension), but
85 // then closed for some non-fatal reason.
86 // 3) notifying the browser of explicit port closure via .disconnect().
87 // In other cases (navigations), the browser automatically cleans up the
88 // port.
79 messagingNatives.PortRelease(this.portId_); 89 messagingNatives.PortRelease(this.portId_);
80 delete ports[this.portId_]; 90 delete ports[this.portId_];
81 }; 91 };
82 92
83 // Returns true if the specified port id is in this context. This is used by 93 // Returns true if the specified port id is in this context. This is used by
84 // the C++ to avoid creating the javascript message for all the contexts that 94 // the C++ to avoid creating the javascript message for all the contexts that
85 // don't care about a particular message. 95 // don't care about a particular message.
86 function hasPort(portId) { 96 function hasPort(portId) {
87 return portId in ports; 97 return portId in ports;
88 }; 98 };
(...skipping 294 matching lines...) Expand 10 before | Expand all | Expand 10 after
383 exports.$set('Port', Port); 393 exports.$set('Port', Port);
384 exports.$set('createPort', createPort); 394 exports.$set('createPort', createPort);
385 exports.$set('sendMessageImpl', sendMessageImpl); 395 exports.$set('sendMessageImpl', sendMessageImpl);
386 exports.$set('sendMessageUpdateArguments', sendMessageUpdateArguments); 396 exports.$set('sendMessageUpdateArguments', sendMessageUpdateArguments);
387 397
388 // For C++ code to call. 398 // For C++ code to call.
389 exports.$set('hasPort', hasPort); 399 exports.$set('hasPort', hasPort);
390 exports.$set('dispatchOnConnect', dispatchOnConnect); 400 exports.$set('dispatchOnConnect', dispatchOnConnect);
391 exports.$set('dispatchOnDisconnect', dispatchOnDisconnect); 401 exports.$set('dispatchOnDisconnect', dispatchOnDisconnect);
392 exports.$set('dispatchOnMessage', dispatchOnMessage); 402 exports.$set('dispatchOnMessage', dispatchOnMessage);
OLDNEW
« content/public/browser/render_frame_host.h ('K') | « extensions/renderer/messaging_bindings.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698