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

Unified Diff: components/nacl/browser/nacl_browser.h

Issue 2630443003: Add thread checks to NaClBrowser, and make it leaky (Closed)
Patch Set: Update NaClGdbDebugStubTest Created 3 years, 10 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
Index: components/nacl/browser/nacl_browser.h
diff --git a/components/nacl/browser/nacl_browser.h b/components/nacl/browser/nacl_browser.h
index 34b33b6f049e2c73975e64436244b2182496246a..5839cda6348c7905dcec5b5d67f805d05bcc3603 100644
--- a/components/nacl/browser/nacl_browser.h
+++ b/components/nacl/browser/nacl_browser.h
@@ -14,8 +14,6 @@
#include "base/containers/mru_cache.h"
#include "base/files/file.h"
#include "base/macros.h"
-#include "base/memory/singleton.h"
-#include "base/memory/weak_ptr.h"
#include "base/time/time.h"
#include "build/build_config.h"
#include "components/nacl/browser/nacl_browser_delegate.h"
@@ -66,17 +64,18 @@ class NaClBrowser {
// IRT file handle, only available when IsReady().
const base::File& IrtFile() const;
- // Methods for testing GDB debug stub in browser. If test adds debug stub
- // port listener, Chrome will allocate a currently-unused TCP port number for
- // debug stub server instead of a fixed one.
-
- // Notify listener that new debug stub TCP port is allocated.
+ // Methods for tracking the GDB debug stub port associated with each NaCl
+ // process.
void SetProcessGdbDebugStubPort(int process_id, int port);
- void SetGdbDebugStubPortListener(base::Callback<void(int)> listener);
- void ClearGdbDebugStubPortListener();
-
int GetProcessGdbDebugStubPort(int process_id);
+ // While a test has a GDB debug port callback set, Chrome will allocate a
+ // currently-unused TCP port to the debug stub server, instead of a fixed
+ // one.
+ static void SetGdbDebugStubPortListenerForTest(
+ base::Callback<void(int)> listener);
+ static void ClearGdbDebugStubPortListenerForTest();
+
enum ValidationCacheStatus {
CACHE_MISS = 0,
CACHE_HIT,
@@ -91,7 +90,7 @@ class NaClBrowser {
return validation_cache_.GetValidationCacheKey();
}
- // The NaCl singleton keeps information about NaCl executable files opened via
+ // The instance keeps information about NaCl executable files opened via
// PPAPI. This allows the NaCl process to get trusted information about the
// file directly from the browser process. In theory, a compromised renderer
// could provide a writable file handle or lie about the file's path. If we
@@ -129,27 +128,32 @@ class NaClBrowser {
#endif
void EarlyStartup();
- static void SetDelegate(NaClBrowserDelegate* delegate);
+
+ // Set/get the NaClBrowserDelegate. The |delegate| must be set at startup,
+ // from the Browser's UI thread. It will be leaked at browser teardown.
+ static void SetDelegate(std::unique_ptr<NaClBrowserDelegate> delegate);
static NaClBrowserDelegate* GetDelegate();
+ static void ClearAndDeleteDelegateForTest();
- // Each time a NaCl process ends, the browser is notified.
+ // Called whenever a NaCl process exits.
void OnProcessEnd(int process_id);
- // Support for NaCl crash throttling.
- // Each time a NaCl module crashes, the browser is notified.
+
+ // Called whenever a NaCl process crashes, before OnProcessEnd().
void OnProcessCrashed();
+
// If "too many" crashes occur within a given time period, NaCl is throttled
// until the rate again drops below the threshold.
bool IsThrottled();
private:
- friend struct base::DefaultSingletonTraits<NaClBrowser>;
-
enum NaClResourceState {
NaClResourceUninitialized,
NaClResourceRequested,
NaClResourceReady
};
+ static NaClBrowser* GetInstanceInternal();
+
NaClBrowser();
~NaClBrowser();
@@ -174,7 +178,6 @@ class NaClBrowser {
void MarkValidationCacheAsModified();
void PersistValidationCache();
-
base::File irt_file_;
base::FilePath irt_filepath_;
NaClResourceState irt_state_;
@@ -193,18 +196,14 @@ class NaClBrowser {
typedef base::HashingMRUCache<std::string, base::FilePath> PathCacheType;
PathCacheType path_cache_;
- bool ok_;
+ // True if it is no longer possible to launch NaCl processes.
+ bool has_failed_;
// A list of pending tasks to start NaCl processes.
std::vector<base::Closure> waiting_;
- std::unique_ptr<NaClBrowserDelegate> browser_delegate_;
-
std::deque<base::Time> crash_times_;
- // Singletons get destroyed at shutdown.
- base::WeakPtrFactory<NaClBrowser> weak_factory_;
-
DISALLOW_COPY_AND_ASSIGN(NaClBrowser);
};

Powered by Google App Engine
This is Rietveld 408576698