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

Side by Side Diff: chrome/browser/autocomplete/search_provider.cc

Issue 289043007: [AiS] Make base64 encoding URL-safe. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 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 | 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 2012 The Chromium Authors. All rights reserved. 1 // Copyright 2012 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 "chrome/browser/autocomplete/search_provider.h" 5 #include "chrome/browser/autocomplete/search_provider.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <cmath> 8 #include <cmath>
9 9
10 #include "base/base64.h" 10 #include "base/base64.h"
(...skipping 1134 matching lines...) Expand 10 before | Expand all | Expand 10 after
1145 } 1145 }
1146 1146
1147 std::string SearchProvider::GetSessionToken() { 1147 std::string SearchProvider::GetSessionToken() {
1148 base::TimeTicks current_time(base::TimeTicks::Now()); 1148 base::TimeTicks current_time(base::TimeTicks::Now());
1149 // Renew token if it expired. 1149 // Renew token if it expired.
1150 if (current_time > token_expiration_time_) { 1150 if (current_time > token_expiration_time_) {
1151 const size_t kTokenBytes = 12; 1151 const size_t kTokenBytes = 12;
1152 std::string raw_data; 1152 std::string raw_data;
1153 base::RandBytes(WriteInto(&raw_data, kTokenBytes + 1), kTokenBytes); 1153 base::RandBytes(WriteInto(&raw_data, kTokenBytes + 1), kTokenBytes);
1154 base::Base64Encode(raw_data, &current_token_); 1154 base::Base64Encode(raw_data, &current_token_);
1155
1156 // Make the base64 encoded value URL and filename safe(see RFC 3548).
1157 std::replace(current_token_.begin(), current_token_.end(), '+', '-');
1158 std::replace(current_token_.begin(), current_token_.end(), '/', '_');
1155 } 1159 }
1156 1160
1157 // Extend expiration time another 60 seconds. 1161 // Extend expiration time another 60 seconds.
1158 token_expiration_time_ = current_time + base::TimeDelta::FromSeconds(60); 1162 token_expiration_time_ = current_time + base::TimeDelta::FromSeconds(60);
1159 1163
1160 return current_token_; 1164 return current_token_;
1161 } 1165 }
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