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

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

Issue 147193003: [GCM] Fix memory leaks (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix windows Created 6 years, 11 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 | « google_apis/gcm/gcm_client_impl.h ('k') | google_apis/gcm/tools/mcs_probe.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 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"
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
54 user_list_.reset(new UserList(gcm_store_.get())); 54 user_list_.reset(new UserList(gcm_store_.get()));
55 connection_factory_.reset(new ConnectionFactoryImpl(GURL(kMCSEndpoint), 55 connection_factory_.reset(new ConnectionFactoryImpl(GURL(kMCSEndpoint),
56 network_session_, 56 network_session_,
57 net_log_.net_log())); 57 net_log_.net_log()));
58 mcs_client_.reset(new MCSClient(&clock_, 58 mcs_client_.reset(new MCSClient(&clock_,
59 connection_factory_.get(), 59 connection_factory_.get(),
60 gcm_store_.get())); 60 gcm_store_.get()));
61 state_ = LOADING; 61 state_ = LOADING;
62 } 62 }
63 63
64 void GCMClientImpl::OnLoadCompleted(const GCMStore::LoadResult& result) { 64 void GCMClientImpl::OnLoadCompleted(scoped_ptr<GCMStore::LoadResult> result) {
65 DCHECK_EQ(LOADING, state_); 65 DCHECK_EQ(LOADING, state_);
66 66
67 if (!result.success) { 67 if (!result->success) {
68 ResetState(); 68 ResetState();
69 return; 69 return;
70 } 70 }
71 71
72 user_list_->Initialize(result.serial_number_mappings); 72 user_list_->Initialize(result->serial_number_mappings);
73 73
74 device_checkin_info_.android_id = result.device_android_id; 74 device_checkin_info_.android_id = result->device_android_id;
75 device_checkin_info_.secret = result.device_security_token; 75 device_checkin_info_.secret = result->device_security_token;
76 InitializeMCSClient(result); 76 InitializeMCSClient(result.Pass());
77 if (!device_checkin_info_.IsValid()) { 77 if (!device_checkin_info_.IsValid()) {
78 device_checkin_info_.Reset(); 78 device_checkin_info_.Reset();
79 state_ = INITIAL_DEVICE_CHECKIN; 79 state_ = INITIAL_DEVICE_CHECKIN;
80 StartCheckin(0, device_checkin_info_); 80 StartCheckin(0, device_checkin_info_);
81 } else { 81 } else {
82 state_ = READY; 82 state_ = READY;
83 StartMCSLogin(); 83 StartMCSLogin();
84 } 84 }
85 } 85 }
86 86
87 void GCMClientImpl::InitializeMCSClient(const GCMStore::LoadResult& result) { 87 void GCMClientImpl::InitializeMCSClient(
88 scoped_ptr<GCMStore::LoadResult> result) {
88 mcs_client_->Initialize( 89 mcs_client_->Initialize(
89 base::Bind(&GCMClientImpl::OnMCSError, base::Unretained(this)), 90 base::Bind(&GCMClientImpl::OnMCSError, base::Unretained(this)),
90 base::Bind(&GCMClientImpl::OnMessageReceivedFromMCS, 91 base::Bind(&GCMClientImpl::OnMessageReceivedFromMCS,
91 base::Unretained(this)), 92 base::Unretained(this)),
92 base::Bind(&GCMClientImpl::OnMessageSentToMCS, base::Unretained(this)), 93 base::Bind(&GCMClientImpl::OnMessageSentToMCS, base::Unretained(this)),
93 result); 94 result.Pass());
94 } 95 }
95 96
96 void GCMClientImpl::OnFirstTimeDeviceCheckinCompleted( 97 void GCMClientImpl::OnFirstTimeDeviceCheckinCompleted(
97 const CheckinInfo& checkin_info) { 98 const CheckinInfo& checkin_info) {
98 DCHECK(!device_checkin_info_.IsValid()); 99 DCHECK(!device_checkin_info_.IsValid());
99 100
100 state_ = READY; 101 state_ = READY;
101 device_checkin_info_.android_id = checkin_info.android_id; 102 device_checkin_info_.android_id = checkin_info.android_id;
102 device_checkin_info_.secret = checkin_info.secret; 103 device_checkin_info_.secret = checkin_info.secret;
103 gcm_store_->SetDeviceCredentials( 104 gcm_store_->SetDeviceCredentials(
(...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after
287 } 288 }
288 289
289 void GCMClientImpl::NotifyDelegateOnMessageReceived( 290 void GCMClientImpl::NotifyDelegateOnMessageReceived(
290 GCMClient::Delegate* delegate, 291 GCMClient::Delegate* delegate,
291 const std::string& app_id, 292 const std::string& app_id,
292 const IncomingMessage& incoming_message) { 293 const IncomingMessage& incoming_message) {
293 delegate->OnMessageReceived(app_id, incoming_message); 294 delegate->OnMessageReceived(app_id, incoming_message);
294 } 295 }
295 296
296 } // namespace gcm 297 } // namespace gcm
OLDNEW
« no previous file with comments | « google_apis/gcm/gcm_client_impl.h ('k') | google_apis/gcm/tools/mcs_probe.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698