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

Side by Side Diff: google_apis/gcm/engine/registration_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_REGISTRATION_REQUEST_H_ 5 #ifndef GOOGLE_APIS_GCM_ENGINE_REGISTRATION_REQUEST_H_
6 #define GOOGLE_APIS_GCM_ENGINE_REGISTRATION_REQUEST_H_ 6 #define GOOGLE_APIS_GCM_ENGINE_REGISTRATION_REQUEST_H_
7 7
8 #include <map> 8 #include <map>
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/logging.h"
jianli 2014/03/18 23:53:23 Why is this needed?
juyik 2014/03/20 01:09:53 Done.
13 #include "base/memory/ref_counted.h" 14 #include "base/memory/ref_counted.h"
14 #include "base/memory/scoped_ptr.h" 15 #include "base/memory/scoped_ptr.h"
15 #include "base/memory/weak_ptr.h" 16 #include "base/memory/weak_ptr.h"
16 #include "google_apis/gcm/base/gcm_export.h" 17 #include "google_apis/gcm/base/gcm_export.h"
18 #include "google_apis/gcm/gcm_stats_recorder.h"
17 #include "net/base/backoff_entry.h" 19 #include "net/base/backoff_entry.h"
18 #include "net/url_request/url_fetcher_delegate.h" 20 #include "net/url_request/url_fetcher_delegate.h"
19 21
20 namespace net { 22 namespace net {
21 class URLRequestContextGetter; 23 class URLRequestContextGetter;
22 } 24 }
23 25
24 namespace gcm { 26 namespace gcm {
25 27
28 class GCMStatsRecorder;
29
26 // Registration request is used to obtain registration IDs for applications that 30 // Registration request is used to obtain registration IDs for applications that
27 // want to use GCM. It requires a set of parameters to be specified to identify 31 // want to use GCM. It requires a set of parameters to be specified to identify
28 // the Chrome instance, the user, the application and a set of senders that will 32 // the Chrome instance, the user, the application and a set of senders that will
29 // be authorized to address the application using it's assigned registration ID. 33 // be authorized to address the application using it's assigned registration ID.
30 class GCM_EXPORT RegistrationRequest : public net::URLFetcherDelegate { 34 class GCM_EXPORT RegistrationRequest : public net::URLFetcherDelegate {
31 public: 35 public:
32 // This enum is also used in an UMA histogram (GCMRegistrationRequestStatus 36 // This enum is also used in an UMA histogram (GCMRegistrationRequestStatus
33 // enum defined in tools/metrics/histograms/histogram.xml). Hence the entries 37 // enum defined in tools/metrics/histograms/histogram.xml). Hence the entries
34 // here shouldn't be deleted or re-ordered and new ones should be added to 38 // here shouldn't be deleted or re-ordered and new ones should be added to
35 // the end. 39 // the end.
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
75 std::string cert; 79 std::string cert;
76 // List of IDs of senders. Allowed up to 100. 80 // List of IDs of senders. Allowed up to 100.
77 std::vector<std::string> sender_ids; 81 std::vector<std::string> sender_ids;
78 }; 82 };
79 83
80 RegistrationRequest( 84 RegistrationRequest(
81 const RequestInfo& request_info, 85 const RequestInfo& request_info,
82 const net::BackoffEntry::Policy& backoff_policy, 86 const net::BackoffEntry::Policy& backoff_policy,
83 const RegistrationCallback& callback, 87 const RegistrationCallback& callback,
84 int max_retry_count, 88 int max_retry_count,
85 scoped_refptr<net::URLRequestContextGetter> request_context_getter); 89 scoped_refptr<net::URLRequestContextGetter> request_context_getter,
90 GCMStatsRecorder* recorder);
86 virtual ~RegistrationRequest(); 91 virtual ~RegistrationRequest();
87 92
88 void Start(); 93 void Start();
89 94
90 // URLFetcherDelegate implementation. 95 // URLFetcherDelegate implementation.
91 virtual void OnURLFetchComplete(const net::URLFetcher* source) OVERRIDE; 96 virtual void OnURLFetchComplete(const net::URLFetcher* source) OVERRIDE;
92 97
93 private: 98 private:
94 // Schedules a retry attempt, informs the backoff of a previous request's 99 // Schedules a retry attempt, informs the backoff of a previous request's
95 // failure, when |update_backoff| is true. 100 // failure, when |update_backoff| is true.
96 void RetryWithBackoff(bool update_backoff); 101 void RetryWithBackoff(bool update_backoff);
97 102
98 // Parse the response returned by the URL fetcher into token, and returns the 103 // Parse the response returned by the URL fetcher into token, and returns the
99 // status. 104 // status.
100 Status ParseResponse(const net::URLFetcher* source, std::string* token); 105 Status ParseResponse(const net::URLFetcher* source, std::string* token);
101 106
102 RegistrationCallback callback_; 107 RegistrationCallback callback_;
103 RequestInfo request_info_; 108 RequestInfo request_info_;
104 109
105 net::BackoffEntry backoff_entry_; 110 net::BackoffEntry backoff_entry_;
106 scoped_refptr<net::URLRequestContextGetter> request_context_getter_; 111 scoped_refptr<net::URLRequestContextGetter> request_context_getter_;
107 scoped_ptr<net::URLFetcher> url_fetcher_; 112 scoped_ptr<net::URLFetcher> url_fetcher_;
108 int retries_left_; 113 int retries_left_;
109 114
115 // GCM internal stats recorder instance. Not owned.
116 GCMStatsRecorder* recorder_;
117
110 base::WeakPtrFactory<RegistrationRequest> weak_ptr_factory_; 118 base::WeakPtrFactory<RegistrationRequest> weak_ptr_factory_;
111 119
112 DISALLOW_COPY_AND_ASSIGN(RegistrationRequest); 120 DISALLOW_COPY_AND_ASSIGN(RegistrationRequest);
113 }; 121 };
114 122
115 } // namespace gcm 123 } // namespace gcm
116 124
117 #endif // GOOGLE_APIS_GCM_ENGINE_REGISTRATION_REQUEST_H_ 125 #endif // GOOGLE_APIS_GCM_ENGINE_REGISTRATION_REQUEST_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698