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

Issue 9791011: Add experimental.alarms API to allow lazy background pages to (Closed)

Created:
8 years, 9 months ago by Matt Perry
Modified:
8 years, 9 months ago
CC:
chromium-reviews, darin-cc_chromium.org, mihaip+watch_chromium.org, brettw-cc_chromium.org
Visibility:
Public.

Description

Add experimental.alarms API to allow lazy background pages to wake themselves up after a timeout. BUG=81758 TEST=no Committed: https://src.chromium.org/viewvc/chrome?view=rev&revision=129495

Patch Set 1 #

Patch Set 2 : oops #

Patch Set 3 : . #

Patch Set 4 : .. #

Patch Set 5 : alarms_api #

Patch Set 6 : docgen #

Patch Set 7 : base files missing? #

Patch Set 8 : set/get/clear #

Patch Set 9 : docs #

Total comments: 6

Patch Set 10 : review fixes #

Patch Set 11 : sync #

Total comments: 13

Patch Set 12 : review #

Patch Set 13 : . #

Unified diffs Side-by-side diffs Delta from patch set Stats (+290 lines, -13 lines) Patch
A chrome/browser/extensions/api/alarms/alarms_api.h View 1 2 3 4 5 6 7 8 9 1 chunk +41 lines, -0 lines 0 comments Download
A chrome/browser/extensions/api/alarms/alarms_api.cc View 1 2 3 4 5 6 7 8 9 10 11 12 1 chunk +73 lines, -0 lines 0 comments Download
M chrome/browser/extensions/extension_event_router.cc View 1 3 chunks +2 lines, -4 lines 0 comments Download
M chrome/browser/extensions/extension_function_registry.cc View 1 2 3 4 5 6 7 8 9 2 chunks +8 lines, -0 lines 0 comments Download
M chrome/browser/extensions/extension_module.h View 1 2 3 4 2 chunks +8 lines, -0 lines 0 comments Download
M chrome/browser/extensions/extension_module.cc View 1 2 3 4 1 chunk +22 lines, -0 lines 0 comments Download
M chrome/browser/extensions/lazy_background_task_queue.cc View 1 2 3 2 chunks +2 lines, -3 lines 0 comments Download
M chrome/chrome_browser_extensions.gypi View 1 2 3 4 1 chunk +2 lines, -0 lines 0 comments Download
M chrome/common/common_resources.grd View 1 2 3 4 5 6 7 8 9 10 11 1 chunk +1 line, -0 lines 0 comments Download
M chrome/common/extensions/api/api.gyp View 1 2 3 4 5 6 7 8 9 1 chunk +1 line, -0 lines 0 comments Download
A chrome/common/extensions/api/experimental.alarms.json View 1 2 3 4 5 6 7 8 9 10 11 1 chunk +116 lines, -0 lines 0 comments Download
M chrome/common/extensions/api/experimental.extension.json View 1 2 3 4 1 chunk +1 line, -4 lines 0 comments Download
M chrome/common/extensions/api/extension_api.cc View 1 2 3 4 5 6 7 8 9 10 11 1 chunk +2 lines, -0 lines 0 comments Download
M chrome/common/extensions/docs/experimental.html View 1 2 3 4 5 1 chunk +1 line, -0 lines 0 comments Download
M chrome/common/extensions/docs/js/api_page_generator.js View 1 2 3 4 5 6 7 8 9 10 11 1 chunk +1 line, -0 lines 0 comments Download
M chrome/common/extensions/docs/samples.json View 1 2 3 4 5 6 7 8 2 chunks +7 lines, -1 line 0 comments Download
M chrome/renderer/extensions/schema_generated_bindings.cc View 1 2 3 4 5 6 7 8 9 10 11 1 chunk +2 lines, -1 line 0 comments Download

Messages

