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

Unified Diff: chrome/browser/ui/google_now/google_now_service.h

Issue 11471046: Fetching Google Now Notifications data from the server (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fixing a leak found by compiler. Created 8 years 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 | « no previous file | chrome/browser/ui/google_now/google_now_service.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/ui/google_now/google_now_service.h
diff --git a/chrome/browser/ui/google_now/google_now_service.h b/chrome/browser/ui/google_now/google_now_service.h
index a48f4017a81b723cd827a26804b6c280740ce0ca..c4c316a46f91c51d3df09c9f834af6c224535530 100644
--- a/chrome/browser/ui/google_now/google_now_service.h
+++ b/chrome/browser/ui/google_now/google_now_service.h
@@ -7,6 +7,7 @@
#include "base/timer.h"
#include "chrome/browser/profiles/profile_keyed_service.h"
+#include "net/url_request/url_fetcher_delegate.h"
class Profile;
@@ -18,10 +19,6 @@ namespace content {
struct Geoposition;
}
-namespace net {
-class URLRequest;
-}
-
// The Google Now service gets Google Now cards from the server and shows them
// as Chrome notifications.
// The service performs periodic updating of Google Now cards.
@@ -29,7 +26,8 @@ class URLRequest;
// 1. Obtaining the location of the machine (asynchronous);
// 2. Making a server request (asynchronous);
// 3. Showing the cards as notifications.
-class GoogleNowService : public ProfileKeyedService {
+class GoogleNowService : public ProfileKeyedService,
+ public net::URLFetcherDelegate {
public:
// Must call Init after construction.
explicit GoogleNowService(Profile* profile);
@@ -54,18 +52,22 @@ class GoogleNowService : public ProfileKeyedService {
void OnLocationObtained(const content::Geoposition& position);
void OnLocationRequestTimeout();
+ // Builds a URL for a server request.
+ static std::string BuildRequestURL(const content::Geoposition& position);
+
// Starts downloading cards from the server.
void StartServerRequest(const content::Geoposition& position);
- void OnServerRequestCompleted(net::URLRequest* request, int num_bytes);
// Parses server response. Returns true if the parsing was successful.
- static bool ParseServerResponse(const net::URLRequest* request,
- int num_bytes,
+ static bool ParseServerResponse(const std::string& response_string,
ServerResponse* server_response);
// Shows Google Now cards as notifications.
void ShowNotifications(const ServerResponse& server_response);
+ // URLFetcherDelegate
+ virtual void OnURLFetchComplete(const net::URLFetcher* source) OVERRIDE;
+
// The profile.
Profile* const profile_;
// Timer to schedule next cards update.
@@ -75,6 +77,8 @@ class GoogleNowService : public ProfileKeyedService {
// Weak factory for the geolocation request callback. Used to ensure
// geolocation request callback is not run after this object is destroyed.
base::WeakPtrFactory<GoogleNowService> geolocation_request_weak_factory_;
+ // Fetcher for Google Now cards.
+ scoped_ptr<net::URLFetcher> fetcher_;
DISALLOW_COPY_AND_ASSIGN(GoogleNowService);
};
« no previous file with comments | « no previous file | chrome/browser/ui/google_now/google_now_service.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698