Re: [chromium-dev] extension load order

196 views
Skip to first unread message

Alon Bar-Lev

unread,
May 13, 2012, 12:33:36 PM5/13/12
to PhistucK, chromium-...@chromium.org
Oh!
Thanks....
Sorry did not know about chromium-extensions.

Hello All,

I have the following problem:

>> >> I have two extensions, one that needs to use the other B uses A.
>> >>
>> >> How do I make sure that that A is loaded before B?
>> >>
>> >> Should background page of B just loop and wait and retry connection?

I also made some solution described bellow.

Anyone has a better solution?

Regards,
Alon Bar-Lev.

On Sun, May 13, 2012 at 7:29 PM, PhistucK <phis...@gmail.com> wrote:
> That is a good way to tell, because background pages are supposed to load
> (or at least start loading) before all of the tabs start to load.
> I am not sure about the efficiency of such approach, but it seems fine to me
> barring other ideas.
>
> Oh and this discussion should really move to chromium-extensions.
>
> ☆PhistucK
>
>
>
> On Sun, May 13, 2012 at 3:28 PM, Alon Bar-Lev <alon....@gmail.com> wrote:
>>
>> Thank you for your response!
>>
>> Well, I don't want to add extra privilege to the extension...
>> And there is no proper timer for background pages[1].
>>
>> So I done the following monitoring tab update at start:
>> ---
>> function ExtWait(extId, maxWait, callback) {
>>        this._extId = extId;
>>        this._maxWait = maxWait;
>>        this._callback = callback;
>>        this._loadTime = new Date();
>>        this._issued = false;
>>        this._tabs_onUpdated_bound = this._tabs_onUpdated.bind(this);
>>        chrome.tabs.onUpdated.addListener(this._tabs_onUpdated_bound);
>> }
>>
>> ExtWait.prototype = {
>>        _tabs_onUpdated: function(tabId, changeInfo, tab) {
>>                var me = this;
>>                chrome.extension.sendRequest(
>>                        this._extId,
>>                        {action: "ping"},
>>                        function(response) {
>>                                if (response) {
>>
>> chrome.tabs.onUpdated.removeListener(me._tabs_onUpdated_bound)
>>                                        if (!this._issued) {
>>                                                this._issued = true;
>>                                                me._callback();
>>                                        }
>>                                }
>>                                else {
>>                                        if ((new Date()).getTime() -
>> me._loadTime.getTime() > me._maxWait) {
>>
>> chrome.tabs.onUpdated.removeListener(me._tabs_onUpdated_bound)
>>                                        }
>>                                }
>>                        }
>>                );
>>        }
>> };
>> ---
>>
>> [1] http://code.google.com/p/chromium/issues/detail?id=81758
>>
>> On Sun, May 13, 2012 at 12:56 PM, PhistucK <phis...@gmail.com> wrote:
>> > I think you will have to resort to the retry loop approach, but, first,
>> > you
>> > should know whether the extension is actually installed, I guess, for
>> > which
>> > you can use the management extension API.
>> >
>> > ☆PhistucK
>> >
>> >
>> >
>> > On Sun, May 13, 2012 at 12:03 PM, Alon Bar-Lev <alon....@gmail.com>
>> > wrote:
>> >>
>> >> Hello,
>> >>
>> >> I could not find answer to this anywhere...
>> >>
>> >> I have two extensions, one that needs to use the other B uses A.
>> >>
>> >> How do I make sure that that A is loaded before B?
>> >>
>> >> Should background page of B just loop and wait and retry connection?
>> >>
>> >> Or... I am looking for an event of the browser in which it is safe to
>> >> say that all extensions loaded.
>> >>
>> >> Thanks!
>> >> Alon.
>> >>
>> >> --
>> >> Chromium Developers mailing list: chromi...@chromium.org
>> >> View archives, change email options, or unsubscribe:
>> >>    http://groups.google.com/a/chromium.org/group/chromium-dev
>> >
>> >
>
>

Devin

unread,
May 14, 2012, 10:02:22 PM5/14/12
to Chromium-extensions
Chrome's V8 Javascript engine is so fast I've never felt bad about
looping/polling for things. Go ahead!


