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

Side by Side Diff: chrome/browser/extensions/webstore_installer.h

Issue 10832105: Ensure that the WebstoreInstaller is always deleted on the UI thread (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 4 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | chrome/browser/extensions/webstore_installer.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 #ifndef CHROME_BROWSER_EXTENSIONS_WEBSTORE_INSTALLER_H_ 5 #ifndef CHROME_BROWSER_EXTENSIONS_WEBSTORE_INSTALLER_H_
6 #define CHROME_BROWSER_EXTENSIONS_WEBSTORE_INSTALLER_H_ 6 #define CHROME_BROWSER_EXTENSIONS_WEBSTORE_INSTALLER_H_
7 7
8 #include <string> 8 #include <string>
9 #include <vector> 9 #include <vector>
10 10
11 #include "base/compiler_specific.h" 11 #include "base/compiler_specific.h"
12 #include "base/memory/ref_counted.h" 12 #include "base/memory/ref_counted.h"
13 #include "base/memory/scoped_ptr.h" 13 #include "base/memory/scoped_ptr.h"
14 #include "base/values.h" 14 #include "base/values.h"
15 #include "content/public/browser/browser_thread.h"
15 #include "content/public/browser/download_id.h" 16 #include "content/public/browser/download_id.h"
16 #include "content/public/browser/download_item.h" 17 #include "content/public/browser/download_item.h"
17 #include "content/public/browser/notification_observer.h" 18 #include "content/public/browser/notification_observer.h"
18 #include "content/public/browser/notification_registrar.h" 19 #include "content/public/browser/notification_registrar.h"
19 #include "net/base/net_errors.h" 20 #include "net/base/net_errors.h"
20 #include "googleurl/src/gurl.h" 21 #include "googleurl/src/gurl.h"
21 22
22 class FilePath; 23 class FilePath;
23 class Profile; 24 class Profile;
24 25
25 namespace content { 26 namespace content {
26 class NavigationController; 27 class NavigationController;
27 } 28 }
28 29
29 namespace extensions { 30 namespace extensions {
30 31
31 // Downloads and installs extensions from the web store. 32 // Downloads and installs extensions from the web store.
32 class WebstoreInstaller : public content::NotificationObserver, 33 class WebstoreInstaller :public content::NotificationObserver,
miket_OOO 2012/08/02 15:53:55 I liked the old whitespace better.
33 public content::DownloadItem::Observer, 34 public content::DownloadItem::Observer,
34 public base::RefCounted<WebstoreInstaller> { 35 public base::RefCountedThreadSafe<
36 WebstoreInstaller, content::BrowserThread::DeleteOnUIThread> {
35 public: 37 public:
36 enum Flag { 38 enum Flag {
37 FLAG_NONE = 0, 39 FLAG_NONE = 0,
38 40
39 // Inline installs trigger slightly different behavior (install source 41 // Inline installs trigger slightly different behavior (install source
40 // is different, download referrers are the item's page in the gallery). 42 // is different, download referrers are the item's page in the gallery).
41 FLAG_INLINE_INSTALL = 1 << 0 43 FLAG_INLINE_INSTALL = 1 << 0
42 }; 44 };
43 45
44 class Delegate { 46 class Delegate {
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
118 // content::NotificationObserver 120 // content::NotificationObserver
119 virtual void Observe(int type, 121 virtual void Observe(int type,
120 const content::NotificationSource& source, 122 const content::NotificationSource& source,
121 const content::NotificationDetails& details) OVERRIDE; 123 const content::NotificationDetails& details) OVERRIDE;
122 124
123 // Instead of using the default download directory, use |directory| instead. 125 // Instead of using the default download directory, use |directory| instead.
124 // This does *not* transfer ownership of |directory|. 126 // This does *not* transfer ownership of |directory|.
125 static void SetDownloadDirectoryForTests(FilePath* directory); 127 static void SetDownloadDirectoryForTests(FilePath* directory);
126 128
127 private: 129 private:
128 friend class base::RefCounted<WebstoreInstaller>; 130 friend struct content::BrowserThread::DeleteOnThread<
131 content::BrowserThread::UI>;
132 friend class base::DeleteHelper<WebstoreInstaller>;
129 virtual ~WebstoreInstaller(); 133 virtual ~WebstoreInstaller();
130 134
131 // DownloadManager::DownloadUrl callback. 135 // DownloadManager::DownloadUrl callback.
132 void OnDownloadStarted(content::DownloadId id, net::Error error); 136 void OnDownloadStarted(content::DownloadId id, net::Error error);
133 137
134 // DownloadItem::Observer implementation: 138 // DownloadItem::Observer implementation:
135 virtual void OnDownloadUpdated(content::DownloadItem* download) OVERRIDE; 139 virtual void OnDownloadUpdated(content::DownloadItem* download) OVERRIDE;
136 virtual void OnDownloadOpened(content::DownloadItem* download) OVERRIDE; 140 virtual void OnDownloadOpened(content::DownloadItem* download) OVERRIDE;
137 141
138 // Starts downloading the extension to |file_path|. 142 // Starts downloading the extension to |file_path|.
(...skipping 18 matching lines...) Expand all
157 // transitions to state REMOVING. 161 // transitions to state REMOVING.
158 content::DownloadItem* download_item_; 162 content::DownloadItem* download_item_;
159 int flags_; 163 int flags_;
160 scoped_ptr<Approval> approval_; 164 scoped_ptr<Approval> approval_;
161 GURL download_url_; 165 GURL download_url_;
162 }; 166 };
163 167
164 } // namespace extensions 168 } // namespace extensions
165 169
166 #endif // CHROME_BROWSER_EXTENSIONS_WEBSTORE_INSTALLER_H_ 170 #endif // CHROME_BROWSER_EXTENSIONS_WEBSTORE_INSTALLER_H_
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/extensions/webstore_installer.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698