OLD | NEW |
---|---|
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef CHROME_BROWSER_UI_GOOGLE_NOW_GOOGLE_NOW_SERVICE_H_ | 5 #ifndef CHROME_BROWSER_UI_GOOGLE_NOW_GOOGLE_NOW_SERVICE_H_ |
6 #define CHROME_BROWSER_UI_GOOGLE_NOW_GOOGLE_NOW_SERVICE_H_ | 6 #define CHROME_BROWSER_UI_GOOGLE_NOW_GOOGLE_NOW_SERVICE_H_ |
7 | 7 |
8 #include "base/timer.h" | 8 #include "base/timer.h" |
9 #include "chrome/browser/profiles/profile_keyed_service.h" | 9 #include "chrome/browser/profiles/profile_keyed_service.h" |
10 | 10 |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
45 // Gets new cards from the server and shows them as notifications. | 45 // Gets new cards from the server and shows them as notifications. |
46 void UpdateCards(); | 46 void UpdateCards(); |
47 | 47 |
48 // Schedules next cards update after the specified delay. | 48 // Schedules next cards update after the specified delay. |
49 void StartWaitingForNextUpdate(base::TimeDelta delay); | 49 void StartWaitingForNextUpdate(base::TimeDelta delay); |
50 void OnWaitingForNextUpdateEnds(); | 50 void OnWaitingForNextUpdateEnds(); |
51 | 51 |
52 // Starts obtaining location of the machine. | 52 // Starts obtaining location of the machine. |
53 void StartObtainingGeolocation(); | 53 void StartObtainingGeolocation(); |
54 void OnLocationObtained(const content::Geoposition& position); | 54 void OnLocationObtained(const content::Geoposition& position); |
55 void OnLocationRequestTimeout(); | |
55 | 56 |
56 // Starts downloading cards from the server. | 57 // Starts downloading cards from the server. If the position's Validate() call |
bulach
2012/12/10 14:25:46
nit: not sure if the last bit add much in here :)
vadimt
2012/12/10 19:09:08
Done.
| |
58 // returns false, this means that the position is not available. | |
57 void StartServerRequest(const content::Geoposition& position); | 59 void StartServerRequest(const content::Geoposition& position); |
58 void OnServerRequestCompleted(net::URLRequest* request, int num_bytes); | 60 void OnServerRequestCompleted(net::URLRequest* request, int num_bytes); |
59 | 61 |
60 // Parses server response. Returns true if the parsing was successful. | 62 // Parses server response. Returns true if the parsing was successful. |
61 static bool ParseServerResponse(const net::URLRequest* request, | 63 static bool ParseServerResponse(const net::URLRequest* request, |
62 int num_bytes, | 64 int num_bytes, |
63 ServerResponse* server_response); | 65 ServerResponse* server_response); |
64 | 66 |
65 // Shows Google Now cards as notifications. | 67 // Shows Google Now cards as notifications. |
66 void ShowNotifications(const ServerResponse& server_response); | 68 void ShowNotifications(const ServerResponse& server_response); |
67 | 69 |
68 // The profile. | 70 // The profile. |
69 Profile* const profile_; | 71 Profile* const profile_; |
70 // Timer to schedule next cards update. | 72 // Timer to schedule next cards update. |
71 base::OneShotTimer<GoogleNowService> next_update_timer_; | 73 base::OneShotTimer<GoogleNowService> next_update_timer_; |
74 // Timer to cancel geolocation requests that take too long. | |
75 base::OneShotTimer<GoogleNowService> geolocation_request_timer_; | |
76 // Weak factory for the geolocation request callback. Used to ensure | |
77 // geolocation request callback is not run after this object is destroyed. | |
78 base::WeakPtrFactory<GoogleNowService> geolocation_request_weak_factory_; | |
John Knottenbelt
2012/12/10 14:30:58
nit: I read this as "a factory that hands out weak
vadimt
2012/12/10 19:09:08
Probably, we'll have other weak pointers here, for
| |
72 | 79 |
73 DISALLOW_COPY_AND_ASSIGN(GoogleNowService); | 80 DISALLOW_COPY_AND_ASSIGN(GoogleNowService); |
74 }; | 81 }; |
75 | 82 |
76 #endif // CHROME_BROWSER_UI_GOOGLE_NOW_GOOGLE_NOW_SERVICE_H_ | 83 #endif // CHROME_BROWSER_UI_GOOGLE_NOW_GOOGLE_NOW_SERVICE_H_ |
OLD | NEW |