summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authoranand.ratn <anand.ratn@samsung.com>2014-09-04 22:11:50 -0700
committerCommit bot <commit-bot@chromium.org>2014-09-05 05:13:47 +0000
commite8dea07883cf5cb9efa4c083495dd3de4abf3e14 (patch)
tree75a407bd31bbb91ddfcc98dffaea12ee31f289be
parent57d121ace54a34516a4b758007632ac410dfe9bd (diff)
downloadchromium_src-e8dea07883cf5cb9efa4c083495dd3de4abf3e14.zip
chromium_src-e8dea07883cf5cb9efa4c083495dd3de4abf3e14.tar.gz
chromium_src-e8dea07883cf5cb9efa4c083495dd3de4abf3e14.tar.bz2
Declaring the weak_ptr_factory in proper order.
Cleaning up weak_ptr_factorydestruction order in "src/ash" module. WeakPtrFactory should remain the last member so it'll be destroyed and invalidate its weak pointers before any other members are destroyed. BUG=303818 Review URL: https://codereview.chromium.org/497733002 Cr-Commit-Position: refs/heads/master@{#293450}
-rw-r--r--AUTHORS1
-rw-r--r--ash/system/chromeos/brightness/tray_brightness.cc4
-rw-r--r--ash/system/chromeos/brightness/tray_brightness.h4
-rw-r--r--ash/wm/workspace/workspace_window_resizer.cc14
-rw-r--r--ash/wm/workspace/workspace_window_resizer.h6
-rw-r--r--ash/wm/workspace/workspace_window_resizer_unittest.cc2
6 files changed, 18 insertions, 13 deletions
diff --git a/AUTHORS b/AUTHORS
index b1e4617..cd0bf32 100644
--- a/AUTHORS
+++ b/AUTHORS
@@ -33,6 +33,7 @@ Amit Sarkar <amit.srkr@samsung.com>
Amogh Bihani <amogh.bihani@samsung.com>
Amruth Raj <amruthraj@motorola.com>
Amruth Raj <ckqr36@motorola.com>
+Anand Ratn <anand.ratn@samsung.com>
Anastasios Cassiotis <tom.cassiotis@gmail.com>
Ancil George <ancilgeorge@samsung.com>
Andrei Parvu <andrei.prv@gmail.com>
diff --git a/ash/system/chromeos/brightness/tray_brightness.cc b/ash/system/chromeos/brightness/tray_brightness.cc
index ee511ea..5c804e8 100644
--- a/ash/system/chromeos/brightness/tray_brightness.cc
+++ b/ash/system/chromeos/brightness/tray_brightness.cc
@@ -174,10 +174,10 @@ void BrightnessView::SliderDragEnded(views::Slider* slider) {
TrayBrightness::TrayBrightness(SystemTray* system_tray)
: SystemTrayItem(system_tray),
- weak_ptr_factory_(this),
brightness_view_(NULL),
current_percent_(100.0),
- got_current_percent_(false) {
+ got_current_percent_(false),
+ weak_ptr_factory_(this) {
// Post a task to get the initial brightness; the BrightnessControlDelegate
// isn't created yet.
base::MessageLoopForUI::current()->PostTask(
diff --git a/ash/system/chromeos/brightness/tray_brightness.h b/ash/system/chromeos/brightness/tray_brightness.h
index 379a8d2..1c0d10d 100644
--- a/ash/system/chromeos/brightness/tray_brightness.h
+++ b/ash/system/chromeos/brightness/tray_brightness.h
@@ -50,8 +50,6 @@ class ASH_EXPORT TrayBrightness
void HandleBrightnessChanged(double percent, bool user_initiated);
- base::WeakPtrFactory<TrayBrightness> weak_ptr_factory_;
-
tray::BrightnessView* brightness_view_;
// Brightness level in the range [0.0, 100.0] that we've heard about most
@@ -61,6 +59,8 @@ class ASH_EXPORT TrayBrightness
// Has |current_percent_| been initialized?
bool got_current_percent_;
+ base::WeakPtrFactory<TrayBrightness> weak_ptr_factory_;
+
DISALLOW_COPY_AND_ASSIGN(TrayBrightness);
};
diff --git a/ash/wm/workspace/workspace_window_resizer.cc b/ash/wm/workspace/workspace_window_resizer.cc
index 7611071..3e551f3 100644
--- a/ash/wm/workspace/workspace_window_resizer.cc
+++ b/ash/wm/workspace/workspace_window_resizer.cc
@@ -110,6 +110,9 @@ namespace {
// when resizing a window using touchscreen.
const int kScreenEdgeInsetForTouchDrag = 32;
+// Current instance for use by the WorkspaceWindowResizerTest.
+WorkspaceWindowResizer* instance = NULL;
+
// Returns true if the window should stick to the edge.
bool ShouldStickToEdge(int distance_from_edge, int sticky_size) {
return distance_from_edge < sticky_size &&
@@ -256,8 +259,9 @@ const int WorkspaceWindowResizer::kMinOnscreenHeight = 32;
// static
const int WorkspaceWindowResizer::kScreenEdgeInset = 8;
-// static
-WorkspaceWindowResizer* WorkspaceWindowResizer::instance_ = NULL;
+WorkspaceWindowResizer* WorkspaceWindowResizer::GetInstanceForTest() {
+ return instance;
+}
// Represents the width or height of a window with constraints on its minimum
// and maximum size. 0 represents a lack of a constraint.
@@ -333,8 +337,8 @@ WorkspaceWindowResizer::~WorkspaceWindowResizer() {
Shell* shell = Shell::GetInstance();
shell->cursor_manager()->UnlockCursor();
}
- if (instance_ == this)
- instance_ = NULL;
+ if (instance == this)
+ instance = NULL;
}
// static
@@ -555,7 +559,7 @@ WorkspaceWindowResizer::WorkspaceWindowResizer(
total_initial_size_ += initial_size;
total_available += std::max(min_size, initial_size) - min_size;
}
- instance_ = this;
+ instance = this;
}
void WorkspaceWindowResizer::LayoutAttachedWindows(
diff --git a/ash/wm/workspace/workspace_window_resizer.h b/ash/wm/workspace/workspace_window_resizer.h
index 99a2df5..ec73f4a 100644
--- a/ash/wm/workspace/workspace_window_resizer.h
+++ b/ash/wm/workspace/workspace_window_resizer.h
@@ -167,6 +167,9 @@ class ASH_EXPORT WorkspaceWindowResizer : public WindowResizer {
const std::vector<aura::Window*> attached_windows_;
+ // Returns the currently used instance for test.
+ static WorkspaceWindowResizer* GetInstanceForTest();
+
bool did_lock_cursor_;
// Set to true once Drag() is invoked and the bounds of the window change.
@@ -221,9 +224,6 @@ class ASH_EXPORT WorkspaceWindowResizer : public WindowResizer {
// gets dragged into another browser window.
base::WeakPtrFactory<WorkspaceWindowResizer> weak_ptr_factory_;
- // Current instance for use by the WorkspaceWindowResizerTest.
- static WorkspaceWindowResizer* instance_;
-
DISALLOW_COPY_AND_ASSIGN(WorkspaceWindowResizer);
};
diff --git a/ash/wm/workspace/workspace_window_resizer_unittest.cc b/ash/wm/workspace/workspace_window_resizer_unittest.cc
index 9b10e16..cd13445 100644
--- a/ash/wm/workspace/workspace_window_resizer_unittest.cc
+++ b/ash/wm/workspace/workspace_window_resizer_unittest.cc
@@ -148,7 +148,7 @@ class WorkspaceWindowResizerTest : public test::AshTestBase {
point_in_parent,
window_component,
aura::client::WINDOW_MOVE_SOURCE_MOUSE).release();
- workspace_resizer_ = WorkspaceWindowResizer::instance_;
+ workspace_resizer_ = WorkspaceWindowResizer::GetInstanceForTest();
return resizer;
}
WorkspaceWindowResizer* CreateWorkspaceResizerForTest(