Chromium Code Reviews| Index: extensions/common/user_script.cc |
| diff --git a/extensions/common/user_script.cc b/extensions/common/user_script.cc |
| index 2e705ce86fc6e8dff6a9cfc4db541b9037fa72a0..be8c9af6f9ad333f4a4df094b0416eb6e2acc596 100644 |
| --- a/extensions/common/user_script.cc |
| +++ b/extensions/common/user_script.cc |
| @@ -4,6 +4,7 @@ |
| #include "extensions/common/user_script.h" |
| +#include "base/atomic_sequence_num.h" |
| #include "base/command_line.h" |
| #include "base/pickle.h" |
| #include "base/strings/string_util.h" |
| @@ -11,6 +12,8 @@ |
| namespace { |
| +base::StaticAtomicSequenceNumber g_user_script_id_generator; |
|
Devlin
2014/08/22 18:24:21
nit: maybe a comment on why this can't just be an
Mark Dittmer
2014/08/22 18:28:56
Done.
|
| + |
| bool UrlMatchesGlobs(const std::vector<std::string>* globs, |
| const GURL& url) { |
| for (std::vector<std::string>::const_iterator glob = globs->begin(); |
| @@ -38,6 +41,12 @@ enum { |
| // static |
| const char UserScript::kFileExtension[] = ".user.js"; |
| + |
| +// static |
| +int UserScript::GenerateUserScriptID() { |
| + return g_user_script_id_generator.GetNext(); |
| +} |
| + |
| bool UserScript::IsURLUserScript(const GURL& url, |
| const std::string& mime_type) { |
| return EndsWith(url.ExtractFileName(), kFileExtension, false) && |
| @@ -128,7 +137,7 @@ void UserScript::Pickle(::Pickle* pickle) const { |
| // Write the simple types to the pickle. |
| pickle->WriteInt(run_location()); |
| pickle->WriteString(extension_id()); |
| - pickle->WriteInt64(user_script_id_); |
| + pickle->WriteInt(user_script_id_); |
| pickle->WriteBool(emulate_greasemonkey()); |
| pickle->WriteBool(match_all_frames()); |
| pickle->WriteBool(match_about_blank()); |
| @@ -178,7 +187,7 @@ void UserScript::Unpickle(const ::Pickle& pickle, PickleIterator* iter) { |
| run_location_ = static_cast<RunLocation>(run_location); |
| CHECK(pickle.ReadString(iter, &extension_id_)); |
| - CHECK(pickle.ReadInt64(iter, &user_script_id_)); |
| + CHECK(pickle.ReadInt(iter, &user_script_id_)); |
| CHECK(pickle.ReadBool(iter, &emulate_greasemonkey_)); |
| CHECK(pickle.ReadBool(iter, &match_all_frames_)); |
| CHECK(pickle.ReadBool(iter, &match_about_blank_)); |