summaryrefslogtreecommitdiffstats
path: root/components/nacl
diff options
context:
space:
mode:
authormohan.reddy <mohan.reddy@samsung.com>2014-09-10 06:33:00 -0700
committerCommit bot <commit-bot@chromium.org>2014-09-10 13:42:19 +0000
commitd97aafa2698638f2f207538980014b6e461e382c (patch)
tree8720732fc762671e92d85491f304e7a493583119 /components/nacl
parent534f477b55a79cb4829d95c48d310cfedca09470 (diff)
downloadchromium_src-d97aafa2698638f2f207538980014b6e461e382c.zip
chromium_src-d97aafa2698638f2f207538980014b6e461e382c.tar.gz
chromium_src-d97aafa2698638f2f207538980014b6e461e382c.tar.bz2
Refactoring the WeakPtrFactory usage, Member variables should appear before the WeakPtrFactory, to ensure that any WeakPtrs to Controller are invalidated before its members variable's destructors are executed, rendering them invalid.
BUG=303818 Review URL: https://codereview.chromium.org/554233002 Cr-Commit-Position: refs/heads/master@{#294163}
Diffstat (limited to 'components/nacl')
-rw-r--r--components/nacl/browser/nacl_browser.cc6
-rw-r--r--components/nacl/browser/nacl_browser.h5
-rw-r--r--components/nacl/browser/nacl_process_host.cc4
-rw-r--r--components/nacl/browser/nacl_process_host.h4
4 files changed, 10 insertions, 9 deletions
diff --git a/components/nacl/browser/nacl_browser.cc b/components/nacl/browser/nacl_browser.cc
index 2982fdc..c76862a 100644
--- a/components/nacl/browser/nacl_browser.cc
+++ b/components/nacl/browser/nacl_browser.cc
@@ -137,8 +137,7 @@ base::File OpenNaClReadExecImpl(const base::FilePath& file_path,
}
NaClBrowser::NaClBrowser()
- : weak_factory_(this),
- irt_filepath_(),
+ : irt_filepath_(),
irt_state_(NaClResourceUninitialized),
validation_cache_file_path_(),
validation_cache_is_enabled_(
@@ -147,7 +146,8 @@ NaClBrowser::NaClBrowser()
validation_cache_is_modified_(false),
validation_cache_state_(NaClResourceUninitialized),
path_cache_(kFilePathCacheSize),
- ok_(true) {
+ ok_(true),
+ weak_factory_(this) {
}
void NaClBrowser::SetDelegate(NaClBrowserDelegate* delegate) {
diff --git a/components/nacl/browser/nacl_browser.h b/components/nacl/browser/nacl_browser.h
index 8e3e9ef..21e3ac7 100644
--- a/components/nacl/browser/nacl_browser.h
+++ b/components/nacl/browser/nacl_browser.h
@@ -170,8 +170,6 @@ class NaClBrowser {
void MarkValidationCacheAsModified();
void PersistValidationCache();
- // Singletons get destroyed at shutdown.
- base::WeakPtrFactory<NaClBrowser> weak_factory_;
base::File irt_file_;
base::FilePath irt_filepath_;
@@ -200,6 +198,9 @@ class NaClBrowser {
std::deque<base::Time> crash_times_;
+ // Singletons get destroyed at shutdown.
+ base::WeakPtrFactory<NaClBrowser> weak_factory_;
+
DISALLOW_COPY_AND_ASSIGN(NaClBrowser);
};
diff --git a/components/nacl/browser/nacl_process_host.cc b/components/nacl/browser/nacl_process_host.cc
index 33b071f..defc29f 100644
--- a/components/nacl/browser/nacl_process_host.cc
+++ b/components/nacl/browser/nacl_process_host.cc
@@ -274,7 +274,6 @@ NaClProcessHost::NaClProcessHost(const GURL& manifest_url,
debug_exception_handler_requested_(false),
#endif
internal_(new NaClInternal()),
- weak_factory_(this),
uses_irt_(uses_irt),
uses_nonsfi_mode_(uses_nonsfi_mode),
enable_debug_stub_(false),
@@ -283,7 +282,8 @@ NaClProcessHost::NaClProcessHost(const GURL& manifest_url,
enable_crash_throttling_(enable_crash_throttling),
off_the_record_(off_the_record),
profile_directory_(profile_directory),
- render_view_id_(render_view_id) {
+ render_view_id_(render_view_id),
+ weak_factory_(this) {
process_.reset(content::BrowserChildProcessHost::Create(
PROCESS_TYPE_NACL_LOADER, this));
diff --git a/components/nacl/browser/nacl_process_host.h b/components/nacl/browser/nacl_process_host.h
index 31e0d60..3b358b5 100644
--- a/components/nacl/browser/nacl_process_host.h
+++ b/components/nacl/browser/nacl_process_host.h
@@ -223,8 +223,6 @@ class NaClProcessHost : public content::BrowserChildProcessHostDelegate {
// Socket pairs for the NaCl process and renderer.
scoped_ptr<NaClInternal> internal_;
- base::WeakPtrFactory<NaClProcessHost> weak_factory_;
-
scoped_ptr<content::BrowserChildProcessHost> process_;
bool uses_irt_;
@@ -253,6 +251,8 @@ class NaClProcessHost : public content::BrowserChildProcessHostDelegate {
// reporting crash information.
base::SharedMemory crash_info_shmem_;
+ base::WeakPtrFactory<NaClProcessHost> weak_factory_;
+
DISALLOW_COPY_AND_ASSIGN(NaClProcessHost);
};