summaryrefslogtreecommitdiffstats
path: root/rlz/lib
diff options
context:
space:
mode:
authorivankr@chromium.org <ivankr@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-11-09 11:04:55 +0000
committerivankr@chromium.org <ivankr@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-11-09 11:04:55 +0000
commit7d21a6b37c15011033601f49150e280c2417ce1d (patch)
tree8a893f4b29f773643df8bdef5102b77cf55627a8 /rlz/lib
parentc80ca12f3e74e8d54653c312bbd3c92afd0fee55 (diff)
downloadchromium_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')
-rw-r--r--rlz/lib/financial_ping.cc24
-rw-r--r--rlz/lib/lib_values.cc6
-rw-r--r--rlz/lib/rlz_enums.h15
-rw-r--r--rlz/lib/rlz_lib.cc10
-rw-r--r--rlz/lib/rlz_lib.h12
-rw-r--r--rlz/lib/rlz_value_store.h11
6 files changed, 59 insertions, 19 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();
diff --git a/rlz/lib/lib_values.cc b/rlz/lib/lib_values.cc
index 68b91d8..9b2c850 100644
--- a/rlz/lib/lib_values.cc
+++ b/rlz/lib/lib_values.cc
@@ -95,9 +95,9 @@ const char* GetAccessPointName(AccessPoint point) {
case PARTNER_AP_5: return "V5";
case CHROME_MAC_OMNIBOX: return "C5";
case CHROME_MAC_HOME_PAGE: return "C6";
- case UNDEFINED_AP_J: return "RJ";
- case UNDEFINED_AP_K: return "RK";
- case UNDEFINED_AP_L: return "RL";
+ case CHROMEOS_OMNIBOX: return "CA";
+ case CHROMEOS_HOME_PAGE: return "CB";
+ case CHROMEOS_RESERVED: return "CC";
case UNDEFINED_AP_M: return "RM";
case UNDEFINED_AP_N: return "RN";
case UNDEFINED_AP_O: return "RO";
diff --git a/rlz/lib/rlz_enums.h b/rlz/lib/rlz_enums.h
index 630db11..0fd0513 100644
--- a/rlz/lib/rlz_enums.h
+++ b/rlz/lib/rlz_enums.h
@@ -21,8 +21,8 @@ enum AccessPoint {
GD_SEARCH_GADGET, // Search gadget when GD in sidebar mode.
GD_WEB_SERVER, // Boxes in web pages shown by local GD web server.
GD_OUTLOOK, // Search box installed within outlook by GD.
- CHROME_OMNIBOX, // Chrome searches through the address bar omnibox.
- CHROME_HOME_PAGE, // Chrome searches through Google as home page.
+ CHROME_OMNIBOX, // Chrome searches through the address bar omnibox (Win).
+ CHROME_HOME_PAGE, // Chrome searches through Google as home page (Win).
FFTB2_BOX, // Firefox Toolbar v2 Search Box.
FFTB3_BOX, // Firefox Toolbar v3+ Search Box.
PINYIN_IME_BHO, // Goopy Input Method Editor BHO (Pinyin).
@@ -55,15 +55,16 @@ enum AccessPoint {
PARTNER_AP_4,
PARTNER_AP_5,
- CHROME_MAC_OMNIBOX, // Chrome searches through the address bar omnibox (mac).
- CHROME_MAC_HOME_PAGE,// Chrome searches through Google as home page (mac).
+ CHROME_MAC_OMNIBOX, // Chrome searches through the address bar omnibox (Mac).
+ CHROME_MAC_HOME_PAGE,// Chrome searches through Google as home page (Mac).
+
+ CHROMEOS_OMNIBOX, // ChromeOS searches through the address bar omnibox.
+ CHROMEOS_HOME_PAGE, // ChromeOS searches through Google as home page.
+ CHROMEOS_RESERVED, // Reserved for ChromeOS.
// Unclaimed access points - should be used first before creating new APs.
// Please also make sure you re-name the enum before using an unclaimed value;
// this acts as a check to ensure we don't have collisions.
- UNDEFINED_AP_J,
- UNDEFINED_AP_K,
- UNDEFINED_AP_L,
UNDEFINED_AP_M,
UNDEFINED_AP_N,
UNDEFINED_AP_O,
diff --git a/rlz/lib/rlz_lib.cc b/rlz/lib/rlz_lib.cc
index 8a1b729..0f67cd4 100644
--- a/rlz/lib/rlz_lib.cc
+++ b/rlz/lib/rlz_lib.cc
@@ -16,6 +16,10 @@
#include "rlz/lib/rlz_value_store.h"
#include "rlz/lib/string_utils.h"
+#if defined(OS_CHROMEOS)
+#include "rlz/chromeos/lib/rlz_value_store_chromeos.h"
+#endif // defined(OS_CHROMEOS)
+
namespace {
// Event information returned from ping response.
@@ -214,6 +218,12 @@ bool SetURLRequestContext(net::URLRequestContextGetter* context) {
}
#endif
+#if defined(OS_CHROMEOS)
+void RLZ_LIB_API SetIOTaskRunner(base::SequencedTaskRunner* io_task_runner) {
+ RlzValueStoreChromeOS::SetIOTaskRunner(io_task_runner);
+}
+#endif
+
bool GetProductEventsAsCgi(Product product, char* cgi, size_t cgi_size) {
if (!cgi || cgi_size <= 0) {
ASSERT_STRING("GetProductEventsAsCgi: Invalid buffer");
diff --git a/rlz/lib/rlz_lib.h b/rlz/lib/rlz_lib.h
index 1f8be5c..a840741 100644
--- a/rlz/lib/rlz_lib.h
+++ b/rlz/lib/rlz_lib.h
@@ -44,6 +44,12 @@
#endif
#endif
+#if defined(OS_CHROMEOS)
+namespace base {
+class SequencedTaskRunner;
+} // namespace base
+#endif
+
#if defined(RLZ_NETWORK_IMPLEMENTATION_CHROME_NET)
namespace net {
class URLRequestContextGetter;
@@ -71,6 +77,12 @@ const size_t kMaxPingResponseLength = 0x4000; // 16K
bool RLZ_LIB_API SetURLRequestContext(net::URLRequestContextGetter* context);
#endif
+#if defined(OS_CHROMEOS)
+// Set the MessageLoopProxy used by RLZ store to run I/O tasks on. Should be
+// called before any other API calls.
+void RLZ_LIB_API SetIOTaskRunner(base::SequencedTaskRunner* io_task_runner);
+#endif
+
// RLZ storage functions.
// Get all the events reported by this product as a CGI string to append to
diff --git a/rlz/lib/rlz_value_store.h b/rlz/lib/rlz_value_store.h
index ab7279a..807f100 100644
--- a/rlz/lib/rlz_value_store.h
+++ b/rlz/lib/rlz_value_store.h
@@ -95,7 +95,12 @@ class ScopedRlzValueStoreLock {
RlzValueStore* GetStore();
private:
+#if defined(OS_WIN) || defined(OS_MACOSX)
+ // On ChromeOS, there is a singleton instance of RlzValueStore.
scoped_ptr<RlzValueStore> store_;
+#elif defined(OS_CHROMEOS)
+ class RlzValueStoreChromeOS* store_;
+#endif
#if defined(OS_WIN)
LibMutex lock_;
#elif defined(OS_MACOSX)
@@ -103,11 +108,15 @@ class ScopedRlzValueStoreLock {
#endif
};
-#if defined(OS_MACOSX)
+#if defined(OS_MACOSX) || defined(OS_CHROMEOS)
namespace testing {
// Prefix |directory| to the path where the RLZ data file lives, for tests.
void SetRlzStoreDirectory(const FilePath& directory);
+} // namespace testing
+#endif // defined(OS_MACOSX) || defined(OS_CHROMEOS)
+#if defined(OS_MACOSX)
+namespace testing {
// Returns the path of the plist file used as data store.
std::string RlzPlistFilenameStr();
} // namespace testing