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

Unified Diff: content/browser/notifications/notification_id_generator.cc

Issue 1904163002: Move Web Notifications to use Mojo Base URL: https://chromium.googlesource.com/chromium/src.git@skbitmap-blink
Patch Set: it works \o/ Created 4 years, 8 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: content/browser/notifications/notification_id_generator.cc
diff --git a/content/browser/notifications/notification_id_generator.cc b/content/browser/notifications/notification_id_generator.cc
index 04f34f757939acfb5979db64ff9ba2ac3c6bf50a..d8ce10b418bebd1264737f254bfe409866115b9f 100644
--- a/content/browser/notifications/notification_id_generator.cc
+++ b/content/browser/notifications/notification_id_generator.cc
@@ -9,11 +9,14 @@
#include "base/files/file_path.h"
#include "base/logging.h"
#include "base/sha1.h"
+#include "base/strings/string_number_conversions.h"
#include "base/strings/utf_string_conversions.h"
#include "build/build_config.h"
#include "content/public/browser/browser_context.h"
#include "url/gurl.h"
+#include "base/base64url.h"
+
namespace content {
namespace {
@@ -29,10 +32,12 @@ std::string ComputeBrowserContextHash(BrowserContext* browser_context) {
const base::FilePath path = browser_context->GetPath();
#if defined(OS_WIN)
- return base::SHA1HashString(base::WideToUTF8(path.value()));
+ std::string path_hash = base::SHA1HashString(base::WideToUTF8(path.value()));
#else
- return base::SHA1HashString(path.value());
+ std::string path_hash = base::SHA1HashString(path.value());
#endif
+
+ return base::HexEncode(path_hash.c_str(), path_hash.length());
}
} // namespace
@@ -68,17 +73,17 @@ std::string NotificationIdGenerator::GenerateForPersistentNotification(
stream << kPersistentPrefix;
stream << ComputeBrowserContextHash(browser_context_);
- stream << browser_context_->IsOffTheRecord();
+ stream << base::IntToString(browser_context_->IsOffTheRecord() ? 1 : 0);
stream << origin;
// Persistent notification ids are unique for the lifetime of the notification
// database, orthogonal to the renderer that created the notification.
- stream << !!tag.size();
+ stream << base::IntToString(tag.size() ? 1 : 0);
if (tag.size())
stream << tag;
else
- stream << persistent_notification_id;
+ stream << base::Int64ToString(persistent_notification_id);
return stream.str();
}
@@ -94,18 +99,18 @@ std::string NotificationIdGenerator::GenerateForNonPersistentNotification(
stream << kNonPersistentPrefix;
stream << ComputeBrowserContextHash(browser_context_);
- stream << browser_context_->IsOffTheRecord();
+ stream << base::IntToString(browser_context_->IsOffTheRecord() ? 1 : 0);
stream << origin;
// Non-persistent notification ids are unique per renderer process when no
// tag is being used. Tags still identify uniqueness for the given origin.
- stream << !!tag.size();
+ stream << base::IntToString(tag.size() ? 1 : 0);
if (!tag.size()) {
- stream << render_process_id_;
+ stream << base::IntToString(render_process_id_);
stream << kSeparator;
- stream << non_persistent_notification_id;
+ stream << base::IntToString(non_persistent_notification_id);
} else {
stream << tag;
}

Powered by Google App Engine
This is Rietveld 408576698