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 30 matching lines...) Expand all Loading... | |
41 // Gets new cards from the server and shows them as notifications. | 41 // Gets new cards from the server and shows them as notifications. |
42 void UpdateCards(); | 42 void UpdateCards(); |
43 | 43 |
44 // Schedules next cards update after the specified delay. | 44 // Schedules next cards update after the specified delay. |
45 void StartWaitingForNextUpdate(int64 delay_ms); | 45 void StartWaitingForNextUpdate(int64 delay_ms); |
46 void OnWaitingForNextUpdateEnds(); | 46 void OnWaitingForNextUpdateEnds(); |
47 | 47 |
48 // Starts obtaining location of the machine. | 48 // Starts obtaining location of the machine. |
49 void StartObtainingGeolocation(); | 49 void StartObtainingGeolocation(); |
50 void OnLocationObtained(const content::Geoposition& position); | 50 void OnLocationObtained(const content::Geoposition& position); |
51 void OnLocationRequestTimeout(); | |
51 | 52 |
52 // Starts downloading cards from the server. | 53 // Starts downloading cards from the server. If the position's Validate() call |
skare_
2012/12/07 23:39:00
will callers need to care about existence or retur
vadimt
2012/12/08 00:04:23
This tells to the callers how exactly to specify t
| |
54 // returns false, this means that the position is not available. | |
53 void StartServerRequest(const content::Geoposition& position); | 55 void StartServerRequest(const content::Geoposition& position); |
54 void OnServerRequestCompleted(net::URLRequest* request, int num_bytes); | 56 void OnServerRequestCompleted(net::URLRequest* request, int num_bytes); |
55 | 57 |
56 // Parses server response. Returns true if the parsing was successful. | 58 // Parses server response. Returns true if the parsing was successful. |
57 static bool ParseServerResponse(const net::URLRequest* request, int num_bytes, | 59 static bool ParseServerResponse(const net::URLRequest* request, int num_bytes, |
58 ServerResponse* server_response); | 60 ServerResponse* server_response); |
59 | 61 |
60 // Shows Google Now cards as notifications. | 62 // Shows Google Now cards as notifications. |
61 void ShowNotifications(const ServerResponse& server_response); | 63 void ShowNotifications(const ServerResponse& server_response); |
62 | 64 |
63 // The profile. | 65 // The profile. |
64 Profile* const profile_; | 66 Profile* const profile_; |
65 // Timer to schedule next cards update. | 67 // Timer to schedule next cards update. |
66 base::OneShotTimer<GoogleNowService> next_update_timer_; | 68 base::OneShotTimer<GoogleNowService> next_update_timer_; |
69 // Timer to cancel geolocation requests that take too long. | |
70 base::OneShotTimer<GoogleNowService> geolocation_request_timer_; | |
71 // Weak factory for the geolocation request callback. | |
72 base::WeakPtrFactory<GoogleNowService> geolocation_request_weak_factory_; | |
skare_
2012/12/07 23:39:00
tiny, tiny nit: some similar code uses comments li
vadimt
2012/12/08 00:04:23
Done.
| |
67 | 73 |
68 DISALLOW_COPY_AND_ASSIGN(GoogleNowService); | 74 DISALLOW_COPY_AND_ASSIGN(GoogleNowService); |
69 }; | 75 }; |
70 | 76 |
71 #endif // CHROME_BROWSER_UI_GOOGLE_NOW_GOOGLE_NOW_SERVICE_H_ | 77 #endif // CHROME_BROWSER_UI_GOOGLE_NOW_GOOGLE_NOW_SERVICE_H_ |
OLD | NEW |