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

Unified Diff: chrome/browser/extensions/api/sessions/foreign_session_id.cc

Issue 21022018: Sessions API - previously Session Restore API. Supports restoring currently open foreign windows an… (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: updated Created 7 years, 4 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/extensions/api/sessions/foreign_session_id.cc
diff --git a/net/quic/crypto/source_address_token.cc b/chrome/browser/extensions/api/sessions/foreign_session_id.cc
similarity index 22%
copy from net/quic/crypto/source_address_token.cc
copy to chrome/browser/extensions/api/sessions/foreign_session_id.cc
index d15afebf2a75557f30c6a9a3b724c7cfc1193c44..ab991fd9359df66421065f287801e5d7a87d80c9 100644
--- a/net/quic/crypto/source_address_token.cc
+++ b/chrome/browser/extensions/api/sessions/foreign_session_id.cc
@@ -2,45 +2,33 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include "net/quic/crypto/source_address_token.h"
-
-#include <vector>
+#include "chrome/browser/extensions/api/sessions/foreign_session_id.h"
#include "base/strings/string_number_conversions.h"
-#include "base/strings/string_split.h"
-using std::string;
-using std::vector;
+namespace extensions {
-namespace net {
+const char kIdSeparator = '.';
-SourceAddressToken::SourceAddressToken() {
+ForeignSessionId::ForeignSessionId(const std::string& session_tag, int id)
+ : session_tag_(session_tag), id_(id) {
}
-SourceAddressToken::~SourceAddressToken() {
+ForeignSessionId::ForeignSessionId(const std::string& foreign_session_string) {
+ if (IsForeignSessionId(foreign_session_string)) {
+ std::size_t separator = foreign_session_string.find(kIdSeparator);
+ session_tag_ = foreign_session_string.substr(0, separator);
+ base::StringToInt(foreign_session_string.substr(separator + 1), &id_);
+ }
}
-string SourceAddressToken::SerializeAsString() const {
- return ip_ + " " + base::Int64ToString(timestamp_);
+// static
+bool ForeignSessionId::IsForeignSessionId(const std::string& id) {
+ return id.find(kIdSeparator) != std::string::npos;
}
-bool SourceAddressToken::ParseFromArray(const char* plaintext,
- size_t plaintext_length) {
- string data(plaintext, plaintext_length);
- vector<string> results;
- base::SplitString(data, ' ', &results);
- if (results.size() < 2) {
- return false;
- }
-
- int64 timestamp;
- if (!base::StringToInt64(results[1], &timestamp)) {
- return false;
- }
-
- ip_ = results[0];
- timestamp_ = timestamp;
- return true;
+std::string ForeignSessionId::ToString() {
+ return (session_tag_ + kIdSeparator + base::IntToString(id_));
not at google - send to devlin 2013/08/12 23:51:34 use base::StringPrintf instead
Kristen Dwan 2013/08/15 07:11:56 Done.
}
-} // namespace net
+} // namespace extensions

Powered by Google App Engine
This is Rietveld 408576698