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

Unified Diff: chrome/browser/extensions/webstore_install_helper.h

Issue 1153143002: Fix race condition in WebstoreInstallHelper (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix memleak Created 5 years, 7 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | chrome/browser/extensions/webstore_install_helper.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/extensions/webstore_install_helper.h
diff --git a/chrome/browser/extensions/webstore_install_helper.h b/chrome/browser/extensions/webstore_install_helper.h
index 08debed102e4b3eb4a076b947cdc2e0f252c9ce5..0a24af1d4817a3edbe25a5f290d6ae2f90129803 100644
--- a/chrome/browser/extensions/webstore_install_helper.h
+++ b/chrome/browser/extensions/webstore_install_helper.h
@@ -5,39 +5,36 @@
#ifndef CHROME_BROWSER_EXTENSIONS_WEBSTORE_INSTALL_HELPER_H_
#define CHROME_BROWSER_EXTENSIONS_WEBSTORE_INSTALL_HELPER_H_
-#include <vector>
+#include <string>
+#include "base/memory/ref_counted.h"
#include "base/memory/scoped_ptr.h"
-#include "base/memory/weak_ptr.h"
#include "chrome/browser/bitmap_fetcher/bitmap_fetcher_delegate.h"
-#include "content/public/browser/utility_process_host_client.h"
#include "third_party/skia/include/core/SkBitmap.h"
#include "url/gurl.h"
namespace base {
class DictionaryValue;
-class ListValue;
+class Value;
}
namespace chrome {
class BitmapFetcher;
}
-namespace content {
-class UtilityProcessHost;
-}
-
namespace net {
class URLRequestContextGetter;
}
+class SafeJsonParser;
+
namespace extensions {
// This is a class to help dealing with webstore-provided data. It manages
// sending work to the utility process for parsing manifests and
// fetching/decoding icon data. Clients must implement the
// WebstoreInstallHelper::Delegate interface to receive the parsed data.
-class WebstoreInstallHelper : public content::UtilityProcessHostClient,
+class WebstoreInstallHelper : public base::RefCounted<WebstoreInstallHelper>,
public chrome::BitmapFetcherDelegate {
public:
class Delegate {
@@ -75,22 +72,19 @@ class WebstoreInstallHelper : public content::UtilityProcessHostClient,
void Start();
private:
- ~WebstoreInstallHelper() override;
-
- void StartWorkOnIOThread();
- void ReportResultsIfComplete();
- void ReportResultFromUIThread();
+ friend class base::RefCounted<WebstoreInstallHelper>;
- // Implementing pieces of the UtilityProcessHostClient interface.
- bool OnMessageReceived(const IPC::Message& message) override;
+ ~WebstoreInstallHelper() override;
- // Message handlers.
- void OnJSONParseSucceeded(const base::ListValue& wrapper);
+ // Callbacks for the SafeJsonParser.
+ void OnJSONParseSucceeded(scoped_ptr<base::Value> result);
void OnJSONParseFailed(const std::string& error_message);
// Implementing the chrome::BitmapFetcherDelegate interface.
void OnFetchComplete(const GURL& url, const SkBitmap* image) override;
+ void ReportResultsIfComplete();
+
// The client who we'll report results back to.
Delegate* delegate_;
@@ -100,14 +94,14 @@ class WebstoreInstallHelper : public content::UtilityProcessHostClient,
// The manifest to parse.
std::string manifest_;
+ scoped_refptr<SafeJsonParser> json_parser_;
+
// If |icon_url_| is non-empty, it needs to be fetched and decoded into an
// SkBitmap.
GURL icon_url_;
net::URLRequestContextGetter* context_getter_; // Only usable on UI thread.
scoped_ptr<chrome::BitmapFetcher> icon_fetcher_;
- base::WeakPtr<content::UtilityProcessHost> utility_host_;
-
// Flags for whether we're done doing icon decoding and manifest parsing.
bool icon_decode_complete_;
bool manifest_parse_complete_;
« no previous file with comments | « no previous file | chrome/browser/extensions/webstore_install_helper.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698