diff options
author | simonmorris@chromium.org <simonmorris@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-10-19 00:45:11 +0000 |
---|---|---|
committer | simonmorris@chromium.org <simonmorris@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-10-19 00:45:11 +0000 |
commit | 76d63208062b33f0b03a45982814346bd8e3e115 (patch) | |
tree | 7bbd273c30bd3ff5a6b6c8aa468fe2345fa14b1c /remoting | |
parent | 52572a1e5ee885ec187b5022612f7529d002d74d (diff) | |
download | chromium_src-76d63208062b33f0b03a45982814346bd8e3e115.zip chromium_src-76d63208062b33f0b03a45982814346bd8e3e115.tar.gz chromium_src-76d63208062b33f0b03a45982814346bd8e3e115.tar.bz2 |
[Chromoting] Use base::GenerateGUID to generate host IDs.
BUG=153453
Review URL: https://chromiumcodereview.appspot.com/11192041
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@162867 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'remoting')
-rw-r--r-- | remoting/host/setup/host_starter.cc | 44 |
1 files changed, 2 insertions, 42 deletions
diff --git a/remoting/host/setup/host_starter.cc b/remoting/host/setup/host_starter.cc index f7aa5be..063ce83 100644 --- a/remoting/host/setup/host_starter.cc +++ b/remoting/host/setup/host_starter.cc @@ -4,55 +4,15 @@ #include "remoting/host/setup/host_starter.h" +#include "base/guid.h" #include "base/thread_task_runner_handle.h" #include "base/values.h" -#include "crypto/random.h" #include "google_apis/google_api_keys.h" #include "remoting/host/pin_hash.h" #include "remoting/host/setup/oauth_helper.h" namespace { - -void AppendByte(std::string& s, uint8 byte) { - const char alphabet[] = "0123456789abcdef"; - s.push_back(alphabet[byte / 16]); - s.push_back(alphabet[byte & 15]); -} - -std::string MakeHostId() { - static const int random_byte_num = 16; - static const unsigned int id_len = 36; - scoped_array<uint8> random_bytes(new uint8[random_byte_num]); - crypto::RandBytes(&random_bytes[0], random_byte_num); - std::string id; - id.reserve(id_len); - int byte_count = 0; - for (int i = 0; i < 4; i++) { - AppendByte(id, random_bytes[byte_count++]); - } - id.push_back('-'); - for (int i = 0; i < 2; i++) { - AppendByte(id, random_bytes[byte_count++]); - } - id.push_back('-'); - for (int i = 0; i < 2; i++) { - AppendByte(id, random_bytes[byte_count++]); - } - id.push_back('-'); - for (int i = 0; i < 2; i++) { - AppendByte(id, random_bytes[byte_count++]); - } - id.push_back('-'); - for (int i = 0; i < 6; i++) { - AppendByte(id, random_bytes[byte_count++]); - } - DCHECK_EQ(random_byte_num, byte_count); - DCHECK_EQ(id_len, id.length()); - return id; -} - const int kMaxGetTokensRetries = 3; - } // namespace namespace remoting { @@ -143,7 +103,7 @@ void HostStarter::OnGetUserEmailResponse(const std::string& user_email) { } user_email_ = user_email; // Register the host. - host_id_ = MakeHostId(); + host_id_ = base::GenerateGUID(); key_pair_.Generate(); service_client_->RegisterHost( host_id_, host_name_, key_pair_.GetPublicKey(), access_token_, this); |