diff options
author | ivankr@chromium.org <ivankr@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-11-09 11:04:55 +0000 |
---|---|---|
committer | ivankr@chromium.org <ivankr@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-11-09 11:04:55 +0000 |
commit | 7d21a6b37c15011033601f49150e280c2417ce1d (patch) | |
tree | 8a893f4b29f773643df8bdef5102b77cf55627a8 /rlz/lib/financial_ping.cc | |
parent | c80ca12f3e74e8d54653c312bbd3c92afd0fee55 (diff) | |
download | chromium_src-7d21a6b37c15011033601f49150e280c2417ce1d.zip chromium_src-7d21a6b37c15011033601f49150e280c2417ce1d.tar.gz chromium_src-7d21a6b37c15011033601f49150e280c2417ce1d.tar.bz2 |
[cros] RlzValueStore implementation for ChromeOS.
BUG=157348
TEST=rlz_unittests
Review URL: https://chromiumcodereview.appspot.com/11365107
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@166891 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'rlz/lib/financial_ping.cc')
-rw-r--r-- | rlz/lib/financial_ping.cc | 24 |
1 files changed, 16 insertions, 8 deletions
diff --git a/rlz/lib/financial_ping.cc b/rlz/lib/financial_ping.cc index aad3db3..9b7e319 100644 --- a/rlz/lib/financial_ping.cc +++ b/rlz/lib/financial_ping.cc @@ -46,6 +46,7 @@ class InternetHandle { #include "base/bind.h" #include "base/message_loop.h" +#include "base/run_loop.h" #include "base/time.h" #include "googleurl/src/gurl.h" #include "net/base/load_flags.h" @@ -194,15 +195,18 @@ namespace { class FinancialPingUrlFetcherDelegate : public net::URLFetcherDelegate { public: - FinancialPingUrlFetcherDelegate(MessageLoop* loop) : loop_(loop) { } + FinancialPingUrlFetcherDelegate(const base::Closure& callback) + : callback_(callback) { + } virtual void OnURLFetchComplete(const net::URLFetcher* source); + private: - MessageLoop* loop_; + base::Closure callback_; }; void FinancialPingUrlFetcherDelegate::OnURLFetchComplete( const net::URLFetcher* source) { - loop_->Quit(); + callback_.Run(); } } // namespace @@ -267,8 +271,12 @@ bool FinancialPing::PingServer(const char* request, std::string* response) { return true; #else // Run a blocking event loop to match the win inet implementation. - MessageLoop loop; - FinancialPingUrlFetcherDelegate delegate(&loop); + scoped_ptr<MessageLoop> message_loop; + // Ensure that we have a MessageLoop. + if (!MessageLoop::current()) + message_loop.reset(new MessageLoop); + base::RunLoop loop; + FinancialPingUrlFetcherDelegate delegate(loop.QuitClosure()); std::string url = base::StringPrintf("http://%s:%d%s", kFinancialServer, kFinancialPort, @@ -289,11 +297,11 @@ bool FinancialPing::PingServer(const char* request, std::string* response) { fetcher->SetRequestContext(g_context); const base::TimeDelta kTimeout = base::TimeDelta::FromMinutes(5); - loop.PostTask( + MessageLoop::current()->PostTask( FROM_HERE, base::Bind(&net::URLFetcher::Start, base::Unretained(fetcher.get()))); - loop.PostNonNestableDelayedTask( - FROM_HERE, MessageLoop::QuitClosure(), kTimeout); + MessageLoop::current()->PostNonNestableDelayedTask( + FROM_HERE, loop.QuitClosure(), kTimeout); loop.Run(); |