invalidation_service_util.cc 704 B

1234567891011121314151617181920212223
  1. // Copyright 2014 The Chromium Authors. All rights reserved.
  2. // Use of this source code is governed by a BSD-style license that can be
  3. // found in the LICENSE file.
  4. #include "components/invalidation/impl/invalidation_service_util.h"
  5. #include "base/base64.h"
  6. #include "base/check.h"
  7. #include "base/rand_util.h"
  8. namespace invalidation {
  9. std::string GenerateInvalidatorClientId() {
  10. // Generate a GUID with 128 bits worth of base64-encoded randomness.
  11. // This format is similar to that of sync's cache_guid.
  12. const int kGuidBytes = 128 / 8;
  13. std::string guid;
  14. base::Base64Encode(base::RandBytesAsString(kGuidBytes), &guid);
  15. DCHECK(!guid.empty());
  16. return guid;
  17. }
  18. } // namespace invalidation