On May 13, 9:33 am, Alon Bar-Lev <alon.bar...@gmail.com> wrote:
> Oh!
> Thanks....
> Sorry did not know about  chromium-extensions.
>
> Hello All,
>
> I have the following problem:
>
> >> >> I have two extensions, one that needs to use the other B uses A.
>
> >> >> How do I make sure that that A is loaded before B?
>
> >> >> Should background page of B just loop and wait and retry connection?
>
> I also made some solution described bellow.
>
> Anyone has a better solution?
>
> Regards,
> Alon Bar-Lev.
>
>
>
>
>
>
>
> On Sun, May 13, 2012 at 7:29 PM, PhistucK <phist...@gmail.com> wrote:
> > That is a good way to tell, because background pages are supposed to load
> > (or at least start loading) before all of the tabs start to load.
> > I am not sure about the efficiency of such approach, but it seems fine to me
> > barring other ideas.
>
> > Oh and this discussion should really move to chromium-extensions.
>
> > ☆PhistucK
>
> >> On Sun, May 13, 2012 at 12:56 PM, PhistucK <phist...@gmail.com> wrote:
> >> > I think you will have to resort to the retry loop approach, but, first,
> >> > you
> >> > should know whether the extension is actually installed, I guess, for
> >> > which
> >> > you can use the management extension API.
>
> >> > ☆PhistucK
>
> >> > On Sun, May 13, 2012 at 12:03 PM, Alon Bar-Lev <alon.bar...@gmail.com>
> >> > wrote:
>
> >> >> Hello,
>
> >> >> I could not find answer to this anywhere...
>
> >> >> I have two extensions, one that needs to use the other B uses A.
>
> >> >> How do I make sure that that A is loaded before B?
>
> >> >> Should background page of B just loop and wait and retry connection?
>
> >> >> Or... I am looking for an event of the browser in which it is safe to
> >> >> say that all extensions loaded.
>
> >> >> Thanks!
> >> >> Alon.
>
> >> >> --
> >> >> Chromium Developers mailing list: chromium-...@chromium.org

Alon Bar-Lev

unread,
May 15, 2012, 2:46:45 AM5/15/12
to Devin, Chromium-extensions
Hmmmm....
Thanks!
But I would like to avoid that.
> --
> You received this message because you are subscribed to the Google Groups "Chromium-extensions" group.
> To post to this group, send email to chromium-...@chromium.org.
> To unsubscribe from this group, send email to chromium-extens...@chromium.org.
> For more options, visit this group at http://groups.google.com/a/chromium.org/group/chromium-extensions/?hl=en.
>

Antony Sargent

unread,
May 17, 2012, 1:04:15 PM5/17/12
to Alon Bar-Lev, Devin, Chromium-extensions
I don't think we provide any guarantees about extension load order. You could file a feature request at http://new.crbug.com  to have us implement an event that fires when all extensions are loaded.

For now, one thing you might try is to have each extension first register a listener for chrome.extension.onRequest, and also send a "ping" message to the other extension. One of the ping messages may or may not get lost, but once one of your listeners fires with a message from the other extension you know that both extensions are now up and running.

Alon Bar-Lev

unread,
May 17, 2012, 1:50:10 PM5/17/12
to Antony Sargent, Devin, Chromium-extensions
On Thu, May 17, 2012 at 8:07 PM, Alon Bar-Lev <alon....@gmail.com> wrote:
> On Thu, May 17, 2012 at 8:04 PM, Antony Sargent <asar...@chromium.org> wrote:
>>
>> I don't think we provide any guarantees about extension load order. You
>> could file a feature request at http://new.crbug.com  to have us implement
>> an event that fires when all extensions are loaded.
>
> Thank you, I will.

https://code.google.com/p/chromium/issues/detail?id=128573

>
>>
>> For now, one thing you might try is to have each extension first register
>> a listener for chrome.extension.onRequest, and also send a "ping" message to
>> the other extension. One of the ping messages may or may not get lost, but
>> once one of your listeners fires with a message from the other extension you
>> know that both extensions are now up and running.
>
> This is what I've done bellow...
> Although the challenge is how to perform the loop without consuming 100$ CPU...
> I solved this using the tabUpdate event... Maybe there is better method.
>
> Regards,
> Alon.

Alon Bar-Lev

unread,
May 17, 2012, 1:07:42 PM5/17/12
to Antony Sargent, Devin, Chromium-extensions
On Thu, May 17, 2012 at 8:04 PM, Antony Sargent <asar...@chromium.org> wrote:
>
> I don't think we provide any guarantees about extension load order. You
> could file a feature request at http://new.crbug.com  to have us implement
> an event that fires when all extensions are loaded.

Thank you, I will.

>
> For now, one thing you might try is to have each extension first register
> a listener for chrome.extension.onRequest, and also send a "ping" message to
> the other extension. One of the ping messages may or may not get lost, but
> once one of your listeners fires with a message from the other extension you
> know that both extensions are now up and running.

This is what I've done bellow...
Although the challenge is how to perform the loop without consuming 100$ CPU...
I solved this using the tabUpdate event... Maybe there is better method.

Regards,
Alon.

>
Reply all
Reply to author
Forward
0 new messages