Commit 371ad914 authored by mohan.reddy's avatar mohan.reddy Committed by Commit bot

Refactoring the weak_ptr_factory order content/browser folder

Changing in the intialization order of WeakPtrFactory such that all
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/567943002

Cr-Commit-Position: refs/heads/master@{#295238}
parent 38dbbbfd
......@@ -69,8 +69,8 @@ struct GpuProcessTransportFactory::PerCompositorData {
};
GpuProcessTransportFactory::GpuProcessTransportFactory()
: callback_factory_(this),
next_surface_id_namespace_(1u) {
: next_surface_id_namespace_(1u),
callback_factory_(this) {
output_surface_proxy_ = new BrowserCompositorOutputSurfaceProxy(
&output_surface_map_);
#if defined(OS_CHROMEOS)
......
......@@ -87,7 +87,6 @@ class GpuProcessTransportFactory
scoped_refptr<ContextProviderCommandBuffer> shared_main_thread_contexts_;
scoped_ptr<GLHelper> gl_helper_;
ObserverList<ImageTransportFactoryObserver> observer_list_;
base::WeakPtrFactory<GpuProcessTransportFactory> callback_factory_;
scoped_ptr<cc::SurfaceManager> surface_manager_;
uint32_t next_surface_id_namespace_;
......@@ -97,6 +96,8 @@ class GpuProcessTransportFactory
scoped_refptr<BrowserCompositorOutputSurfaceProxy> output_surface_proxy_;
base::WeakPtrFactory<GpuProcessTransportFactory> callback_factory_;
DISALLOW_COPY_AND_ASSIGN(GpuProcessTransportFactory);
};
......
......@@ -56,7 +56,7 @@ const double DevToolsTracingHandler::kMinimumReportingInterval = 250.0;
DevToolsTracingHandler::DevToolsTracingHandler(
DevToolsTracingHandler::Target target)
: weak_factory_(this), target_(target), is_recording_(false) {
: target_(target), is_recording_(false), weak_factory_(this) {
RegisterCommandHandler(devtools::Tracing::start::kName,
base::Bind(&DevToolsTracingHandler::OnStart,
base::Unretained(this)));
......
......@@ -54,7 +54,6 @@ class DevToolsTracingHandler : public DevToolsProtocol::Handler {
void DisableRecording(bool abort);
base::WeakPtrFactory<DevToolsTracingHandler> weak_factory_;
scoped_ptr<base::Timer> buffer_usage_poll_timer_;
Target target_;
bool is_recording_;
......@@ -63,6 +62,8 @@ class DevToolsTracingHandler : public DevToolsProtocol::Handler {
static const double kDefaultReportingInterval;
static const double kMinimumReportingInterval;
base::WeakPtrFactory<DevToolsTracingHandler> weak_factory_;
DISALLOW_COPY_AND_ASSIGN(DevToolsTracingHandler);
};
......
......@@ -64,8 +64,9 @@ class ScreenshotData : public base::RefCountedThreadSafe<ScreenshotData> {
NavigationEntryScreenshotManager::NavigationEntryScreenshotManager(
NavigationControllerImpl* owner)
: owner_(owner),
screenshot_factory_(this),
min_screenshot_interval_ms_(kMinScreenshotIntervalMS) {
min_screenshot_interval_ms_(kMinScreenshotIntervalMS),
screenshot_factory_(this) {
}
NavigationEntryScreenshotManager::~NavigationEntryScreenshotManager() {
......
......@@ -74,14 +74,14 @@ class CONTENT_EXPORT NavigationEntryScreenshotManager {
// The navigation controller that owns this screenshot-manager.
NavigationControllerImpl* owner_;
base::Time last_screenshot_time_;
int min_screenshot_interval_ms_;
// Taking a screenshot and encoding them can be async. So use a weakptr for
// the callback to make sure that the screenshot/encoding completion callback
// does not trigger on a destroyed NavigationEntryScreenshotManager.
base::WeakPtrFactory<NavigationEntryScreenshotManager> screenshot_factory_;
base::Time last_screenshot_time_;
int min_screenshot_interval_ms_;
DISALLOW_COPY_AND_ASSIGN(NavigationEntryScreenshotManager);
};
......
......@@ -52,14 +52,14 @@ WindowSlider::WindowSlider(Delegate* delegate,
owner_(owner),
active_animator_(NULL),
delta_x_(0.f),
weak_factory_(this),
active_start_threshold_(0.f),
start_threshold_touchscreen_(content::GetOverscrollConfig(
content::OVERSCROLL_CONFIG_HORIZ_THRESHOLD_START_TOUCHSCREEN)),
start_threshold_touchpad_(content::GetOverscrollConfig(
content::OVERSCROLL_CONFIG_HORIZ_THRESHOLD_START_TOUCHPAD)),
complete_threshold_(content::GetOverscrollConfig(
content::OVERSCROLL_CONFIG_HORIZ_THRESHOLD_COMPLETE)) {
content::OVERSCROLL_CONFIG_HORIZ_THRESHOLD_COMPLETE)),
weak_factory_(this) {
event_window_->AddPreTargetHandler(this);
event_window_->AddObserver(this);
......
......@@ -140,14 +140,14 @@ class CONTENT_EXPORT WindowSlider : public ui::EventHandler,
// This manages the shadow for the layers.
scoped_ptr<ShadowLayerDelegate> shadow_;
base::WeakPtrFactory<WindowSlider> weak_factory_;
float active_start_threshold_;
const float start_threshold_touchscreen_;
const float start_threshold_touchpad_;
const float complete_threshold_;
base::WeakPtrFactory<WindowSlider> weak_factory_;
DISALLOW_COPY_AND_ASSIGN(WindowSlider);
};
......
......@@ -354,7 +354,6 @@ WebContentsImpl::WebContentsImpl(
waiting_for_response_(false),
load_state_(net::LOAD_STATE_IDLE, base::string16()),
loading_total_progress_(0.0),
loading_weak_factory_(this),
loading_frames_in_progress_(0),
upload_size_(0),
upload_position_(0),
......@@ -380,7 +379,8 @@ WebContentsImpl::WebContentsImpl(
last_dialog_suppressed_(false),
accessibility_mode_(
BrowserAccessibilityStateImpl::GetInstance()->accessibility_mode()),
audio_stream_monitor_(this) {
audio_stream_monitor_(this),
loading_weak_factory_(this) {
for (size_t i = 0; i < g_created_callbacks.Get().size(); i++)
g_created_callbacks.Get().at(i).Run(this);
frame_tree_.SetFrameRemoveListener(
......
......@@ -1061,8 +1061,6 @@ class CONTENT_EXPORT WebContentsImpl
base::TimeTicks loading_last_progress_update_;
base::WeakPtrFactory<WebContentsImpl> loading_weak_factory_;
// Counter to track how many frames have sent start notifications but not
// stop notifications.
int loading_frames_in_progress_;
......@@ -1241,6 +1239,8 @@ class CONTENT_EXPORT WebContentsImpl
// Monitors power levels for audio streams associated with this WebContents.
AudioStreamMonitor audio_stream_monitor_;
base::WeakPtrFactory<WebContentsImpl> loading_weak_factory_;
DISALLOW_COPY_AND_ASSIGN(WebContentsImpl);
};
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment