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

Side by Side Diff: components/gcm_driver/instance_id/instance_id_impl.cc

Issue 1128123003: Implement InstanceID API functions. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix test Created 5 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 | « components/gcm_driver/instance_id/instance_id_driver_unittest.cc ('k') | 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 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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 "components/gcm_driver/instance_id/instance_id_impl.h" 5 #include "components/gcm_driver/instance_id/instance_id_impl.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include "base/base64.h" 8 #include "base/base64.h"
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/logging.h" 10 #include "base/logging.h"
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
52 NOTIMPLEMENTED(); 52 NOTIMPLEMENTED();
53 } 53 }
54 54
55 void InstanceIDImpl::DeleteID(const DeleteIDCallback& callback) { 55 void InstanceIDImpl::DeleteID(const DeleteIDCallback& callback) {
56 // TODO(jianli): Delete the ID from the store. 56 // TODO(jianli): Delete the ID from the store.
57 id_.clear(); 57 id_.clear();
58 creation_time_ = base::Time(); 58 creation_time_ = base::Time();
59 59
60 base::MessageLoop::current()->PostTask( 60 base::MessageLoop::current()->PostTask(
61 FROM_HERE, 61 FROM_HERE,
62 base::Bind(callback, this, InstanceID::SUCCESS)); 62 base::Bind(callback, InstanceID::SUCCESS));
63 } 63 }
64 64
65 void InstanceIDImpl::EnsureIDGenerated() { 65 void InstanceIDImpl::EnsureIDGenerated() {
66 if (!id_.empty()) 66 if (!id_.empty())
67 return; 67 return;
68 68
69 // Now produce the ID in the following steps: 69 // Now produce the ID in the following steps:
70 70
71 // 1) Generates the random number in 8 bytes which is required by the server. 71 // 1) Generates the random number in 8 bytes which is required by the server.
72 // We don't want to be strictly cryptographically secure. The server might 72 // We don't want to be strictly cryptographically secure. The server might
(...skipping 15 matching lines...) Expand all
88 std::replace(id_.begin(), id_.end(), '+', '-'); 88 std::replace(id_.begin(), id_.end(), '+', '-');
89 std::replace(id_.begin(), id_.end(), '/', '_'); 89 std::replace(id_.begin(), id_.end(), '/', '_');
90 id_.erase(std::remove(id_.begin(), id_.end(), '='), id_.end()); 90 id_.erase(std::remove(id_.begin(), id_.end(), '='), id_.end());
91 91
92 creation_time_ = base::Time::Now(); 92 creation_time_ = base::Time::Now();
93 93
94 // TODO(jianli): Save the ID to the store. 94 // TODO(jianli): Save the ID to the store.
95 } 95 }
96 96
97 } // namespace instance_id 97 } // namespace instance_id
OLDNEW
« no previous file with comments | « components/gcm_driver/instance_id/instance_id_driver_unittest.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698