Commit 7f1c96b5 authored by achuith@chromium.org's avatar achuith@chromium.org

Use Closure instead of ScopedRunnableMethodFactory in NetworkMenuButton.

BUG=chromium-os:22024
TEST=tests pass.
Review URL: http://codereview.chromium.org/8351021

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@107080 0039d316-1c4b-4281-b951-d872f2087c98
parent 9b743a9f
......@@ -6,7 +6,9 @@
#include <algorithm>
#include <limits>
#include <vector>
#include "base/bind.h"
#include "base/logging.h"
#include "base/message_loop.h"
#include "base/string_util.h"
......@@ -100,7 +102,7 @@ NetworkMenuButton::NetworkMenuButton(StatusAreaHost* host)
is_browser_mode_(false),
check_for_promo_(true),
was_sim_locked_(false),
ALLOW_THIS_IN_INITIALIZER_LIST(method_factory_(this)) {
ALLOW_THIS_IN_INITIALIZER_LIST(weak_ptr_factory_(this)) {
is_browser_mode_ = (host->GetScreenMode() == StatusAreaHost::kBrowserMode);
network_menu_.reset(new NetworkMenu(this, is_browser_mode_));
network_icon_.reset(
......@@ -385,10 +387,11 @@ void NetworkMenuButton::ShowOptionalMobileDataPromoNotification(
if (!screen_bounds.Contains(button_bounds)) {
// If we're not on screen yet, delay notification display.
// It may be shown earlier, on next NetworkLibrary callback processing.
if (method_factory_.empty()) {
if (!weak_ptr_factory_.HasWeakPtrs()) {
MessageLoop::current()->PostDelayedTask(FROM_HERE,
method_factory_.NewRunnableMethod(
base::Bind(
&NetworkMenuButton::ShowOptionalMobileDataPromoNotification,
weak_ptr_factory_.GetWeakPtr(),
cros),
kPromoShowDelayMs);
}
......
......@@ -8,7 +8,7 @@
#include <string>
#include "base/task.h"
#include "base/memory/weak_ptr.h"
#include "base/timer.h"
#include "chrome/browser/chromeos/cros/network_library.h"
#include "chrome/browser/chromeos/login/message_bubble.h"
......@@ -160,7 +160,7 @@ class NetworkMenuButton : public StatusAreaButton,
std::string deal_topup_url_;
// Factory for delaying showing promo notification.
ScopedRunnableMethodFactory<NetworkMenuButton> method_factory_;
base::WeakPtrFactory<NetworkMenuButton> weak_ptr_factory_;
DISALLOW_COPY_AND_ASSIGN(NetworkMenuButton);
};
......
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