Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(458)

Unified Diff: rlz/lib/financial_ping.cc

Issue 11365107: [cros] RlzValueStore implementation for ChromeOS. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Revert to Chrome-only Created 8 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « rlz/chromeos/lib/rlz_value_store_chromeos.cc ('k') | rlz/lib/lib_values.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: rlz/lib/financial_ping.cc
diff --git a/rlz/lib/financial_ping.cc b/rlz/lib/financial_ping.cc
index aad3db33b8ca0b6ff104abc00b8c9171231b7bad..9b7e3194a0ce01e4b0d89d4d5b72716810493e44 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();
« no previous file with comments | « rlz/chromeos/lib/rlz_value_store_chromeos.cc ('k') | rlz/lib/lib_values.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698