Total messages: 11 (0 generated)
Matt Perry
8 years, 9 months ago (2012-03-27 00:18:19 UTC) #1
Aaron Boodman
Sweet. Couple API issues before I look at the code: Can we call this 'alarm' ...
8 years, 9 months ago (2012-03-27 00:40:39 UTC) #2
Matt Perry
On 2012/03/27 00:40:39, Aaron Boodman wrote: > Sweet. Couple API issues before I look at ...
8 years, 9 months ago (2012-03-27 01:05:14 UTC) #3
Matt Perry
OK, I moved it to a new namespace. I didn't add the RUD part of ...
8 years, 9 months ago (2012-03-27 01:42:45 UTC) #4
Matt Perry
OK, I moved it to a new namespace. I didn't add the RUD part of ...
8 years, 9 months ago (2012-03-27 01:42:46 UTC) #5
Matt Perry
OK, added stubs for get/getAll/clear/clearAll. I think I'll defer the implementation of those for a ...
8 years, 9 months ago (2012-03-27 22:59:39 UTC) #6
Aaron Boodman
http://codereview.chromium.org/9791011/diff/9001/chrome/browser/extensions/api/alarms/alarms_api.cc File chrome/browser/extensions/api/alarms/alarms_api.cc (right): http://codereview.chromium.org/9791011/diff/9001/chrome/browser/extensions/api/alarms/alarms_api.cc#newcode36 chrome/browser/extensions/api/alarms/alarms_api.cc:36: DictionaryValue* details; Please use the JSON Schema compiler for ...
8 years, 9 months ago (2012-03-27 23:34:01 UTC) #7
Matt Perry
http://codereview.chromium.org/9791011/diff/9001/chrome/browser/extensions/api/alarms/alarms_api.cc File chrome/browser/extensions/api/alarms/alarms_api.cc (right): http://codereview.chromium.org/9791011/diff/9001/chrome/browser/extensions/api/alarms/alarms_api.cc#newcode36 chrome/browser/extensions/api/alarms/alarms_api.cc:36: DictionaryValue* details; On 2012/03/27 23:34:01, Aaron Boodman wrote: > ...
8 years, 9 months ago (2012-03-28 00:33:03 UTC) #8
Aaron Boodman
LGTM w/ nits http://codereview.chromium.org/9791011/diff/10003/chrome/browser/extensions/api/alarms/alarms_api.cc File chrome/browser/extensions/api/alarms/alarms_api.cc (right): http://codereview.chromium.org/9791011/diff/10003/chrome/browser/extensions/api/alarms/alarms_api.cc#newcode24 chrome/browser/extensions/api/alarms/alarms_api.cc:24: void SetAlarmCallback(Profile* profile, const std::string& extension_id) ...
8 years, 9 months ago (2012-03-28 03:36:18 UTC) #9
Mihai Parparita -not on Chrome
http://codereview.chromium.org/9791011/diff/10003/chrome/renderer/extensions/schema_generated_bindings.cc File chrome/renderer/extensions/schema_generated_bindings.cc (right): http://codereview.chromium.org/9791011/diff/10003/chrome/renderer/extensions/schema_generated_bindings.cc#newcode145 chrome/renderer/extensions/schema_generated_bindings.cc:145: ". Did you remember to register it with ExtensionFunctionRegistry?"; ...
8 years, 9 months ago (2012-03-28 17:01:30 UTC) #10
Matt Perry
8 years, 9 months ago (2012-03-28 20:21:36 UTC) #11
http://codereview.chromium.org/9791011/diff/10003/chrome/browser/extensions/a...
File chrome/browser/extensions/api/alarms/alarms_api.cc (right):

http://codereview.chromium.org/9791011/diff/10003/chrome/browser/extensions/a...
chrome/browser/extensions/api/alarms/alarms_api.cc:24: void
SetAlarmCallback(Profile* profile, const std::string& extension_id) {
On 2012/03/28 03:36:18, Aaron Boodman wrote:
> Maybe just AlarmCallback? How is this setting anything?

It was (SetAlarm)Callback, not Set(AlarmCallback) :) - from back when the API
was setAlarm. But you're right, I'll change it.

http://codereview.chromium.org/9791011/diff/10003/chrome/browser/extensions/a...
chrome/browser/extensions/api/alarms/alarms_api.cc:50:
params->alarm_info.delay_in_seconds*1000);
On 2012/03/28 03:36:18, Aaron Boodman wrote:
> "*".wrap(" ");

Done.

http://codereview.chromium.org/9791011/diff/10003/chrome/common/extensions/ap...
File chrome/common/extensions/api/experimental.alarms.json (right):

http://codereview.chromium.org/9791011/diff/10003/chrome/common/extensions/ap...
chrome/common/extensions/api/experimental.alarms.json:26: "description": "Sets
an alarm. After the delay is expired, the onAlarm event is fired. If there is
another alarm with the same name (or no name if none is specified), it will be
overridden by this alarm.",
On 2012/03/28 03:36:18, Aaron Boodman wrote:
> Creates an alarm. Will the old alarm be canceled in the case of overwrite? Or
> will it still fire?

Done (it will be cancelled).

http://codereview.chromium.org/9791011/diff/10003/chrome/common/extensions/ap...
chrome/common/extensions/api/experimental.alarms.json:32: "description":
"Optional name to identify this alarm. Defaults to \"default\"."
On 2012/03/28 03:36:18, Aaron Boodman wrote:
> How about just defaulting to empty string?

Done.

http://codereview.chromium.org/9791011/diff/10003/chrome/common/extensions/ap...
chrome/common/extensions/api/experimental.alarms.json:39: "description": "Length
of time in seconds after which the onAlarm event should fire. Note that
granularity is not guaranteed: up to a minute may pass before the alarm is
finally triggered."},
On 2012/03/28 03:36:18, Aaron Boodman wrote:
> You could say: Accuracy is only guaranteed to within one minute (but then why
> not just have units be minutes? -- your previous explanation didn't totally
make
> sense to me).

I'm trying to give us some leeway as to how accurate alarms are, and not tie it
directly to the units. If we want to allow alarms every 30 seconds, for example,
we need to use seconds as the units. And if we want to reduce granularity to
every 5 minutes, using minutes as units doesn't convey that either. I'll update
the description and try to convey this better.

http://codereview.chromium.org/9791011/diff/10003/chrome/renderer/extensions/...
File chrome/renderer/extensions/schema_generated_bindings.cc (right):

http://codereview.chromium.org/9791011/diff/10003/chrome/renderer/extensions/...
chrome/renderer/extensions/schema_generated_bindings.cc:145: ". Did you remember
to register it with ExtensionFunctionRegistry?";
On 2012/03/28 17:01:31, Mihai Parparita wrote:
> On 2012/03/28 03:36:18, Aaron Boodman wrote:
> > Heh.
> > 
> > Can we automate registration?
> 
> I thought Mike and Antony's IDL work automates that step
> (http://crrev.com/127159)

Ah, cool, it does. Unfortunately it doesn't quite work with all the JSON files
yet:
- it generates the schema.json data, which is unnecessary for JSON files.
- it assumes a particular naming scheme for ExtensionFunctions, which is not
obeyed by all the JSON APIs.

Powered by Google App Engine
This is Rietveld 408576698