Closed
Bug 1340464
Opened 9 years ago
Closed 9 years ago
Handle NetMonitorController connection state in util/client
Categories
(DevTools :: Netmonitor, defect, P1)
DevTools
Netmonitor
Tracking
(firefox54 fixed)
| Tracking | Status | |
|---|---|---|
| firefox54 | --- | fixed |
People
(Reporter: gasolin, Assigned: gasolin)
References
(Blocks 1 open bug)
Details
(Whiteboard: [netmonitor-reserve])
Attachments
(2 files)
As the first step to refactor NetMonitorController, separate netmonitor-controller.js to
- netmonitor-controller.js which contains NetMonitorController
- netmonitor-target-events.js which contains TargetEventsHandler
- netmonitor-network-events.js which contains NetworkEventsHandler
Updated•9 years ago
|
Flags: qe-verify?
Whiteboard: [netmonitor] → [netmonitor][triage]
Comment 1•9 years ago
|
||
We should take a look how debugger.html deal with its controller part. They create a uitls/client.js to handle `navigate` events [1] like we did in TargetEventsHandler. And further, they implement actions.willNavigate and actions.navigated as callback, so it makes sense for us to move _onTabNavigated out of TargetEventsHandler modules and use action instead.
Separate NetMonitorController into three modules might be useless if we're going to adopt this approach. Maybe we can implement one controller module to register all listeners and move these listener callbacks into actions.
Fred, Honza, how do you think?
[1] https://github.com/devtools-html/debugger.html/blob/0fb0d7cc56240851536874e17ef166ac21a56a11/src/utils/client.js#L16-L17
Flags: needinfo?(odvarko)
Flags: needinfo?(gasolin)
| Assignee | ||
Comment 2•9 years ago
|
||
Yes, it make sense to refer how debugger.html organize their controllers and reflect it back to netmonitor
Flags: needinfo?(gasolin)
| Assignee | ||
Comment 3•9 years ago
|
||
We can change the title once I figured out if there is a better way to organize netmonitor controller
Comment 4•9 years ago
|
||
Also, agree. Supporting the same architecture as debugger.html makes total sense. Especially if we can share code/modules...
Honza
Flags: needinfo?(odvarko)
Updated•9 years ago
|
Iteration: --- → 54.3 - Mar 6
Flags: qe-verify? → qe-verify-
Priority: -- → P1
Whiteboard: [netmonitor][triage] → [netmonitor-reserve]
| Assignee | ||
Comment 5•9 years ago
|
||
learned from debugger.html panel.js
* wrap init process as bootstrap
https://github.com/mozilla/gecko-dev/blob/master/devtools/client/debugger/new/panel.js#L24
Then we will have similar interface to reuse `devtools-launchpad`
* L10N as global variable
https://github.com/mozilla/gecko-dev/blob/master/devtools/client/debugger/new/panel.js#L14
Therefore we can remove L10N dependency from components
| Assignee | ||
Comment 6•9 years ago
|
||
* connection state is handled in util/client::onFirefoxConnect
https://github.com/devtools-html/debugger.html/blob/master/src/utils/client.js#L16
And debugger.html didn't handle disconnect (target.off) states.
* activeConsole sham is not enough for netmonitor/webconsole
https://github.com/devtools-html/devtools-core/blob/master/packages/devtools-client-adapters/src/firefox/types.js#L229
We don't have to deal with it until we are moving to github
* gNetwork.getString is defined in NetMonitorController.NetworkEventsHandler
We can remove global `gNetwork` by define `getString` in NetMonitorController directly, then we can move NetworkEventsHandler out of NetMonitorController.
| Comment hidden (mozreview-request) |
| Assignee | ||
Comment 8•9 years ago
|
||
This is part 1 patch, the part 2 will convert TargetEventsHandler to util/client
And I plan to create some following bugs:
* L10N as global variable
- dup webconsole related string into netmonitor strings, and remove webconsole strings dependency
- turn L10N as global variable and remove utils/l10n
* Move NetworkEventsHandler to utils/network-events-handler
- Move getString out of NetworkEventsHandler
- Move NetworkEventsHandler to utils/network-events-handler and is called by utils/client
Still in concern:
* wrap activeConsole(webconsoleClient) related operations into a module
- it might more make sense to use `activeConsole` instead of webconsoleClient)
Summary: Separate NetMonitorController to several files → Handle NetMonitorController connection state in util/client
| Comment hidden (mozreview-request) |
| Comment hidden (mozreview-request) |
| Comment hidden (mozreview-request) |
Comment 12•9 years ago
|
||
| mozreview-review | ||
Comment on attachment 8839850 [details]
Bug 1340464 - PART 1: wrap init process into bootstrap function;
https://reviewboard.mozilla.org/r/114434/#review116338
Looks good but, please resolve my comments/question.
R+ assuming try is green.
Honza
::: devtools/client/netmonitor/netmonitor.js:25
(Diff revision 2)
> +
> + this.hook = document.querySelector(".root");
>
> render(Provider(
> { store: window.gStore },
> NetworkMonitor({ toolbox: window.NetMonitorController._toolbox }),
Why `toolbox` prop is passed into `NetworkMonitor` component?
Also, I am seeing typo in NetworkMonitor component file.
Line 15: MonitoPanel -> MonitorPanel
(and also line 26)
Please fix it as part of this patch
Attachment #8839850 -
Flags: review?(odvarko) → review+
Comment 13•9 years ago
|
||
| mozreview-review | ||
Comment on attachment 8840356 [details]
Bug 1340464 - PART 2: handle connection state in util/client;
https://reviewboard.mozilla.org/r/114862/#review116358
One question before R+
Thanks,
Honza
::: devtools/client/netmonitor/netmonitor-controller.js:107
(Diff revision 2)
> return undefined;
> };
> await connectTimeline();
>
> - this.TargetEventsHandler.connect();
> + onFirefoxConnect(this._target);
> + this._target.on("close", this._onTabDetached);
Shouldn't handling of the `close` event be part of utils/client module?
(just like it was part of the TargetEventsHandler)
Attachment #8840356 -
Flags: review?(odvarko)
Comment 14•9 years ago
|
||
(In reply to Fred Lin [:gasolin] from comment #8)
> This is part 1 patch, the part 2 will convert TargetEventsHandler to
> util/client
>
> And I plan to create some following bugs:
>
> * L10N as global variable
> - dup webconsole related string into netmonitor strings, and remove
> webconsole strings dependency
> - turn L10N as global variable and remove utils/l10n
Yep, I like that.
>
>
> * Move NetworkEventsHandler to utils/network-events-handler
> - Move getString out of NetworkEventsHandler
> - Move NetworkEventsHandler to utils/network-events-handler and is called
> by utils/client
Also agree
> Still in concern:
>
> * wrap activeConsole(webconsoleClient) related operations into a module
> - it might more make sense to use `activeConsole` instead of
> webconsoleClient)
Can you please provide more info for this? What's the outcome here?
Honza
| Assignee | ||
Comment 15•9 years ago
|
||
> > + this._target.on("close", this._onTabDetached);
>
> Shouldn't handling of the `close` event be part of utils/client module?
> (just like it was part of the TargetEventsHandler)
The onTabDetached called shutdown NetworkController function, which is defined in NetworkController.
Define onClose into utils/client will create a cyclic require condition.
Since this is a first step to refactor NetworkController, we should more carefully add things into utils/client than keep things in NetworkController. I can see we add onClose into utils/client until NetworkController is refactored
| Assignee | ||
Comment 16•9 years ago
|
||
>
> > Still in concern:
> >
> > * wrap activeConsole(webconsoleClient) related operations into a module
> > - it might more make sense to use `activeConsole` instead of
> > webconsoleClient)
> Can you please provide more info for this? What's the outcome here?
>
That's not much value if its just a renaming.
We have use gNetwork variable (NetworkEventHandler in NetworkController) to getString from activeconsole, I think we can re-purpose `gNetwork` to expose everything NetworkController exposed to netmonitor.
During that process we can re-evaluate if that function can be provided without global variable.
Comment 17•9 years ago
|
||
| mozreview-review | ||
Comment on attachment 8840356 [details]
Bug 1340464 - PART 2: handle connection state in util/client;
https://reviewboard.mozilla.org/r/114862/#review116728
Thanks for the explanation Fred!
R+ assuming try is green.
Honza
Attachment #8840356 -
Flags: review+
Comment 18•9 years ago
|
||
| mozreview-review | ||
Comment on attachment 8840356 [details]
Bug 1340464 - PART 2: handle connection state in util/client;
https://reviewboard.mozilla.org/r/114862/#review116934
::: devtools/client/netmonitor/netmonitor-controller.js:62
(Diff revision 2)
> return this._shutdown;
> }
> this._shutdown = new Promise(async (resolve) => {
> gStore.dispatch(Actions.batchReset());
> - this.TargetEventsHandler.disconnect();
> + onFirefoxDisconnect(this._target);
> + this._target.on("close", this._onTabDetached);
listen _target.on again in shutdownNetMonitor is a mistake. It should be _target.off().
::: devtools/client/netmonitor/netmonitor-controller.js:107
(Diff revision 2)
> return undefined;
> };
> await connectTimeline();
>
> - this.TargetEventsHandler.connect();
> + onFirefoxConnect(this._target);
> + this._target.on("close", this._onTabDetached);
nit: remove _onTabDetached and use this.shutdownNetMonitor directly.
this._target.on("close", this.shutdownNetMonitor);
::: devtools/client/netmonitor/utils/client.js:17
(Diff revision 2)
> + * Called for each location change in the monitored tab.
> + *
> + * @param {String} type Packet type.
> + * @param {Object} packet Packet received from the server.
> + */
> +function _onTabNavigated(type) {
Can we separate _onTabNavigated into two methods here?
It's unnecessary to use swtich case in this case. And also remove _ prefix.
We can make function name as simple as its event name like:
tabTarget.on("navigate", navigate);
tabTarget.on("will-navigate", willNavigate);
::: devtools/client/netmonitor/utils/client.js:21
(Diff revision 2)
> + */
> +function _onTabNavigated(type) {
> + switch (type) {
> + case "will-navigate": {
> + // Reset UI.
> + if (!Services.prefs.getBoolPref("devtools.webconsole.persistlog")) {
Do you think we can export these Services.prefs from utils/prefs.js?
As a result, we can merge all preference setting into prefs.js and let PrefsHelper access settings all at once.
This could be done in another patch and get rid of Services step by step while refactoring NetmonitorController.
Comment 19•9 years ago
|
||
| mozreview-review | ||
Comment on attachment 8839850 [details]
Bug 1340464 - PART 1: wrap init process into bootstrap function;
https://reviewboard.mozilla.org/r/114434/#review116936
::: devtools/client/netmonitor/netmonitor.js:21
(Diff revision 2)
>
> - this.networkMonitor = document.querySelector(".root");
> + window.NetMonitorController = require("./netmonitor-controller").NetMonitorController;
> + window.NetMonitorController._toolbox = toolbox;
> + window.NetMonitorController._target = tabTarget;
> +
> + this.hook = document.querySelector(".root");
nit: this.root to align with class name.
::: devtools/client/netmonitor/netmonitor.js:25
(Diff revision 2)
> +
> + this.hook = document.querySelector(".root");
>
> render(Provider(
> { store: window.gStore },
> NetworkMonitor({ toolbox: window.NetMonitorController._toolbox }),
nit: toolbox prop is unused anymore, we can remove it.
| Assignee | ||
Comment 20•9 years ago
|
||
| mozreview-review-reply | ||
Comment on attachment 8840356 [details]
Bug 1340464 - PART 2: handle connection state in util/client;
https://reviewboard.mozilla.org/r/114862/#review116934
> listen _target.on again in shutdownNetMonitor is a mistake. It should be _target.off().
good catch!
> nit: remove _onTabDetached and use this.shutdownNetMonitor directly.
>
> this._target.on("close", this.shutdownNetMonitor);
there are plenty of `this` reference in shutdown function, a binding is safer for this case
> Do you think we can export these Services.prefs from utils/prefs.js?
>
> As a result, we can merge all preference setting into prefs.js and let PrefsHelper access settings all at once.
>
> This could be done in another patch and get rid of Services step by step while refactoring NetmonitorController.
The pref here take separate domain (devtools.webconsole) from utils/prefs.js(devtools.netmonitor), and currently utils/prefs.js is not for multiple PrefsHelper.
And there's no need to remove "services" require since there's already a shim for it `require("./client/shared/shim/Services");`
| Comment hidden (mozreview-request) |
| Comment hidden (mozreview-request) |
| Comment hidden (mozreview-request) |
| Comment hidden (mozreview-request) |
Comment 25•9 years ago
|
||
(In reply to Fred Lin [:gasolin] from comment #20)
> The pref here take separate domain (devtools.webconsole) from
> utils/prefs.js(devtools.netmonitor), and currently utils/prefs.js is not
> for multiple PrefsHelper.
>
> And there's no need to remove "services" require since there's already a
> shim for it `require("./client/shared/shim/Services");`
I mean we can get rid of Services if it's accessing prefs APIs, but not mean to remove all Services in codebase since there is a shim already existed.
IMO, prefs.js is created for managing all prefs relevant intents, so we should move all prefs relevant calls to prefs itself.
For separate domain like devtools.webconsole prefs, it won't be a problem. The case is pretty much like export WEBCONSOLE_L10N in utils/l10n.js, we can do it as well to export a WebconsolePrefs for managing web console domain.
| Assignee | ||
Comment 26•9 years ago
|
||
Try green, thanks
> IMO, prefs.js is created for managing all prefs relevant intents, so we
> should move all prefs relevant calls to prefs itself.
>
> For separate domain like devtools.webconsole prefs, it won't be a problem.
> The case is pretty much like export WEBCONSOLE_L10N in utils/l10n.js, we can
> do it as well to export a WebconsolePrefs for managing web console domain.
Yeah, we can do so in follow up refactor patch
Keywords: checkin-needed
Comment 27•9 years ago
|
||
Pushed by ryanvm@gmail.com:
https://hg.mozilla.org/integration/autoland/rev/44fc24be2928
PART 1: wrap init process into bootstrap function;r=Honza
https://hg.mozilla.org/integration/autoland/rev/9703c14de853
PART 2: handle connection state in util/client;r=Honza
Keywords: checkin-needed
| Assignee | ||
Comment 28•9 years ago
|
||
waitForAllRequestsFinished is only used in talo, we can remove it from NetworkController
http://searchfox.org/mozilla-central/source/testing/talos/talos/tests/devtools/addon/content/damp.js#120
And some functions (such as supportsTransferredResponseSize) not used any where, we can safely remove them from NetworkController as well.
Comment 29•9 years ago
|
||
Things we can do for refactoring netmonitor-controller.js
* Remove isConnected()
* Remove unused getCurrentActivity()
* Remove unused supportsTransferredResponseSize()
* Remove supportsPerfStats()
* Move implementation of waitForAllRequestsFinished() out of controller to damp.js
| Assignee | ||
Comment 30•9 years ago
|
||
Thanks for find out redundant functions!
`supportsPerfStats` is used in request-list-context-menu.js but others are removable
Comment 31•9 years ago
|
||
supportsPerfStats() is safe to remove since we don't detect it in summary button but only in request-list-context-menu.js...
Comment 32•9 years ago
|
||
| bugherder | ||
https://hg.mozilla.org/mozilla-central/rev/44fc24be2928
https://hg.mozilla.org/mozilla-central/rev/9703c14de853
Status: ASSIGNED → RESOLVED
Closed: 9 years ago
status-firefox54:
--- → fixed
Resolution: --- → FIXED
Target Milestone: --- → Firefox 54
Updated•7 years ago
|
Product: Firefox → DevTools
You need to log in
before you can comment on or make changes to this bug.
Description
•