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

Issue 9817018: Cleaning Up Extensions When Local Content Removed (Closed)

Created:
8 years, 9 months ago by Devlin
Modified:
8 years, 7 months ago
CC:
chromium-reviews, mihaip+watch_chromium.org
Base URL:
http://git.chromium.org/chromium/src.git@master
Visibility:
Public.

Description

Cleaning Up Extensions When Local Content Removed This fixes an issue where removing an extension's local content, e.g. deleting the user-data-dir/Default/Extensions/<id> directory, would result in a broken extension. Chrome will now uninstall/remove any extensions where the path to the extension cannot be resolved. BUG=31910 TEST=ExtensionServiceTest.CleanupInternalExtensionsMissingLocalContent; ExtensionServiceTest.CleanupUnpackedExtensionsMissingLocalContent; test by hand by loading an extension, deleting the local directory, and restarting chrome Committed: http://src.chromium.org/viewvc/chrome?view=rev&revision=134062

Patch Set 1 : Cleaning Up Extensions When Local Content Removed #

Total comments: 5

Patch Set 2 : Pulled garbage collection into its own class. #

Total comments: 10

Patch Set 3 : Removed preexisting race condition #

Total comments: 13

Patch Set 4 : Modified for thread safety #

Total comments: 10

Patch Set 5 : Request changes + extension_file_util #

Patch Set 6 : Updated with newest master #

Unified diffs Side-by-side diffs Delta from patch set Stats (+410 lines, -158 lines) Patch
A chrome/browser/extensions/extension_garbage_collector.h View 1 2 3 4 1 chunk +51 lines, -0 lines 0 comments Download
A chrome/browser/extensions/extension_garbage_collector.cc View 1 2 3 4 5 1 chunk +187 lines, -0 lines 0 comments Download
M chrome/browser/extensions/extension_service.h View 1 2 3 4 5 2 chunks +5 lines, -0 lines 0 comments Download
M chrome/browser/extensions/extension_service.cc View 1 2 3 4 5 5 chunks +4 lines, -20 lines 0 comments Download
M chrome/browser/extensions/extension_service_unittest.cc View 1 2 3 4 5 5 chunks +129 lines, -5 lines 0 comments Download
M chrome/chrome_browser_extensions.gypi View 1 2 3 4 5 1 chunk +2 lines, -0 lines 0 comments Download
M chrome/common/extensions/extension_file_util.h View 1 3 4 1 chunk +0 lines, -13 lines 0 comments Download
M chrome/common/extensions/extension_file_util.cc View 1 2 3 4 5 1 chunk +0 lines, -63 lines 0 comments Download
M chrome/common/extensions/extension_file_util_unittest.cc View 1 3 4 1 chunk +0 lines, -57 lines 0 comments Download
A chrome/test/data/extensions/garbage_collection/Extensions/fdoajpacpdeapbmhbblepcnilfkpmkff/1.0_0/manifest.json View 1 1 chunk +6 lines, -0 lines 0 comments Download
A chrome/test/data/extensions/garbage_collection/Extensions/fdoajpacpdeapbmhbblepcnilfkpmkff/1.1_0/manifest.json View 1 1 chunk +6 lines, -0 lines 0 comments Download
A chrome/test/data/extensions/garbage_collection/Preferences View 1 1 chunk +20 lines, -0 lines 0 comments Download

Messages

