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

Side by Side Diff: google_apis/gcm/gcm_client_impl.cc

Issue 164183008: [GCM] Update backoff policy to be more conservative. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 10 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 #include "google_apis/gcm/gcm_client_impl.h" 5 #include "google_apis/gcm/gcm_client_impl.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/files/file_path.h" 8 #include "base/files/file_path.h"
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "base/memory/scoped_ptr.h" 10 #include "base/memory/scoped_ptr.h"
11 #include "base/message_loop/message_loop.h" 11 #include "base/message_loop/message_loop.h"
12 #include "base/sequenced_task_runner.h" 12 #include "base/sequenced_task_runner.h"
13 #include "base/time/default_clock.h" 13 #include "base/time/default_clock.h"
14 #include "google_apis/gcm/base/mcs_message.h" 14 #include "google_apis/gcm/base/mcs_message.h"
15 #include "google_apis/gcm/base/mcs_util.h" 15 #include "google_apis/gcm/base/mcs_util.h"
16 #include "google_apis/gcm/engine/checkin_request.h" 16 #include "google_apis/gcm/engine/checkin_request.h"
17 #include "google_apis/gcm/engine/connection_factory_impl.h" 17 #include "google_apis/gcm/engine/connection_factory_impl.h"
18 #include "google_apis/gcm/engine/gcm_store_impl.h" 18 #include "google_apis/gcm/engine/gcm_store_impl.h"
19 #include "google_apis/gcm/engine/mcs_client.h" 19 #include "google_apis/gcm/engine/mcs_client.h"
20 #include "google_apis/gcm/engine/registration_request.h" 20 #include "google_apis/gcm/engine/registration_request.h"
21 #include "google_apis/gcm/protocol/mcs.pb.h" 21 #include "google_apis/gcm/protocol/mcs.pb.h"
22 #include "net/http/http_network_session.h" 22 #include "net/http/http_network_session.h"
23 #include "net/url_request/url_request_context.h" 23 #include "net/url_request/url_request_context.h"
24 #include "url/gurl.h" 24 #include "url/gurl.h"
25 25
26 namespace gcm { 26 namespace gcm {
27 27
28 namespace { 28 namespace {
29 29
30 // Backoff policy. Shared across reconnection logic and checkin/registration 30 // Backoff policy. Shared across reconnection logic and checkin/registration
fgorski 2014/02/14 18:36:29 also unregistration
Nicolas Zea 2014/02/14 18:39:47 Done.
31 // retries. 31 // retries.
32 // Note: In order to ensure a minimum of 20 seconds between server errors (for
33 // server reasons), we have a 30s += 10s (33%) jitter initial backoff.
fgorski 2014/02/14 18:36:29 +/- insted of +=?
Nicolas Zea 2014/02/14 18:39:47 Done.
32 // TODO(zea): consider sharing/synchronizing the scheduling of backoff retries 34 // TODO(zea): consider sharing/synchronizing the scheduling of backoff retries
33 // themselves. 35 // themselves.
34 const net::BackoffEntry::Policy kDefaultBackoffPolicy = { 36 const net::BackoffEntry::Policy kDefaultBackoffPolicy = {
35 // Number of initial errors (in sequence) to ignore before applying 37 // Number of initial errors (in sequence) to ignore before applying
36 // exponential back-off rules. 38 // exponential back-off rules.
37 0, 39 0,
38 40
39 // Initial delay for exponential back-off in ms. 41 // Initial delay for exponential back-off in ms.
40 15000, // 15 seconds. 42 1000 * 30, // 30 seconds.
fgorski 2014/02/14 18:36:29 nit: would big-endian be more intuitive? 30* 1000
Nicolas Zea 2014/02/14 18:39:47 Done.
41 43
42 // Factor by which the waiting time will be multiplied. 44 // Factor by which the waiting time will be multiplied.
43 2, 45 2,
44 46
45 // Fuzzing percentage. ex: 10% will spread requests randomly 47 // Fuzzing percentage. ex: 10% will spread requests randomly
46 // between 90%-100% of the calculated time. 48 // between 90%-100% of the calculated time.
47 0.5, // 50%. 49 0.33, // 33%.
48 50
49 // Maximum amount of time we are willing to delay our request in ms. 51 // Maximum amount of time we are willing to delay our request in ms.
50 1000 * 60 * 5, // 5 minutes. 52 1000 * 60 * 10, // 10 minutes.
fgorski 2014/02/14 18:36:29 nit: same here, big endian?
Nicolas Zea 2014/02/14 18:39:47 Done.
51 53
52 // Time to keep an entry from being discarded even when it 54 // Time to keep an entry from being discarded even when it
53 // has no significant state, -1 to never discard. 55 // has no significant state, -1 to never discard.
54 -1, 56 -1,
55 57
56 // Don't use initial delay unless the last request was an error. 58 // Don't use initial delay unless the last request was an error.
57 false, 59 false,
58 }; 60 };
59 61
60 // Indicates a message type of the received message. 62 // Indicates a message type of the received message.
(...skipping 389 matching lines...) Expand 10 before | Expand all | Expand 10 after
450 if (iter != incoming_message.data.end()) 452 if (iter != incoming_message.data.end())
451 message_id = iter->second; 453 message_id = iter->second;
452 delegate->OnMessageSendError(app_id, message_id, SERVER_ERROR); 454 delegate->OnMessageSendError(app_id, message_id, SERVER_ERROR);
453 } 455 }
454 456
455 void GCMClientImpl::SetMCSClientForTesting(scoped_ptr<MCSClient> mcs_client) { 457 void GCMClientImpl::SetMCSClientForTesting(scoped_ptr<MCSClient> mcs_client) {
456 mcs_client_ = mcs_client.Pass(); 458 mcs_client_ = mcs_client.Pass();
457 } 459 }
458 460
459 } // namespace gcm 461 } // namespace gcm
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698