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

Side by Side Diff: google_apis/gcm/engine/checkin_request.h

Issue 261573002: Add checkin activity recording to gcm recorder. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: resolve conflicts. Created 6 years, 7 months 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 unified diff | Download patch
« no previous file with comments | « no previous file | google_apis/gcm/engine/checkin_request.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 GOOGLE_APIS_GCM_ENGINE_CHECKIN_REQUEST_H_ 5 #ifndef GOOGLE_APIS_GCM_ENGINE_CHECKIN_REQUEST_H_
6 #define GOOGLE_APIS_GCM_ENGINE_CHECKIN_REQUEST_H_ 6 #define GOOGLE_APIS_GCM_ENGINE_CHECKIN_REQUEST_H_
7 7
8 #include <string> 8 #include <string>
9 #include <vector> 9 #include <vector>
10 10
11 #include "base/basictypes.h" 11 #include "base/basictypes.h"
12 #include "base/callback.h" 12 #include "base/callback.h"
13 #include "base/memory/weak_ptr.h" 13 #include "base/memory/weak_ptr.h"
14 #include "google_apis/gcm/base/gcm_export.h" 14 #include "google_apis/gcm/base/gcm_export.h"
15 #include "google_apis/gcm/protocol/android_checkin.pb.h" 15 #include "google_apis/gcm/protocol/android_checkin.pb.h"
16 #include "google_apis/gcm/protocol/checkin.pb.h" 16 #include "google_apis/gcm/protocol/checkin.pb.h"
17 #include "net/base/backoff_entry.h" 17 #include "net/base/backoff_entry.h"
18 #include "net/url_request/url_fetcher_delegate.h" 18 #include "net/url_request/url_fetcher_delegate.h"
19 #include "url/gurl.h" 19 #include "url/gurl.h"
20 20
21 namespace net { 21 namespace net {
22 class URLRequestContextGetter; 22 class URLRequestContextGetter;
23 } 23 }
24 24
25 namespace gcm { 25 namespace gcm {
26 26
27 class GCMStatsRecorder;
28
27 // Enables making check-in requests with the GCM infrastructure. When called 29 // Enables making check-in requests with the GCM infrastructure. When called
28 // with android_id and security_token both set to 0 it is an initial check-in 30 // with android_id and security_token both set to 0 it is an initial check-in
29 // used to obtain credentials. These should be persisted and used for subsequent 31 // used to obtain credentials. These should be persisted and used for subsequent
30 // check-ins. 32 // check-ins.
31 class GCM_EXPORT CheckinRequest : public net::URLFetcherDelegate { 33 class GCM_EXPORT CheckinRequest : public net::URLFetcherDelegate {
32 public: 34 public:
33 // A callback function for the checkin request, accepting |checkin_response| 35 // A callback function for the checkin request, accepting |checkin_response|
34 // protobuf. 36 // protobuf.
35 typedef base::Callback<void(const checkin_proto::AndroidCheckinResponse& 37 typedef base::Callback<void(const checkin_proto::AndroidCheckinResponse&
36 checkin_response)> CheckinRequestCallback; 38 checkin_response)> CheckinRequestCallback;
(...skipping 16 matching lines...) Expand all
53 // Account IDs of GAIA accounts related to this device. 55 // Account IDs of GAIA accounts related to this device.
54 std::vector<std::string> account_ids; 56 std::vector<std::string> account_ids;
55 // Information of the Chrome build of this device. 57 // Information of the Chrome build of this device.
56 checkin_proto::ChromeBuildProto chrome_build_proto; 58 checkin_proto::ChromeBuildProto chrome_build_proto;
57 }; 59 };
58 60
59 CheckinRequest(const GURL& checkin_url, 61 CheckinRequest(const GURL& checkin_url,
60 const RequestInfo& request_info, 62 const RequestInfo& request_info,
61 const net::BackoffEntry::Policy& backoff_policy, 63 const net::BackoffEntry::Policy& backoff_policy,
62 const CheckinRequestCallback& callback, 64 const CheckinRequestCallback& callback,
63 net::URLRequestContextGetter* request_context_getter); 65 net::URLRequestContextGetter* request_context_getter,
66 GCMStatsRecorder* recorder);
64 virtual ~CheckinRequest(); 67 virtual ~CheckinRequest();
65 68
66 void Start(); 69 void Start();
67 70
68 // URLFetcherDelegate implementation. 71 // URLFetcherDelegate implementation.
69 virtual void OnURLFetchComplete(const net::URLFetcher* source) OVERRIDE; 72 virtual void OnURLFetchComplete(const net::URLFetcher* source) OVERRIDE;
70 73
71 private: 74 private:
72 // Schedules a retry attempt, informs the backoff of a previous request's 75 // Schedules a retry attempt, informs the backoff of a previous request's
73 // failure when |update_backoff| is true. 76 // failure when |update_backoff| is true.
74 void RetryWithBackoff(bool update_backoff); 77 void RetryWithBackoff(bool update_backoff);
75 78
76 net::URLRequestContextGetter* request_context_getter_; 79 net::URLRequestContextGetter* request_context_getter_;
77 CheckinRequestCallback callback_; 80 CheckinRequestCallback callback_;
78 81
79 net::BackoffEntry backoff_entry_; 82 net::BackoffEntry backoff_entry_;
80 GURL checkin_url_; 83 GURL checkin_url_;
81 scoped_ptr<net::URLFetcher> url_fetcher_; 84 scoped_ptr<net::URLFetcher> url_fetcher_;
82 const RequestInfo request_info_; 85 const RequestInfo request_info_;
83 86
87 // Recorder that records GCM activities for debugging purpose. Not owned.
88 GCMStatsRecorder* recorder_;
89
84 base::WeakPtrFactory<CheckinRequest> weak_ptr_factory_; 90 base::WeakPtrFactory<CheckinRequest> weak_ptr_factory_;
85 91
86 DISALLOW_COPY_AND_ASSIGN(CheckinRequest); 92 DISALLOW_COPY_AND_ASSIGN(CheckinRequest);
87 }; 93 };
88 94
89 } // namespace gcm 95 } // namespace gcm
90 96
91 #endif // GOOGLE_APIS_GCM_ENGINE_CHECKIN_REQUEST_H_ 97 #endif // GOOGLE_APIS_GCM_ENGINE_CHECKIN_REQUEST_H_
OLDNEW
« no previous file with comments | « no previous file | google_apis/gcm/engine/checkin_request.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698