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

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

Issue 202083005: Add activity recording capability to gcm internals page. User can refresh, start/stop recording, an… (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: . Created 6 years, 9 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
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/gcm_stats_recorder.h"
15 #include "google_apis/gcm/protocol/android_checkin.pb.h" 16 #include "google_apis/gcm/protocol/android_checkin.pb.h"
16 #include "net/base/backoff_entry.h" 17 #include "net/base/backoff_entry.h"
17 #include "net/url_request/url_fetcher_delegate.h" 18 #include "net/url_request/url_fetcher_delegate.h"
18 19
19 namespace net { 20 namespace net {
20 class URLRequestContextGetter; 21 class URLRequestContextGetter;
21 } 22 }
22 23
23 namespace gcm { 24 namespace gcm {
24 25
25 // Enables making check-in requests with the GCM infrastructure. When called 26 // Enables making check-in requests with the GCM infrastructure. When called
26 // with android_id and security_token both set to 0 it is an initial check-in 27 // with android_id and security_token both set to 0 it is an initial check-in
27 // used to obtain credentials. These should be persisted and used for subsequent 28 // used to obtain credentials. These should be persisted and used for subsequent
28 // check-ins. 29 // check-ins.
29 class GCM_EXPORT CheckinRequest : public net::URLFetcherDelegate { 30 class GCM_EXPORT CheckinRequest : public net::URLFetcherDelegate {
30 public: 31 public:
31 // A callback function for the checkin request, accepting |android_id| and 32 // A callback function for the checkin request, accepting |android_id| and
32 // |security_token|. 33 // |security_token|.
33 typedef base::Callback<void(uint64 android_id, uint64 security_token)> 34 typedef base::Callback<void(uint64 android_id, uint64 security_token)>
34 CheckinRequestCallback; 35 CheckinRequestCallback;
35 36
36 CheckinRequest(const CheckinRequestCallback& callback, 37 CheckinRequest(const CheckinRequestCallback& callback,
37 const net::BackoffEntry::Policy& backoff_policy, 38 const net::BackoffEntry::Policy& backoff_policy,
38 const checkin_proto::ChromeBuildProto& chrome_build_proto, 39 const checkin_proto::ChromeBuildProto& chrome_build_proto,
39 uint64 android_id, 40 uint64 android_id,
40 uint64 security_token, 41 uint64 security_token,
41 const std::vector<std::string>& account_ids, 42 const std::vector<std::string>& account_ids,
42 net::URLRequestContextGetter* request_context_getter); 43 net::URLRequestContextGetter* request_context_getter,
44 GCMStatsRecorder* recorder);
43 virtual ~CheckinRequest(); 45 virtual ~CheckinRequest();
44 46
45 void Start(); 47 void Start();
46 48
47 // URLFetcherDelegate implementation. 49 // URLFetcherDelegate implementation.
48 virtual void OnURLFetchComplete(const net::URLFetcher* source) OVERRIDE; 50 virtual void OnURLFetchComplete(const net::URLFetcher* source) OVERRIDE;
49 51
50 private: 52 private:
51 // Schedules a retry attempt, informs the backoff of a previous request's 53 // Schedules a retry attempt, informs the backoff of a previous request's
52 // failure when |update_backoff| is true. 54 // failure when |update_backoff| is true.
53 void RetryWithBackoff(bool update_backoff); 55 void RetryWithBackoff(bool update_backoff);
54 56
55 net::URLRequestContextGetter* request_context_getter_; 57 net::URLRequestContextGetter* request_context_getter_;
56 CheckinRequestCallback callback_; 58 CheckinRequestCallback callback_;
57 59
58 net::BackoffEntry backoff_entry_; 60 net::BackoffEntry backoff_entry_;
59 scoped_ptr<net::URLFetcher> url_fetcher_; 61 scoped_ptr<net::URLFetcher> url_fetcher_;
60 const checkin_proto::ChromeBuildProto chrome_build_proto_; 62 const checkin_proto::ChromeBuildProto chrome_build_proto_;
61 const uint64 android_id_; 63 const uint64 android_id_;
62 const uint64 security_token_; 64 const uint64 security_token_;
63 const std::vector<std::string> account_ids_; 65 const std::vector<std::string> account_ids_;
64 66
67 // GCM internal stats recorder instance. Not owned.
68 GCMStatsRecorder* recorder_;
69
65 base::WeakPtrFactory<CheckinRequest> weak_ptr_factory_; 70 base::WeakPtrFactory<CheckinRequest> weak_ptr_factory_;
66 71
67 DISALLOW_COPY_AND_ASSIGN(CheckinRequest); 72 DISALLOW_COPY_AND_ASSIGN(CheckinRequest);
68 }; 73 };
69 74
70 } // namespace gcm 75 } // namespace gcm
71 76
72 #endif // GOOGLE_APIS_GCM_ENGINE_CHECKIN_REQUEST_H_ 77 #endif // GOOGLE_APIS_GCM_ENGINE_CHECKIN_REQUEST_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698