Total messages: 26 (0 generated)
Devlin
8 years, 9 months ago (2012-03-21 20:45:55 UTC) #1
Aaron Boodman
+yoz for his opinion on my idea. https://chromiumcodereview.appspot.com/9817018/diff/2001/chrome/browser/extensions/extension_service.cc File chrome/browser/extensions/extension_service.cc (right): https://chromiumcodereview.appspot.com/9817018/diff/2001/chrome/browser/extensions/extension_service.cc#newcode1941 chrome/browser/extensions/extension_service.cc:1941: if (!file_util::PathExists(info->at(i)->extension_path)) ...
8 years, 9 months ago (2012-03-21 21:00:47 UTC) #2
Devlin
https://chromiumcodereview.appspot.com/9817018/diff/2001/chrome/browser/extensions/extension_service.cc File chrome/browser/extensions/extension_service.cc (right): https://chromiumcodereview.appspot.com/9817018/diff/2001/chrome/browser/extensions/extension_service.cc#newcode1941 chrome/browser/extensions/extension_service.cc:1941: if (!file_util::PathExists(info->at(i)->extension_path)) { On 2012/03/21 21:00:47, Aaron Boodman wrote: ...
8 years, 9 months ago (2012-03-21 21:48:38 UTC) #3
Yoyo Zhou
On 2012/03/21 21:00:47, Aaron Boodman wrote: > +yoz for his opinion on my idea. https://chromiumcodereview.appspot.com/9817018/diff/2001/chrome/browser/extensions/extension_service.cc ...
8 years, 9 months ago (2012-03-21 22:55:18 UTC) #4
Yoyo Zhou
A few nits on the test. https://chromiumcodereview.appspot.com/9817018/diff/2001/chrome/browser/extensions/extension_service_unittest.cc File chrome/browser/extensions/extension_service_unittest.cc (right): https://chromiumcodereview.appspot.com/9817018/diff/2001/chrome/browser/extensions/extension_service_unittest.cc#newcode1159 chrome/browser/extensions/extension_service_unittest.cc:1159: // Test that ...
8 years, 9 months ago (2012-03-21 22:55:37 UTC) #5
Aaron Boodman
On 2012/03/21 21:48:38, D Cronin wrote: > https://chromiumcodereview.appspot.com/9817018/diff/2001/chrome/browser/extensions/extension_service.cc > File chrome/browser/extensions/extension_service.cc (right): > > https://chromiumcodereview.appspot.com/9817018/diff/2001/chrome/browser/extensions/extension_service.cc#newcode1941 ...
8 years, 9 months ago (2012-03-21 23:26:18 UTC) #6
mihaip_google.com
+Evan, for historical curiosity On Wed, Mar 21, 2012 at 4:26 PM, <aa@chromium.org> wrote: > ...
8 years, 9 months ago (2012-03-22 19:25:57 UTC) #7
mihaip_google.com
On Thu, Mar 22, 2012 at 12:25 PM, Mihai Parparita <mihaip@google.com> wrote: > The GC ...
8 years, 9 months ago (2012-03-22 19:31:45 UTC) #8
Aaron Boodman
On Thu, Mar 22, 2012 at 12:25 PM, Mihai Parparita <mihaip@google.com> wrote: > +Evan, for ...
8 years, 9 months ago (2012-03-22 19:44:30 UTC) #9
Aaron Boodman
On Thu, Mar 22, 2012 at 12:25 PM, Mihai Parparita <mihaip@google.com> wrote: > I'm guessing ...
8 years, 9 months ago (2012-03-22 20:16:52 UTC) #10
Aaron Boodman
On Thu, Mar 22, 2012 at 1:16 PM, Aaron Boodman <aa@chromium.org> wrote: > On Thu, ...
8 years, 9 months ago (2012-03-22 20:17:29 UTC) #11
Devlin
Refactor for pulling garbage collection into its own class completed.
8 years, 8 months ago (2012-03-31 15:49:44 UTC) #12
Aaron Boodman
There's a race in here that was already there. I wonder if you could fix ...
8 years, 8 months ago (2012-03-31 23:33:33 UTC) #13
Aaron Boodman
http://codereview.chromium.org/9817018/diff/9002/chrome/browser/extensions/extension_garbage_collector.cc File chrome/browser/extensions/extension_garbage_collector.cc (right): http://codereview.chromium.org/9817018/diff/9002/chrome/browser/extensions/extension_garbage_collector.cc#newcode145 chrome/browser/extensions/extension_garbage_collector.cc:145: extension_service_->UnloadExtension( In that case, it seems like we wouldn't ...
8 years, 8 months ago (2012-03-31 23:39:50 UTC) #14
Devlin
All requested changes made, and the preexisting race condition should be removed. https://chromiumcodereview.appspot.com/9817018/diff/9002/chrome/browser/extensions/extension_garbage_collector.cc File chrome/browser/extensions/extension_garbage_collector.cc ...
8 years, 8 months ago (2012-04-05 01:58:00 UTC) #15
Aaron Boodman
http://codereview.chromium.org/9817018/diff/13001/chrome/browser/extensions/extension_garbage_collector.cc File chrome/browser/extensions/extension_garbage_collector.cc (right): http://codereview.chromium.org/9817018/diff/13001/chrome/browser/extensions/extension_garbage_collector.cc#newcode30 chrome/browser/extensions/extension_garbage_collector.cc:30: if (!content::BrowserThread::PostTask( I think the current guidance to fire-and-forget ...
8 years, 8 months ago (2012-04-05 21:53:14 UTC) #16
Devlin
http://codereview.chromium.org/9817018/diff/13001/chrome/browser/extensions/extension_garbage_collector.cc File chrome/browser/extensions/extension_garbage_collector.cc (right): http://codereview.chromium.org/9817018/diff/13001/chrome/browser/extensions/extension_garbage_collector.cc#newcode30 chrome/browser/extensions/extension_garbage_collector.cc:30: if (!content::BrowserThread::PostTask( On 2012/04/05 21:53:14, Aaron Boodman wrote: > ...
8 years, 8 months ago (2012-04-07 17:38:21 UTC) #17
Aaron Boodman
LGTM, don't need another review from me http://codereview.chromium.org/9817018/diff/13001/chrome/browser/extensions/extension_garbage_collector.h File chrome/browser/extensions/extension_garbage_collector.h (right): http://codereview.chromium.org/9817018/diff/13001/chrome/browser/extensions/extension_garbage_collector.h#newcode33 chrome/browser/extensions/extension_garbage_collector.h:33: void CheckExtensionDirectories(const ...
8 years, 8 months ago (2012-04-07 18:01:03 UTC) #18
Yoyo Zhou
Can you remove the garbage collection code from extension_file_util.cc now that you've refactored it out?
8 years, 8 months ago (2012-04-10 19:36:45 UTC) #19
Devlin
On 2012/04/10 19:36:45, Yoyo Zhou wrote: > Can you remove the garbage collection code from ...
8 years, 8 months ago (2012-04-14 18:13:03 UTC) #20
Devlin
https://chromiumcodereview.appspot.com/9817018/diff/13001/chrome/browser/extensions/extension_garbage_collector.h File chrome/browser/extensions/extension_garbage_collector.h (right): https://chromiumcodereview.appspot.com/9817018/diff/13001/chrome/browser/extensions/extension_garbage_collector.h#newcode33 chrome/browser/extensions/extension_garbage_collector.h:33: void CheckExtensionDirectories(const FilePath& installation_directory); On 2012/04/07 18:01:03, Aaron Boodman ...
8 years, 8 months ago (2012-04-14 18:13:21 UTC) #21
Aaron Boodman
LGTM
8 years, 8 months ago (2012-04-15 23:24:10 UTC) #22
commit-bot: I haz the power
CQ is trying da patch. Follow status at https://chromium-status.appspot.com/cq/rdevlin.cronin@chromium.org/9817018/43001
8 years, 8 months ago (2012-04-26 02:22:40 UTC) #23
commit-bot: I haz the power
Change committed as 134062
8 years, 8 months ago (2012-04-26 04:03:43 UTC) #24
Devlin
On 2012/04/26 04:03:43, I haz the power (commit-bot) wrote: > Change committed as 134062 Change ...
8 years, 7 months ago (2012-05-05 18:07:33 UTC) #25
Aaron Boodman
8 years, 7 months ago (2012-05-07 22:10:31 UTC) #26
On Sat, May 5, 2012 at 11:07 AM,  <rdevlin.cronin@chromium.org> wrote:
> On 2012/04/26 04:03:43, I haz the power (commit-bot) wrote:
>>
>> Change committed as 134062
>
>
> Change was reverted since it broke sync integration tests (dang - didn't
> realize
> these weren't done by the trybots).
>
> The problem is that both the garbage collection and the installation of
> extensions happen on the UI and FILE threads, which can cause a race
> condition.
> For instance:
>
> 1) Garbage collection looks for directories on the file system (FILE)
> 2) An extension is in the stages of install
> 3) The new extension is registered in the prefs
> 4) Garbage collection move to UI thread, checks the prefs, and sees an
> extension
> seemingly without a corresponding file path (since the paths were gathered
> before the extension was installed).
> 5) Garbage collection deletes the extension from the prefs.

My understanding was that installation is always:

1) Write extension to disk on file thread
2) Write extension to preferences on UI thread

And that (new) GC is:

a) Read current extensions from disk on file thread
b) Read current extensions from preferences on UI thread
c) Delete any orphaned preferences on UI thread
d) Delete any orphaned directories on file thread

It sounds like you are saying the order [a, 1, 2, b, c, d] can occur.
But that doesn't make sense to me since both the file and UI thread
are serviced by shared event queues. It seems to me like the order
will always be either [a, b, ...] or [1, 2, ...]. What am I
misunderstanding? Perhaps in the case of sync, the order for
installation is not [1,2]?

> Of course, this is not a real solution.  Any
> suggestions for how we can avoid this race condition?

Threads are hard. The typical sane solution is to avoid them. To apply
that here, my idea has been to introduce the concept of an
ExtensionOperationQueue, which would be a queue of Task. Examples of
Tasks would be Install, Uninstall, CollectGarbage. A task would
encapsulate the file and UI thread bits. Only one task would operate
at a time.

That is a pretty big refactor though, so it would be good if we could
puzzle out what's going on with the sync tests.

- a

Powered by Google App Engine
This is Rietveld 408576698