diff options
author | avi <avi@chromium.org> | 2015-12-24 18:40:26 -0800 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2015-12-25 02:41:55 +0000 |
commit | 7bf9dd9c930bef49e8c6e8ce63c164d3f0ebdd57 (patch) | |
tree | d90eb0fa3e283b86f704d6f1b2504a8c66f956f7 | |
parent | 1023d01cf18184883fad21181873d41b740e4d03 (diff) | |
download | chromium_src-7bf9dd9c930bef49e8c6e8ce63c164d3f0ebdd57.zip chromium_src-7bf9dd9c930bef49e8c6e8ce63c164d3f0ebdd57.tar.gz chromium_src-7bf9dd9c930bef49e8c6e8ce63c164d3f0ebdd57.tar.bz2 |
Switch to standard integer types in content/browser/service_worker/.
BUG=138542
TBR=michaeln@chromium.org
Review URL: https://codereview.chromium.org/1548083002
Cr-Commit-Position: refs/heads/master@{#366848}
76 files changed, 793 insertions, 692 deletions
diff --git a/content/browser/service_worker/embedded_worker_instance.cc b/content/browser/service_worker/embedded_worker_instance.cc index 0089bf5..17c3022 100644 --- a/content/browser/service_worker/embedded_worker_instance.cc +++ b/content/browser/service_worker/embedded_worker_instance.cc @@ -5,6 +5,7 @@ #include "content/browser/service_worker/embedded_worker_instance.h" #include "base/bind_helpers.h" +#include "base/macros.h" #include "base/metrics/histogram_macros.h" #include "base/threading/non_thread_safe.h" #include "base/trace_event/trace_event.h" @@ -48,7 +49,7 @@ void RegisterToWorkerDevToolsManagerOnUI( int process_id, const ServiceWorkerContextCore* service_worker_context, const base::WeakPtr<ServiceWorkerContextCore>& service_worker_context_weak, - int64 service_worker_version_id, + int64_t service_worker_version_id, const GURL& url, const base::Callback<void(int worker_devtools_agent_route_id, bool wait_for_debugger)>& callback) { @@ -139,7 +140,7 @@ EmbeddedWorkerInstance::~EmbeddedWorkerInstance() { registry_->RemoveWorker(process_id_, embedded_worker_id_); } -void EmbeddedWorkerInstance::Start(int64 service_worker_version_id, +void EmbeddedWorkerInstance::Start(int64_t service_worker_version_id, const GURL& scope, const GURL& script_url, const StatusCallback& callback) { @@ -281,7 +282,7 @@ void EmbeddedWorkerInstance::ProcessAllocated( OnStartFailed(callback, status); return; } - const int64 service_worker_version_id = params->service_worker_version_id; + const int64_t service_worker_version_id = params->service_worker_version_id; process_id_ = process_id; GURL script_url(params->script_url); diff --git a/content/browser/service_worker/embedded_worker_instance.h b/content/browser/service_worker/embedded_worker_instance.h index 60b3363..ad1272f 100644 --- a/content/browser/service_worker/embedded_worker_instance.h +++ b/content/browser/service_worker/embedded_worker_instance.h @@ -5,13 +5,15 @@ #ifndef CONTENT_BROWSER_SERVICE_WORKER_EMBEDDED_WORKER_INSTANCE_H_ #define CONTENT_BROWSER_SERVICE_WORKER_EMBEDDED_WORKER_INSTANCE_H_ +#include <stdint.h> + #include <string> -#include "base/basictypes.h" #include "base/callback.h" #include "base/callback_forward.h" #include "base/gtest_prod_util.h" #include "base/logging.h" +#include "base/macros.h" #include "base/memory/ref_counted.h" #include "base/memory/weak_ptr.h" #include "base/observer_list.h" @@ -102,7 +104,7 @@ class CONTENT_EXPORT EmbeddedWorkerInstance { // Starts the worker. It is invalid to call this when the worker is not in // STOPPED status. |callback| is invoked after the worker script has been // started and evaluated, or when an error occurs. - void Start(int64 service_worker_version_id, + void Start(int64_t service_worker_version_id, const GURL& scope, const GURL& script_url, const StatusCallback& callback); diff --git a/content/browser/service_worker/embedded_worker_instance_unittest.cc b/content/browser/service_worker/embedded_worker_instance_unittest.cc index c2a109c..4057e3a 100644 --- a/content/browser/service_worker/embedded_worker_instance_unittest.cc +++ b/content/browser/service_worker/embedded_worker_instance_unittest.cc @@ -2,7 +2,9 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "base/basictypes.h" +#include <stdint.h> + +#include "base/macros.h" #include "base/run_loop.h" #include "base/stl_util.h" #include "content/browser/service_worker/embedded_worker_instance.h" @@ -108,7 +110,7 @@ TEST_F(EmbeddedWorkerInstanceTest, StartAndStop) { embedded_worker_registry()->CreateWorker(); EXPECT_EQ(EmbeddedWorkerInstance::STOPPED, worker->status()); - const int64 service_worker_version_id = 55L; + const int64_t service_worker_version_id = 55L; const GURL pattern("http://example.com/"); const GURL url("http://example.com/worker.js"); @@ -154,7 +156,7 @@ TEST_F(EmbeddedWorkerInstanceTest, StopWhenDevToolsAttached) { embedded_worker_registry()->CreateWorker(); EXPECT_EQ(EmbeddedWorkerInstance::STOPPED, worker->status()); - const int64 service_worker_version_id = 55L; + const int64_t service_worker_version_id = 55L; const GURL pattern("http://example.com/"); const GURL url("http://example.com/worker.js"); @@ -202,8 +204,8 @@ TEST_F(EmbeddedWorkerInstanceTest, RemoveWorkerInSharedProcess) { scoped_ptr<EmbeddedWorkerInstance> worker2 = embedded_worker_registry()->CreateWorker(); - const int64 version_id1 = 55L; - const int64 version_id2 = 56L; + const int64_t version_id1 = 55L; + const int64_t version_id2 = 56L; const GURL pattern("http://example.com/"); const GURL url("http://example.com/worker.js"); int process_id = helper_->mock_render_process_id(); @@ -300,7 +302,7 @@ TEST_F(EmbeddedWorkerInstanceTest, StopDuringStart) { } TEST_F(EmbeddedWorkerInstanceTest, Detach) { - const int64 version_id = 55L; + const int64_t version_id = 55L; const GURL pattern("http://example.com/"); const GURL url("http://example.com/worker.js"); scoped_ptr<EmbeddedWorkerInstance> worker = @@ -333,7 +335,7 @@ TEST_F(EmbeddedWorkerInstanceTest, Detach) { TEST_F(EmbeddedWorkerInstanceTest, FailToSendStartIPC) { helper_.reset(new FailToSendIPCHelper()); - const int64 version_id = 55L; + const int64_t version_id = 55L; const GURL pattern("http://example.com/"); const GURL url("http://example.com/worker.js"); diff --git a/content/browser/service_worker/embedded_worker_registry.h b/content/browser/service_worker/embedded_worker_registry.h index 22313dd..308e1de 100644 --- a/content/browser/service_worker/embedded_worker_registry.h +++ b/content/browser/service_worker/embedded_worker_registry.h @@ -9,8 +9,8 @@ #include <set> #include <vector> -#include "base/basictypes.h" #include "base/gtest_prod_util.h" +#include "base/macros.h" #include "base/memory/ref_counted.h" #include "base/memory/scoped_ptr.h" #include "base/memory/weak_ptr.h" diff --git a/content/browser/service_worker/embedded_worker_test_helper.cc b/content/browser/service_worker/embedded_worker_test_helper.cc index bd331bf..f3f557d 100644 --- a/content/browser/service_worker/embedded_worker_test_helper.cc +++ b/content/browser/service_worker/embedded_worker_test_helper.cc @@ -111,7 +111,7 @@ void EmbeddedWorkerTestHelper::ShutdownContext() { } void EmbeddedWorkerTestHelper::OnStartWorker(int embedded_worker_id, - int64 service_worker_version_id, + int64_t service_worker_version_id, const GURL& scope, const GURL& script_url) { embedded_worker_id_service_worker_version_id_map_[embedded_worker_id] = @@ -197,7 +197,7 @@ void EmbeddedWorkerTestHelper::SimulateWorkerReadyForInspection( void EmbeddedWorkerTestHelper::SimulateWorkerScriptCached( int embedded_worker_id) { - int64 version_id = + int64_t version_id = embedded_worker_id_service_worker_version_id_map_[embedded_worker_id]; ServiceWorkerVersion* version = context()->GetLiveVersion(version_id); if (!version || version->script_cache_map()->size()) diff --git a/content/browser/service_worker/embedded_worker_test_helper.h b/content/browser/service_worker/embedded_worker_test_helper.h index 8efd35b..9a30831 100644 --- a/content/browser/service_worker/embedded_worker_test_helper.h +++ b/content/browser/service_worker/embedded_worker_test_helper.h @@ -5,11 +5,14 @@ #ifndef CONTENT_BROWSER_SERVICE_WORKER_EMBEDDED_WORKER_TEST_HELPER_H_ #define CONTENT_BROWSER_SERVICE_WORKER_EMBEDDED_WORKER_TEST_HELPER_H_ +#include <stdint.h> + #include <map> #include <string> #include <vector> #include "base/callback.h" +#include "base/macros.h" #include "base/memory/weak_ptr.h" #include "ipc/ipc_listener.h" #include "ipc/ipc_test_sink.h" @@ -88,7 +91,7 @@ class EmbeddedWorkerTestHelper : public IPC::Sender, // - OnStopWorker calls SimulateWorkerStoped // - OnSendMessageToWorker calls the message's respective On*Event handler virtual void OnStartWorker(int embedded_worker_id, - int64 service_worker_version_id, + int64_t service_worker_version_id, const GURL& scope, const GURL& script_url); virtual void OnStopWorker(int embedded_worker_id); @@ -147,7 +150,7 @@ class EmbeddedWorkerTestHelper : public IPC::Sender, int next_thread_id_; int mock_render_process_id_; - std::map<int, int64> embedded_worker_id_service_worker_version_id_map_; + std::map<int, int64_t> embedded_worker_id_service_worker_version_id_map_; // Updated each time MessageToWorker message is received. int current_embedded_worker_id_; diff --git a/content/browser/service_worker/foreign_fetch_request_handler.cc b/content/browser/service_worker/foreign_fetch_request_handler.cc index b3b1213..5edda64 100644 --- a/content/browser/service_worker/foreign_fetch_request_handler.cc +++ b/content/browser/service_worker/foreign_fetch_request_handler.cc @@ -4,6 +4,7 @@ #include "content/browser/service_worker/foreign_fetch_request_handler.h" +#include "base/macros.h" #include "content/browser/service_worker/service_worker_context_wrapper.h" #include "content/browser/service_worker/service_worker_url_request_job.h" #include "content/common/resource_request_body.h" diff --git a/content/browser/service_worker/foreign_fetch_request_handler.h b/content/browser/service_worker/foreign_fetch_request_handler.h index c2300a0..196f7e0 100644 --- a/content/browser/service_worker/foreign_fetch_request_handler.h +++ b/content/browser/service_worker/foreign_fetch_request_handler.h @@ -5,7 +5,7 @@ #ifndef CONTENT_BROWSER_SERVICE_WORKER_FOREIGN_FETCH_REQUEST_HANDLER_H_ #define CONTENT_BROWSER_SERVICE_WORKER_FOREIGN_FETCH_REQUEST_HANDLER_H_ -#include "base/basictypes.h" +#include "base/macros.h" #include "base/memory/weak_ptr.h" #include "base/supports_user_data.h" #include "base/time/time.h" diff --git a/content/browser/service_worker/service_worker_browsertest.cc b/content/browser/service_worker/service_worker_browsertest.cc index 2e5ad39..10b727c 100644 --- a/content/browser/service_worker/service_worker_browsertest.cc +++ b/content/browser/service_worker/service_worker_browsertest.cc @@ -2,13 +2,18 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. +#include <stddef.h> +#include <stdint.h> + #include "base/bind.h" #include "base/callback.h" #include "base/command_line.h" +#include "base/macros.h" #include "base/run_loop.h" #include "base/single_thread_task_runner.h" #include "base/strings/utf_string_conversions.h" #include "base/thread_task_runner_handle.h" +#include "build/build_config.h" #include "content/browser/fileapi/chrome_blob_storage_context.h" #include "content/browser/service_worker/embedded_worker_instance.h" #include "content/browser/service_worker/embedded_worker_registry.h" @@ -181,7 +186,7 @@ class WorkerActivatedObserver RunOnIOThread(base::Bind(&WorkerActivatedObserver::InitOnIOThread, this)); } // ServiceWorkerContextObserver overrides. - void OnVersionStateChanged(int64 version_id, + void OnVersionStateChanged(int64_t version_id, ServiceWorkerVersion::Status) override { ASSERT_TRUE(BrowserThread::CurrentlyOn(BrowserThread::IO)); const ServiceWorkerVersion* version = context_->GetLiveVersion(version_id); @@ -541,7 +546,7 @@ class ServiceWorkerVersionBrowserTest : public ServiceWorkerBrowserTest { ASSERT_EQ(expected_status, status); } - void StoreRegistration(int64 version_id, + void StoreRegistration(int64_t version_id, ServiceWorkerStatusCode expected_status) { ASSERT_TRUE(BrowserThread::CurrentlyOn(BrowserThread::UI)); ServiceWorkerStatusCode status = SERVICE_WORKER_ERROR_FAILED; @@ -557,7 +562,7 @@ class ServiceWorkerVersionBrowserTest : public ServiceWorkerBrowserTest { this, status)); } - void FindRegistrationForId(int64 id, + void FindRegistrationForId(int64_t id, const GURL& origin, ServiceWorkerStatusCode expected_status) { ASSERT_TRUE(BrowserThread::CurrentlyOn(BrowserThread::UI)); @@ -573,7 +578,7 @@ class ServiceWorkerVersionBrowserTest : public ServiceWorkerBrowserTest { void FindRegistrationForIdOnIOThread(const base::Closure& done, ServiceWorkerStatusCode* result, - int64 id, + int64_t id, const GURL& origin) { ASSERT_TRUE(BrowserThread::CurrentlyOn(BrowserThread::IO)); wrapper()->context()->storage()->FindRegistrationForId( @@ -588,7 +593,7 @@ class ServiceWorkerVersionBrowserTest : public ServiceWorkerBrowserTest { registration_.get(), version_.get(), status); } - void RemoveLiveRegistrationOnIOThread(int64 id) { + void RemoveLiveRegistrationOnIOThread(int64_t id) { ASSERT_TRUE(BrowserThread::CurrentlyOn(BrowserThread::IO)); wrapper()->context()->RemoveLiveRegistration(id); } @@ -609,7 +614,7 @@ class ServiceWorkerVersionBrowserTest : public ServiceWorkerBrowserTest { void StoreOnIOThread(const base::Closure& done, ServiceWorkerStatusCode* result, - int64 version_id) { + int64_t version_id) { ASSERT_TRUE(BrowserThread::CurrentlyOn(BrowserThread::IO)); ServiceWorkerVersion* version = wrapper()->context()->GetLiveVersion(version_id); diff --git a/content/browser/service_worker/service_worker_cache_writer.h b/content/browser/service_worker/service_worker_cache_writer.h index dde71a6..e4c38cc 100644 --- a/content/browser/service_worker/service_worker_cache_writer.h +++ b/content/browser/service_worker/service_worker_cache_writer.h @@ -5,6 +5,8 @@ #ifndef CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_CACHE_WRITER_H_ #define CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_CACHE_WRITER_H_ +#include <stddef.h> + #include <map> #include <set> diff --git a/content/browser/service_worker/service_worker_cache_writer_unittest.cc b/content/browser/service_worker/service_worker_cache_writer_unittest.cc index 887cedc..96f6599 100644 --- a/content/browser/service_worker/service_worker_cache_writer_unittest.cc +++ b/content/browser/service_worker/service_worker_cache_writer_unittest.cc @@ -4,10 +4,13 @@ #include "content/browser/service_worker/service_worker_cache_writer.h" +#include <stddef.h> + #include <list> #include <queue> #include <string> +#include "base/macros.h" #include "base/stl_util.h" #include "content/browser/service_worker/service_worker_disk_cache.h" #include "testing/gtest/include/gtest/gtest.h" diff --git a/content/browser/service_worker/service_worker_client_navigation_utils.cc b/content/browser/service_worker/service_worker_client_navigation_utils.cc index afba372..5147bd1 100644 --- a/content/browser/service_worker/service_worker_client_navigation_utils.cc +++ b/content/browser/service_worker/service_worker_client_navigation_utils.cc @@ -4,6 +4,7 @@ #include "content/browser/service_worker/service_worker_client_navigation_utils.h" +#include "base/macros.h" #include "content/browser/frame_host/frame_tree_node.h" #include "content/browser/frame_host/render_frame_host_impl.h" #include "content/browser/service_worker/service_worker_context_core.h" diff --git a/content/browser/service_worker/service_worker_context_core.cc b/content/browser/service_worker/service_worker_context_core.cc index cddecdc..487fdbd 100644 --- a/content/browser/service_worker/service_worker_context_core.cc +++ b/content/browser/service_worker/service_worker_context_core.cc @@ -9,6 +9,7 @@ #include "base/bind_helpers.h" #include "base/files/file_path.h" #include "base/location.h" +#include "base/macros.h" #include "base/single_thread_task_runner.h" #include "base/strings/string_util.h" #include "base/thread_task_runner_handle.h" @@ -104,7 +105,7 @@ class ClearAllServiceWorkersHelper return; // Make a copy of live versions map because StopWorker() removes the version // from it when we were starting up and don't have a process yet. - const std::map<int64, ServiceWorkerVersion*> live_versions_copy = + const std::map<int64_t, ServiceWorkerVersion*> live_versions_copy = context->GetLiveVersions(); for (const auto& version_itr : live_versions_copy) { ServiceWorkerVersion* version(version_itr.second); @@ -523,7 +524,7 @@ void ServiceWorkerContextCore::UpdateComplete( void ServiceWorkerContextCore::UnregistrationComplete( const GURL& pattern, const ServiceWorkerContextCore::UnregistrationCallback& callback, - int64 registration_id, + int64_t registration_id, ServiceWorkerStatusCode status) { callback.Run(status); if (status == SERVICE_WORKER_OK && observer_list_.get()) { @@ -534,7 +535,7 @@ void ServiceWorkerContextCore::UnregistrationComplete( } ServiceWorkerRegistration* ServiceWorkerContextCore::GetLiveRegistration( - int64 id) { + int64_t id) { RegistrationsMap::iterator it = live_registrations_.find(id); return (it != live_registrations_.end()) ? it->second : NULL; } @@ -550,12 +551,11 @@ void ServiceWorkerContextCore::AddLiveRegistration( } } -void ServiceWorkerContextCore::RemoveLiveRegistration(int64 id) { +void ServiceWorkerContextCore::RemoveLiveRegistration(int64_t id) { live_registrations_.erase(id); } -ServiceWorkerVersion* ServiceWorkerContextCore::GetLiveVersion( - int64 id) { +ServiceWorkerVersion* ServiceWorkerContextCore::GetLiveVersion(int64_t id) { VersionMap::iterator it = live_versions_.find(id); return (it != live_versions_.end()) ? it->second : NULL; } @@ -601,17 +601,16 @@ void ServiceWorkerContextCore::AddLiveVersion(ServiceWorkerVersion* version) { } } -void ServiceWorkerContextCore::RemoveLiveVersion(int64 id) { +void ServiceWorkerContextCore::RemoveLiveVersion(int64_t id) { live_versions_.erase(id); } std::vector<ServiceWorkerRegistrationInfo> ServiceWorkerContextCore::GetAllLiveRegistrationInfo() { std::vector<ServiceWorkerRegistrationInfo> infos; - for (std::map<int64, ServiceWorkerRegistration*>::const_iterator iter = + for (std::map<int64_t, ServiceWorkerRegistration*>::const_iterator iter = live_registrations_.begin(); - iter != live_registrations_.end(); - ++iter) { + iter != live_registrations_.end(); ++iter) { infos.push_back(iter->second->GetInfo()); } return infos; @@ -620,10 +619,9 @@ ServiceWorkerContextCore::GetAllLiveRegistrationInfo() { std::vector<ServiceWorkerVersionInfo> ServiceWorkerContextCore::GetAllLiveVersionInfo() { std::vector<ServiceWorkerVersionInfo> infos; - for (std::map<int64, ServiceWorkerVersion*>::const_iterator iter = + for (std::map<int64_t, ServiceWorkerVersion*>::const_iterator iter = live_versions_.begin(); - iter != live_versions_.end(); - ++iter) { + iter != live_versions_.end(); ++iter) { infos.push_back(iter->second->GetInfo()); } return infos; @@ -636,7 +634,7 @@ void ServiceWorkerContextCore::ProtectVersion( protected_versions_[version->version_id()] = version; } -void ServiceWorkerContextCore::UnprotectVersion(int64 version_id) { +void ServiceWorkerContextCore::UnprotectVersion(int64_t version_id) { DCHECK(protected_versions_.find(version_id) != protected_versions_.end()); protected_versions_.erase(version_id); } diff --git a/content/browser/service_worker/service_worker_context_core.h b/content/browser/service_worker/service_worker_context_core.h index 0db2447..f944886 100644 --- a/content/browser/service_worker/service_worker_context_core.h +++ b/content/browser/service_worker/service_worker_context_core.h @@ -5,12 +5,15 @@ #ifndef CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_CONTEXT_CORE_H_ #define CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_CONTEXT_CORE_H_ +#include <stdint.h> + #include <map> #include <vector> #include "base/callback.h" #include "base/files/file_path.h" #include "base/id_map.h" +#include "base/macros.h" #include "base/memory/scoped_ptr.h" #include "base/memory/weak_ptr.h" #include "base/observer_list_threadsafe.h" @@ -60,10 +63,10 @@ class CONTENT_EXPORT ServiceWorkerContextCore typedef base::Callback<void(ServiceWorkerStatusCode status)> StatusCallback; typedef base::Callback<void(ServiceWorkerStatusCode status, const std::string& status_message, - int64 registration_id)> RegistrationCallback; + int64_t registration_id)> RegistrationCallback; typedef base::Callback<void(ServiceWorkerStatusCode status, const std::string& status_message, - int64 registration_id)> UpdateCallback; + int64_t registration_id)> UpdateCallback; typedef base::Callback< void(ServiceWorkerStatusCode status)> UnregistrationCallback; typedef IDMap<ServiceWorkerProviderHost, IDMapOwnPointer> ProviderMap; @@ -213,17 +216,17 @@ class CONTENT_EXPORT ServiceWorkerContextCore // This class maintains collections of live instances, this class // does not own these object or influence their lifetime. - ServiceWorkerRegistration* GetLiveRegistration(int64 registration_id); + ServiceWorkerRegistration* GetLiveRegistration(int64_t registration_id); void AddLiveRegistration(ServiceWorkerRegistration* registration); - void RemoveLiveRegistration(int64 registration_id); - const std::map<int64, ServiceWorkerRegistration*>& GetLiveRegistrations() + void RemoveLiveRegistration(int64_t registration_id); + const std::map<int64_t, ServiceWorkerRegistration*>& GetLiveRegistrations() const { return live_registrations_; } - ServiceWorkerVersion* GetLiveVersion(int64 version_id); + ServiceWorkerVersion* GetLiveVersion(int64_t version_id); void AddLiveVersion(ServiceWorkerVersion* version); - void RemoveLiveVersion(int64 registration_id); - const std::map<int64, ServiceWorkerVersion*>& GetLiveVersions() const { + void RemoveLiveVersion(int64_t registration_id); + const std::map<int64_t, ServiceWorkerVersion*>& GetLiveVersions() const { return live_versions_; } @@ -242,7 +245,7 @@ class CONTENT_EXPORT ServiceWorkerContextCore // ProtectVersion holds a reference to |version| until UnprotectVersion is // called. void ProtectVersion(const scoped_refptr<ServiceWorkerVersion>& version); - void UnprotectVersion(int64 version_id); + void UnprotectVersion(int64_t version_id); // Returns new context-local unique ID. int GetNewServiceWorkerHandleId(); @@ -278,8 +281,8 @@ class CONTENT_EXPORT ServiceWorkerContextCore } private: - typedef std::map<int64, ServiceWorkerRegistration*> RegistrationsMap; - typedef std::map<int64, ServiceWorkerVersion*> VersionMap; + typedef std::map<int64_t, ServiceWorkerRegistration*> RegistrationsMap; + typedef std::map<int64_t, ServiceWorkerVersion*> VersionMap; ProviderMap* GetProviderMapForProcess(int process_id) { return providers_->Lookup(process_id); @@ -298,7 +301,7 @@ class CONTENT_EXPORT ServiceWorkerContextCore void UnregistrationComplete(const GURL& pattern, const UnregistrationCallback& callback, - int64 registration_id, + int64_t registration_id, ServiceWorkerStatusCode status); void DidGetAllRegistrationsForUnregisterForOrigin( @@ -324,9 +327,9 @@ class CONTENT_EXPORT ServiceWorkerContextCore scoped_ptr<ServiceWorkerStorage> storage_; scoped_refptr<EmbeddedWorkerRegistry> embedded_worker_registry_; scoped_ptr<ServiceWorkerJobCoordinator> job_coordinator_; - std::map<int64, ServiceWorkerRegistration*> live_registrations_; - std::map<int64, ServiceWorkerVersion*> live_versions_; - std::map<int64, scoped_refptr<ServiceWorkerVersion>> protected_versions_; + std::map<int64_t, ServiceWorkerRegistration*> live_registrations_; + std::map<int64_t, ServiceWorkerVersion*> live_versions_; + std::map<int64_t, scoped_refptr<ServiceWorkerVersion>> protected_versions_; // PlzNavigate // Map of ServiceWorkerNavigationHandleCores used for navigation requests. diff --git a/content/browser/service_worker/service_worker_context_observer.h b/content/browser/service_worker/service_worker_context_observer.h index 1dcd73e..86c2385 100644 --- a/content/browser/service_worker/service_worker_context_observer.h +++ b/content/browser/service_worker/service_worker_context_observer.h @@ -5,6 +5,8 @@ #ifndef CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_CONTEXT_OBSERVER_H_ #define CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_CONTEXT_OBSERVER_H_ +#include <stdint.h> + #include "base/strings/string16.h" #include "base/time/time.h" #include "content/browser/service_worker/service_worker_version.h" @@ -45,39 +47,40 @@ class ServiceWorkerContextObserver { const int line_number; const GURL source_url; }; - virtual void OnNewLiveRegistration(int64 registration_id, + virtual void OnNewLiveRegistration(int64_t registration_id, const GURL& pattern) {} - virtual void OnNewLiveVersion(int64 version_id, - int64 registration_id, + virtual void OnNewLiveVersion(int64_t version_id, + int64_t registration_id, const GURL& script_url) {} virtual void OnRunningStateChanged( - int64 version_id, + int64_t version_id, ServiceWorkerVersion::RunningStatus running_status) {} - virtual void OnVersionStateChanged(int64 version_id, + virtual void OnVersionStateChanged(int64_t version_id, ServiceWorkerVersion::Status status) {} virtual void OnMainScriptHttpResponseInfoSet( - int64 version_id, + int64_t version_id, base::Time script_response_time, base::Time script_last_modified) {} - virtual void OnErrorReported(int64 version_id, + virtual void OnErrorReported(int64_t version_id, int process_id, int thread_id, const ErrorInfo& info) {} - virtual void OnReportConsoleMessage(int64 version_id, + virtual void OnReportConsoleMessage(int64_t version_id, int process_id, int thread_id, const ConsoleMessage& message) {} - virtual void OnControlleeAdded(int64 version_id, + virtual void OnControlleeAdded(int64_t version_id, const std::string& uuid, int process_id, int route_id, ServiceWorkerProviderType type) {} - virtual void OnControlleeRemoved(int64 version_id, const std::string& uuid) {} - virtual void OnRegistrationStored(int64 registration_id, + virtual void OnControlleeRemoved(int64_t version_id, + const std::string& uuid) {} + virtual void OnRegistrationStored(int64_t registration_id, const GURL& pattern) {} - virtual void OnRegistrationDeleted(int64 registration_id, + virtual void OnRegistrationDeleted(int64_t registration_id, const GURL& pattern) {} - virtual void OnForceUpdateOnPageLoadChanged(int64 registration_id, + virtual void OnForceUpdateOnPageLoadChanged(int64_t registration_id, bool force_update_on_page_load) {} // Notified when the storage corruption recovery is completed and all stored diff --git a/content/browser/service_worker/service_worker_context_request_handler.cc b/content/browser/service_worker/service_worker_context_request_handler.cc index beb79f4..8b76146 100644 --- a/content/browser/service_worker/service_worker_context_request_handler.cc +++ b/content/browser/service_worker/service_worker_context_request_handler.cc @@ -60,7 +60,7 @@ net::URLRequestJob* ServiceWorkerContextRequestHandler::MaybeCreateJob( context_->GetLiveRegistration(version_->registration_id()); DCHECK(registration); // We're registering or updating so must be there. - int64 resource_id = context_->storage()->NewResourceId(); + int64_t resource_id = context_->storage()->NewResourceId(); if (resource_id == kInvalidServiceWorkerResourceId) return NULL; @@ -78,7 +78,7 @@ net::URLRequestJob* ServiceWorkerContextRequestHandler::MaybeCreateJob( ServiceWorkerVersion* stored_version = registration->waiting_version() ? registration->waiting_version() : registration->active_version(); - int64 incumbent_resource_id = kInvalidServiceWorkerResourceId; + int64_t incumbent_resource_id = kInvalidServiceWorkerResourceId; if (stored_version && stored_version->script_url() == request->url()) { incumbent_resource_id = stored_version->script_cache_map()->LookupResourceId(request->url()); @@ -88,7 +88,7 @@ net::URLRequestJob* ServiceWorkerContextRequestHandler::MaybeCreateJob( extra_load_flags, resource_id, incumbent_resource_id); } - int64 resource_id = kInvalidServiceWorkerResourceId; + int64_t resource_id = kInvalidServiceWorkerResourceId; if (ShouldReadFromScriptCache(request->url(), &resource_id)) { return new ServiceWorkerReadFromCacheJob(request, network_delegate, resource_type_, context_, version_, @@ -121,7 +121,7 @@ bool ServiceWorkerContextRequestHandler::ShouldAddToScriptCache( bool ServiceWorkerContextRequestHandler::ShouldReadFromScriptCache( const GURL& url, - int64* resource_id_out) { + int64_t* resource_id_out) { // We don't read from the script cache until the version is INSTALLED. if (version_->status() == ServiceWorkerVersion::NEW || version_->status() == ServiceWorkerVersion::INSTALLING) diff --git a/content/browser/service_worker/service_worker_context_request_handler.h b/content/browser/service_worker/service_worker_context_request_handler.h index e936462..e86fb83 100644 --- a/content/browser/service_worker/service_worker_context_request_handler.h +++ b/content/browser/service_worker/service_worker_context_request_handler.h @@ -5,6 +5,9 @@ #ifndef CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_CONTEXT_REQUEST_HANDLER_H_ #define CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_CONTEXT_REQUEST_HANDLER_H_ +#include <stdint.h> + +#include "base/macros.h" #include "content/browser/service_worker/service_worker_request_handler.h" namespace content { @@ -33,7 +36,7 @@ class CONTENT_EXPORT ServiceWorkerContextRequestHandler private: bool ShouldAddToScriptCache(const GURL& url); - bool ShouldReadFromScriptCache(const GURL& url, int64* resource_id_out); + bool ShouldReadFromScriptCache(const GURL& url, int64_t* resource_id_out); scoped_refptr<ServiceWorkerVersion> version_; diff --git a/content/browser/service_worker/service_worker_context_unittest.cc b/content/browser/service_worker/service_worker_context_unittest.cc index 78c8eb9..a9c89847 100644 --- a/content/browser/service_worker/service_worker_context_unittest.cc +++ b/content/browser/service_worker/service_worker_context_unittest.cc @@ -4,6 +4,8 @@ #include "content/public/browser/service_worker_context.h" +#include <stdint.h> + #include "base/files/scoped_temp_dir.h" #include "base/logging.h" #include "base/message_loop/message_loop.h" @@ -27,10 +29,10 @@ namespace content { namespace { void SaveResponseCallback(bool* called, - int64* store_registration_id, + int64_t* store_registration_id, ServiceWorkerStatusCode status, const std::string& status_message, - int64 registration_id) { + int64_t registration_id) { EXPECT_EQ(SERVICE_WORKER_OK, status) << ServiceWorkerStatusToString(status); *called = true; *store_registration_id = registration_id; @@ -38,7 +40,7 @@ void SaveResponseCallback(bool* called, ServiceWorkerContextCore::RegistrationCallback MakeRegisteredCallback( bool* called, - int64* store_registration_id) { + int64_t* store_registration_id) { return base::Bind(&SaveResponseCallback, called, store_registration_id); } @@ -110,7 +112,7 @@ enum NotificationType { struct NotificationLog { NotificationType type; GURL pattern; - int64 registration_id; + int64_t registration_id; }; } // namespace @@ -129,7 +131,7 @@ class ServiceWorkerContextTest : public ServiceWorkerContextObserver, void TearDown() override { helper_.reset(); } // ServiceWorkerContextObserver overrides. - void OnRegistrationStored(int64 registration_id, + void OnRegistrationStored(int64_t registration_id, const GURL& pattern) override { NotificationLog log; log.type = REGISTRATION_STORED; @@ -137,7 +139,7 @@ class ServiceWorkerContextTest : public ServiceWorkerContextObserver, log.registration_id = registration_id; notifications_.push_back(log); } - void OnRegistrationDeleted(int64 registration_id, + void OnRegistrationDeleted(int64_t registration_id, const GURL& pattern) override { NotificationLog log; log.type = REGISTRATION_DELETED; @@ -164,7 +166,7 @@ TEST_F(ServiceWorkerContextTest, Register) { GURL pattern("http://www.example.com/"); GURL script_url("http://www.example.com/service_worker.js"); - int64 registration_id = kInvalidServiceWorkerRegistrationId; + int64_t registration_id = kInvalidServiceWorkerRegistrationId; bool called = false; context()->RegisterServiceWorker( pattern, @@ -212,7 +214,7 @@ TEST_F(ServiceWorkerContextTest, Register_RejectInstall) { helper_.reset(); // Make sure the process lookups stay overridden. helper_.reset(new RejectInstallTestHelper); helper_->context_wrapper()->AddObserver(this); - int64 registration_id = kInvalidServiceWorkerRegistrationId; + int64_t registration_id = kInvalidServiceWorkerRegistrationId; bool called = false; context()->RegisterServiceWorker( pattern, @@ -259,7 +261,7 @@ TEST_F(ServiceWorkerContextTest, Register_RejectActivate) { helper_.reset(); helper_.reset(new RejectActivateTestHelper); helper_->context_wrapper()->AddObserver(this); - int64 registration_id = kInvalidServiceWorkerRegistrationId; + int64_t registration_id = kInvalidServiceWorkerRegistrationId; bool called = false; context()->RegisterServiceWorker( pattern, script_url, NULL, @@ -297,7 +299,7 @@ TEST_F(ServiceWorkerContextTest, Unregister) { GURL pattern("http://www.example.com/"); bool called = false; - int64 registration_id = kInvalidServiceWorkerRegistrationId; + int64_t registration_id = kInvalidServiceWorkerRegistrationId; context()->RegisterServiceWorker( pattern, GURL("http://www.example.com/service_worker.js"), @@ -343,10 +345,10 @@ TEST_F(ServiceWorkerContextTest, UnregisterMultiple) { GURL origin3_p1("http://www.other.com/"); bool called = false; - int64 registration_id1 = kInvalidServiceWorkerRegistrationId; - int64 registration_id2 = kInvalidServiceWorkerRegistrationId; - int64 registration_id3 = kInvalidServiceWorkerRegistrationId; - int64 registration_id4 = kInvalidServiceWorkerRegistrationId; + int64_t registration_id1 = kInvalidServiceWorkerRegistrationId; + int64_t registration_id2 = kInvalidServiceWorkerRegistrationId; + int64_t registration_id3 = kInvalidServiceWorkerRegistrationId; + int64_t registration_id4 = kInvalidServiceWorkerRegistrationId; context()->RegisterServiceWorker( origin1_p1, GURL("http://www.example.com/service_worker.js"), @@ -443,7 +445,7 @@ TEST_F(ServiceWorkerContextTest, RegisterNewScript) { GURL pattern("http://www.example.com/"); bool called = false; - int64 old_registration_id = kInvalidServiceWorkerRegistrationId; + int64_t old_registration_id = kInvalidServiceWorkerRegistrationId; context()->RegisterServiceWorker( pattern, GURL("http://www.example.com/service_worker.js"), @@ -456,7 +458,7 @@ TEST_F(ServiceWorkerContextTest, RegisterNewScript) { EXPECT_NE(kInvalidServiceWorkerRegistrationId, old_registration_id); called = false; - int64 new_registration_id = kInvalidServiceWorkerRegistrationId; + int64_t new_registration_id = kInvalidServiceWorkerRegistrationId; context()->RegisterServiceWorker( pattern, GURL("http://www.example.com/service_worker_new.js"), @@ -486,7 +488,7 @@ TEST_F(ServiceWorkerContextTest, RegisterDuplicateScript) { GURL script_url("http://www.example.com/service_worker.js"); bool called = false; - int64 old_registration_id = kInvalidServiceWorkerRegistrationId; + int64_t old_registration_id = kInvalidServiceWorkerRegistrationId; context()->RegisterServiceWorker( pattern, script_url, @@ -499,7 +501,7 @@ TEST_F(ServiceWorkerContextTest, RegisterDuplicateScript) { EXPECT_NE(kInvalidServiceWorkerRegistrationId, old_registration_id); called = false; - int64 new_registration_id = kInvalidServiceWorkerRegistrationId; + int64_t new_registration_id = kInvalidServiceWorkerRegistrationId; context()->RegisterServiceWorker( pattern, script_url, @@ -619,7 +621,7 @@ TEST_P(ServiceWorkerContextRecoveryTest, DeleteAndStartOver) { helper_->context_wrapper()->AddObserver(this); } - int64 registration_id = kInvalidServiceWorkerRegistrationId; + int64_t registration_id = kInvalidServiceWorkerRegistrationId; bool called = false; context()->RegisterServiceWorker( pattern, diff --git a/content/browser/service_worker/service_worker_context_watcher.cc b/content/browser/service_worker/service_worker_context_watcher.cc index 9c0a24c..cee965b 100644 --- a/content/browser/service_worker/service_worker_context_watcher.cc +++ b/content/browser/service_worker/service_worker_context_watcher.cc @@ -63,7 +63,7 @@ void ServiceWorkerContextWatcher::OnStoredRegistrationsOnIOThread( DCHECK_CURRENTLY_ON(BrowserThread::IO); context_->AddObserver(this); - base::ScopedPtrHashMap<int64, scoped_ptr<ServiceWorkerRegistrationInfo>> + base::ScopedPtrHashMap<int64_t, scoped_ptr<ServiceWorkerRegistrationInfo>> registration_info_map; for (const auto& registration : stored_registrations) StoreRegistrationInfo(registration, ®istration_info_map); @@ -105,7 +105,7 @@ ServiceWorkerContextWatcher::~ServiceWorkerContextWatcher() { void ServiceWorkerContextWatcher::StoreRegistrationInfo( const ServiceWorkerRegistrationInfo& registration_info, - base::ScopedPtrHashMap<int64, scoped_ptr<ServiceWorkerRegistrationInfo>>* + base::ScopedPtrHashMap<int64_t, scoped_ptr<ServiceWorkerRegistrationInfo>>* info_map) { DCHECK_CURRENTLY_ON(BrowserThread::IO); if (registration_info.registration_id == kInvalidServiceWorkerRegistrationId) @@ -129,7 +129,7 @@ void ServiceWorkerContextWatcher::StoreVersionInfo( } void ServiceWorkerContextWatcher::SendRegistrationInfo( - int64 registration_id, + int64_t registration_id, const GURL& pattern, ServiceWorkerRegistrationInfo::DeleteFlag delete_flag) { std::vector<ServiceWorkerRegistrationInfo> registrations; @@ -154,14 +154,14 @@ void ServiceWorkerContextWatcher::SendVersionInfo( base::Bind(version_callback_, versions)); } -void ServiceWorkerContextWatcher::OnNewLiveRegistration(int64 registration_id, +void ServiceWorkerContextWatcher::OnNewLiveRegistration(int64_t registration_id, const GURL& pattern) { SendRegistrationInfo(registration_id, pattern, ServiceWorkerRegistrationInfo::IS_NOT_DELETED); } -void ServiceWorkerContextWatcher::OnNewLiveVersion(int64 version_id, - int64 registration_id, +void ServiceWorkerContextWatcher::OnNewLiveVersion(int64_t version_id, + int64_t registration_id, const GURL& script_url) { if (ServiceWorkerVersionInfo* version = version_info_map_.get(version_id)) { DCHECK_EQ(version->registration_id, registration_id); @@ -179,7 +179,7 @@ void ServiceWorkerContextWatcher::OnNewLiveVersion(int64 version_id, } void ServiceWorkerContextWatcher::OnRunningStateChanged( - int64 version_id, + int64_t version_id, content::ServiceWorkerVersion::RunningStatus running_status) { ServiceWorkerVersionInfo* version = version_info_map_.get(version_id); DCHECK(version); @@ -192,7 +192,7 @@ void ServiceWorkerContextWatcher::OnRunningStateChanged( } void ServiceWorkerContextWatcher::OnVersionStateChanged( - int64 version_id, + int64_t version_id, content::ServiceWorkerVersion::Status status) { ServiceWorkerVersionInfo* version = version_info_map_.get(version_id); DCHECK(version); @@ -205,7 +205,7 @@ void ServiceWorkerContextWatcher::OnVersionStateChanged( } void ServiceWorkerContextWatcher::OnMainScriptHttpResponseInfoSet( - int64 version_id, + int64_t version_id, base::Time script_response_time, base::Time script_last_modified) { ServiceWorkerVersionInfo* version = version_info_map_.get(version_id); @@ -215,11 +215,11 @@ void ServiceWorkerContextWatcher::OnMainScriptHttpResponseInfoSet( SendVersionInfo(*version); } -void ServiceWorkerContextWatcher::OnErrorReported(int64 version_id, +void ServiceWorkerContextWatcher::OnErrorReported(int64_t version_id, int process_id, int thread_id, const ErrorInfo& info) { - int64 registration_id = kInvalidServiceWorkerRegistrationId; + int64_t registration_id = kInvalidServiceWorkerRegistrationId; if (ServiceWorkerVersionInfo* version = version_info_map_.get(version_id)) registration_id = version->registration_id; BrowserThread::PostTask( @@ -228,13 +228,13 @@ void ServiceWorkerContextWatcher::OnErrorReported(int64 version_id, } void ServiceWorkerContextWatcher::OnReportConsoleMessage( - int64 version_id, + int64_t version_id, int process_id, int thread_id, const ConsoleMessage& message) { if (message.message_level != CONSOLE_MESSAGE_LEVEL_ERROR) return; - int64 registration_id = kInvalidServiceWorkerRegistrationId; + int64_t registration_id = kInvalidServiceWorkerRegistrationId; if (ServiceWorkerVersionInfo* version = version_info_map_.get(version_id)) registration_id = version->registration_id; BrowserThread::PostTask( @@ -245,7 +245,7 @@ void ServiceWorkerContextWatcher::OnReportConsoleMessage( } void ServiceWorkerContextWatcher::OnControlleeAdded( - int64 version_id, + int64_t version_id, const std::string& uuid, int process_id, int route_id, @@ -257,7 +257,7 @@ void ServiceWorkerContextWatcher::OnControlleeAdded( SendVersionInfo(*version); } -void ServiceWorkerContextWatcher::OnControlleeRemoved(int64 version_id, +void ServiceWorkerContextWatcher::OnControlleeRemoved(int64_t version_id, const std::string& uuid) { ServiceWorkerVersionInfo* version = version_info_map_.get(version_id); if (!version) @@ -266,20 +266,20 @@ void ServiceWorkerContextWatcher::OnControlleeRemoved(int64 version_id, SendVersionInfo(*version); } -void ServiceWorkerContextWatcher::OnRegistrationStored(int64 registration_id, +void ServiceWorkerContextWatcher::OnRegistrationStored(int64_t registration_id, const GURL& pattern) { SendRegistrationInfo(registration_id, pattern, ServiceWorkerRegistrationInfo::IS_NOT_DELETED); } -void ServiceWorkerContextWatcher::OnRegistrationDeleted(int64 registration_id, +void ServiceWorkerContextWatcher::OnRegistrationDeleted(int64_t registration_id, const GURL& pattern) { SendRegistrationInfo(registration_id, pattern, ServiceWorkerRegistrationInfo::IS_DELETED); } void ServiceWorkerContextWatcher::OnForceUpdateOnPageLoadChanged( - int64 registration_id, + int64_t registration_id, bool force_update_on_page_load) { ServiceWorkerRegistration* registration = context_->GetLiveRegistration(registration_id); diff --git a/content/browser/service_worker/service_worker_context_watcher.h b/content/browser/service_worker/service_worker_context_watcher.h index a7b430e..506418b 100644 --- a/content/browser/service_worker/service_worker_context_watcher.h +++ b/content/browser/service_worker/service_worker_context_watcher.h @@ -5,6 +5,8 @@ #ifndef CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_CONTEXT_WATCHER_H_ #define CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_CONTEXT_WATCHER_H_ +#include <stdint.h> + #include <vector> #include "base/callback.h" @@ -27,8 +29,8 @@ class ServiceWorkerContextWatcher WorkerRegistrationUpdatedCallback; typedef base::Callback<void(const std::vector<ServiceWorkerVersionInfo>&)> WorkerVersionUpdatedCallback; - typedef base::Callback<void(int64 /* registration_id */, - int64 /* version_id */, + typedef base::Callback<void(int64_t /* registration_id */, + int64_t /* version_id */, const ErrorInfo&)> WorkerErrorReportedCallback; ServiceWorkerContextWatcher( @@ -50,54 +52,56 @@ class ServiceWorkerContextWatcher void StoreRegistrationInfo( const ServiceWorkerRegistrationInfo& registration, - base::ScopedPtrHashMap<int64, scoped_ptr<ServiceWorkerRegistrationInfo>>* + base::ScopedPtrHashMap<int64_t, + scoped_ptr<ServiceWorkerRegistrationInfo>>* info_map); void StoreVersionInfo(const ServiceWorkerVersionInfo& version); void SendRegistrationInfo( - int64 registration_id, + int64_t registration_id, const GURL& pattern, ServiceWorkerRegistrationInfo::DeleteFlag delete_flag); void SendVersionInfo(const ServiceWorkerVersionInfo& version); // ServiceWorkerContextObserver implements - void OnNewLiveRegistration(int64 registration_id, + void OnNewLiveRegistration(int64_t registration_id, const GURL& pattern) override; - void OnNewLiveVersion(int64 version_id, - int64 registration_id, + void OnNewLiveVersion(int64_t version_id, + int64_t registration_id, const GURL& script_url) override; void OnRunningStateChanged( - int64 version_id, + int64_t version_id, content::ServiceWorkerVersion::RunningStatus running_status) override; void OnVersionStateChanged( - int64 version_id, + int64_t version_id, content::ServiceWorkerVersion::Status status) override; void OnMainScriptHttpResponseInfoSet( - int64 version_id, + int64_t version_id, base::Time script_response_time, base::Time script_last_modified) override; - void OnErrorReported(int64 version_id, + void OnErrorReported(int64_t version_id, int process_id, int thread_id, const ErrorInfo& info) override; - void OnReportConsoleMessage(int64 version_id, + void OnReportConsoleMessage(int64_t version_id, int process_id, int thread_id, const ConsoleMessage& message) override; - void OnControlleeAdded(int64 version_id, + void OnControlleeAdded(int64_t version_id, const std::string& uuid, int process_id, int route_id, ServiceWorkerProviderType type) override; - void OnControlleeRemoved(int64 version_id, const std::string& uuid) override; - void OnRegistrationStored(int64 registration_id, + void OnControlleeRemoved(int64_t version_id, + const std::string& uuid) override; + void OnRegistrationStored(int64_t registration_id, const GURL& pattern) override; - void OnRegistrationDeleted(int64 registration_id, + void OnRegistrationDeleted(int64_t registration_id, const GURL& pattern) override; - void OnForceUpdateOnPageLoadChanged(int64 registration_id, + void OnForceUpdateOnPageLoadChanged(int64_t registration_id, bool force_update_on_page_load) override; - base::ScopedPtrHashMap<int64, scoped_ptr<ServiceWorkerVersionInfo>> + base::ScopedPtrHashMap<int64_t, scoped_ptr<ServiceWorkerVersionInfo>> version_info_map_; scoped_refptr<ServiceWorkerContextWrapper> context_; WorkerRegistrationUpdatedCallback registration_callback_; diff --git a/content/browser/service_worker/service_worker_context_wrapper.cc b/content/browser/service_worker/service_worker_context_wrapper.cc index da6970e..81a6416 100644 --- a/content/browser/service_worker/service_worker_context_wrapper.cc +++ b/content/browser/service_worker/service_worker_context_wrapper.cc @@ -170,7 +170,7 @@ static void FinishRegistrationOnIO( const ServiceWorkerContext::ResultCallback& continuation, ServiceWorkerStatusCode status, const std::string& status_message, - int64 registration_id) { + int64_t registration_id) { DCHECK_CURRENTLY_ON(BrowserThread::IO); BrowserThread::PostTask( BrowserThread::UI, diff --git a/content/browser/service_worker/service_worker_context_wrapper.h b/content/browser/service_worker/service_worker_context_wrapper.h index 93cd72d..a81e888 100644 --- a/content/browser/service_worker/service_worker_context_wrapper.h +++ b/content/browser/service_worker/service_worker_context_wrapper.h @@ -5,9 +5,12 @@ #ifndef CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_CONTEXT_WRAPPER_H_ #define CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_CONTEXT_WRAPPER_H_ +#include <stdint.h> + #include <vector> #include "base/files/file_path.h" +#include "base/macros.h" #include "base/memory/ref_counted.h" #include "base/memory/scoped_ptr.h" #include "content/browser/service_worker/service_worker_context_core.h" diff --git a/content/browser/service_worker/service_worker_controllee_request_handler.cc b/content/browser/service_worker/service_worker_controllee_request_handler.cc index 3c3cb45..85de531 100644 --- a/content/browser/service_worker/service_worker_controllee_request_handler.cc +++ b/content/browser/service_worker/service_worker_controllee_request_handler.cc @@ -298,7 +298,7 @@ void ServiceWorkerControlleeRequestHandler::DidUpdateRegistration( const scoped_refptr<ServiceWorkerRegistration>& original_registration, ServiceWorkerStatusCode status, const std::string& status_message, - int64 registration_id) { + int64_t registration_id) { DCHECK(force_update_started_); // The job may have been canceled and then destroyed before this was invoked. diff --git a/content/browser/service_worker/service_worker_controllee_request_handler.h b/content/browser/service_worker/service_worker_controllee_request_handler.h index dca78ef..1526385 100644 --- a/content/browser/service_worker/service_worker_controllee_request_handler.h +++ b/content/browser/service_worker/service_worker_controllee_request_handler.h @@ -5,6 +5,8 @@ #ifndef CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_CONTROLLEE_REQUEST_HANDLER_H_ #define CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_CONTROLLEE_REQUEST_HANDLER_H_ +#include <stdint.h> + #include "base/gtest_prod_util.h" #include "base/macros.h" #include "base/memory/ref_counted.h" @@ -75,7 +77,7 @@ class CONTENT_EXPORT ServiceWorkerControlleeRequestHandler const scoped_refptr<ServiceWorkerRegistration>& original_registration, ServiceWorkerStatusCode status, const std::string& status_message, - int64 registration_id); + int64_t registration_id); void OnUpdatedVersionStatusChanged( const scoped_refptr<ServiceWorkerRegistration>& registration, const scoped_refptr<ServiceWorkerVersion>& version); diff --git a/content/browser/service_worker/service_worker_database.cc b/content/browser/service_worker/service_worker_database.cc index ac96e43..cf6e941 100644 --- a/content/browser/service_worker/service_worker_database.cc +++ b/content/browser/service_worker/service_worker_database.cc @@ -28,7 +28,7 @@ // ======================= // // NOTE -// - int64 value is serialized as a string by base::Int64ToString(). +// - int64_t value is serialized as a string by base::Int64ToString(). // - GURL value is serialized as a string by GURL::spec(). // // Version 1 (in sorted order) @@ -36,43 +36,43 @@ // value: "1" // // key: "INITDATA_NEXT_REGISTRATION_ID" -// value: <int64 'next_available_registration_id'> +// value: <int64_t 'next_available_registration_id'> // // key: "INITDATA_NEXT_RESOURCE_ID" -// value: <int64 'next_available_resource_id'> +// value: <int64_t 'next_available_resource_id'> // // key: "INITDATA_NEXT_VERSION_ID" -// value: <int64 'next_available_version_id'> +// value: <int64_t 'next_available_version_id'> // // key: "INITDATA_UNIQUE_ORIGIN:" + <GURL 'origin'> // value: <empty> // -// key: "PRES:" + <int64 'purgeable_resource_id'> +// key: "PRES:" + <int64_t 'purgeable_resource_id'> // value: <empty> // -// key: "REG:" + <GURL 'origin'> + '\x00' + <int64 'registration_id'> +// key: "REG:" + <GURL 'origin'> + '\x00' + <int64_t 'registration_id'> // (ex. "REG:http://example.com\x00123456") // value: <ServiceWorkerRegistrationData serialized as a string> // // key: "REG_HAS_USER_DATA:" + <std::string 'user_data_name'> + '\x00' -// + <int64 'registration_id'> +// + <int64_t 'registration_id'> // value: <empty> // -// key: "REG_USER_DATA:" + <int64 'registration_id'> + '\x00' +// key: "REG_USER_DATA:" + <int64_t 'registration_id'> + '\x00' // + <std::string user_data_name> // (ex. "REG_USER_DATA:123456\x00foo_bar") // value: <std::string user_data> // -// key: "RES:" + <int64 'version_id'> + '\x00' + <int64 'resource_id'> +// key: "RES:" + <int64_t 'version_id'> + '\x00' + <int64_t 'resource_id'> // (ex. "RES:123456\x00654321") // value: <ServiceWorkerResourceRecord serialized as a string> // -// key: "URES:" + <int64 'uncommitted_resource_id'> +// key: "URES:" + <int64_t 'uncommitted_resource_id'> // value: <empty> // // Version 2 // -// key: "REGID_TO_ORIGIN:" + <int64 'registration_id'> +// key: "REGID_TO_ORIGIN:" + <int64_t 'registration_id'> // value: <GURL 'origin'> // // OBSOLETE: http://crbug.com/539713 @@ -110,7 +110,7 @@ const char kKeySeparator = '\x00'; const char kUncommittedResIdKeyPrefix[] = "URES:"; const char kPurgeableResIdKeyPrefix[] = "PRES:"; -const int64 kCurrentSchemaVersion = 2; +const int64_t kCurrentSchemaVersion = 2; class ServiceWorkerEnv : public leveldb_env::ChromiumEnv { public: @@ -136,21 +136,19 @@ std::string CreateRegistrationKeyPrefix(const GURL& origin) { origin.GetOrigin().spec().c_str(), kKeySeparator); } -std::string CreateRegistrationKey(int64 registration_id, - const GURL& origin) { +std::string CreateRegistrationKey(int64_t registration_id, const GURL& origin) { return CreateRegistrationKeyPrefix(origin) .append(base::Int64ToString(registration_id)); } -std::string CreateResourceRecordKeyPrefix(int64 version_id) { +std::string CreateResourceRecordKeyPrefix(int64_t version_id) { return base::StringPrintf("%s%s%c", kResKeyPrefix, base::Int64ToString(version_id).c_str(), kKeySeparator); } -std::string CreateResourceRecordKey(int64 version_id, - int64 resource_id) { +std::string CreateResourceRecordKey(int64_t version_id, int64_t resource_id) { return CreateResourceRecordKeyPrefix(version_id).append( base::Int64ToString(resource_id)); } @@ -165,19 +163,19 @@ std::string CreateForeignFetchOriginKey(const GURL& origin) { origin.GetOrigin().spec().c_str()); } -std::string CreateResourceIdKey(const char* key_prefix, int64 resource_id) { +std::string CreateResourceIdKey(const char* key_prefix, int64_t resource_id) { return base::StringPrintf( "%s%s", key_prefix, base::Int64ToString(resource_id).c_str()); } -std::string CreateUserDataKeyPrefix(int64 registration_id) { +std::string CreateUserDataKeyPrefix(int64_t registration_id) { return base::StringPrintf("%s%s%c", kRegUserDataKeyPrefix, base::Int64ToString(registration_id).c_str(), kKeySeparator); } -std::string CreateUserDataKey(int64 registration_id, +std::string CreateUserDataKey(int64_t registration_id, const std::string& user_data_name) { return CreateUserDataKeyPrefix(registration_id).append(user_data_name); } @@ -187,13 +185,13 @@ std::string CreateHasUserDataKeyPrefix(const std::string& user_data_name) { user_data_name.c_str(), kKeySeparator); } -std::string CreateHasUserDataKey(int64 registration_id, +std::string CreateHasUserDataKey(int64_t registration_id, const std::string& user_data_name) { return CreateHasUserDataKeyPrefix(user_data_name) .append(base::Int64ToString(registration_id)); } -std::string CreateRegistrationIdToOriginKey(int64 registration_id) { +std::string CreateRegistrationIdToOriginKey(int64_t registration_id) { return base::StringPrintf("%s%s", kRegIdToOriginKeyPrefix, base::Int64ToString(registration_id).c_str()); } @@ -229,7 +227,7 @@ void PutRegistrationDataToBatch( void PutResourceRecordToBatch( const ServiceWorkerDatabase::ResourceRecord& input, - int64 version_id, + int64_t version_id, leveldb::WriteBatch* batch) { DCHECK(batch); DCHECK_GE(input.size_bytes, 0); @@ -252,7 +250,7 @@ void PutUniqueOriginToBatch(const GURL& origin, batch->Put(CreateUniqueOriginKey(origin), ""); } -void PutPurgeableResourceIdToBatch(int64 resource_id, +void PutPurgeableResourceIdToBatch(int64_t resource_id, leveldb::WriteBatch* batch) { // Value should be empty. batch->Put(CreateResourceIdKey(kPurgeableResIdKeyPrefix, resource_id), ""); @@ -264,11 +262,10 @@ void PutForeignFetchOriginToBatch(const GURL& origin, batch->Put(CreateForeignFetchOriginKey(origin), ""); } -ServiceWorkerDatabase::Status ParseId( - const std::string& serialized, - int64* out) { +ServiceWorkerDatabase::Status ParseId(const std::string& serialized, + int64_t* out) { DCHECK(out); - int64 id; + int64_t id; if (!base::StringToInt64(serialized, &id) || id < 0) return ServiceWorkerDatabase::STATUS_ERROR_CORRUPTED; *out = id; @@ -277,10 +274,10 @@ ServiceWorkerDatabase::Status ParseId( ServiceWorkerDatabase::Status ParseDatabaseVersion( const std::string& serialized, - int64* out) { + int64_t* out) { DCHECK(out); const int kFirstValidVersion = 1; - int64 version; + int64_t version; if (!base::StringToInt64(serialized, &version) || version < kFirstValidVersion) { return ServiceWorkerDatabase::STATUS_ERROR_CORRUPTED; @@ -433,9 +430,9 @@ ServiceWorkerDatabase::~ServiceWorkerDatabase() { } ServiceWorkerDatabase::Status ServiceWorkerDatabase::GetNextAvailableIds( - int64* next_avail_registration_id, - int64* next_avail_version_id, - int64* next_avail_resource_id) { + int64_t* next_avail_registration_id, + int64_t* next_avail_version_id, + int64_t* next_avail_resource_id) { DCHECK(sequence_checker_.CalledOnValidSequencedThread()); DCHECK(next_avail_registration_id); DCHECK(next_avail_version_id); @@ -641,7 +638,7 @@ ServiceWorkerDatabase::Status ServiceWorkerDatabase::GetAllRegistrations( } ServiceWorkerDatabase::Status ServiceWorkerDatabase::ReadRegistration( - int64 registration_id, + int64_t registration_id, const GURL& origin, RegistrationData* registration, std::vector<ResourceRecord>* resources) { @@ -673,7 +670,7 @@ ServiceWorkerDatabase::Status ServiceWorkerDatabase::ReadRegistration( } ServiceWorkerDatabase::Status ServiceWorkerDatabase::ReadRegistrationOrigin( - int64 registration_id, + int64_t registration_id, GURL* origin) { DCHECK(sequence_checker_.CalledOnValidSequencedThread()); DCHECK(origin); @@ -710,7 +707,7 @@ ServiceWorkerDatabase::Status ServiceWorkerDatabase::WriteRegistration( const RegistrationData& registration, const std::vector<ResourceRecord>& resources, RegistrationData* old_registration, - std::vector<int64>* newly_purgeable_resources) { + std::vector<int64_t>* newly_purgeable_resources) { DCHECK(sequence_checker_.CalledOnValidSequencedThread()); DCHECK(old_registration); DCHECK(!resources.empty()); @@ -738,7 +735,7 @@ ServiceWorkerDatabase::Status ServiceWorkerDatabase::WriteRegistration( registration.scope.GetOrigin().spec()); // Used for avoiding multiple writes for the same resource id or url. - std::set<int64> pushed_resources; + std::set<int64_t> pushed_resources; std::set<GURL> pushed_urls; for (std::vector<ResourceRecord>::const_iterator itr = resources.begin(); itr != resources.end(); ++itr) { @@ -775,10 +772,11 @@ ServiceWorkerDatabase::Status ServiceWorkerDatabase::WriteRegistration( // Currently resource sharing across versions and registrations is not // supported, so resource ids should not be overlapped between // |registration| and |old_registration|. - std::set<int64> deleted_resources(newly_purgeable_resources->begin(), - newly_purgeable_resources->end()); - DCHECK(base::STLSetIntersection<std::set<int64> >( - pushed_resources, deleted_resources).empty()); + std::set<int64_t> deleted_resources(newly_purgeable_resources->begin(), + newly_purgeable_resources->end()); + DCHECK(base::STLSetIntersection<std::set<int64_t>>(pushed_resources, + deleted_resources) + .empty()); // If old registration had foreign fetch scopes, but new registration // doesn't, the origin might have to be removed from the list of origins @@ -810,7 +808,7 @@ ServiceWorkerDatabase::Status ServiceWorkerDatabase::WriteRegistration( } ServiceWorkerDatabase::Status ServiceWorkerDatabase::UpdateVersionToActive( - int64 registration_id, + int64_t registration_id, const GURL& origin) { DCHECK(sequence_checker_.CalledOnValidSequencedThread()); Status status = LazyOpen(false); @@ -834,7 +832,7 @@ ServiceWorkerDatabase::Status ServiceWorkerDatabase::UpdateVersionToActive( } ServiceWorkerDatabase::Status ServiceWorkerDatabase::UpdateLastCheckTime( - int64 registration_id, + int64_t registration_id, const GURL& origin, const base::Time& time) { DCHECK(sequence_checker_.CalledOnValidSequencedThread()); @@ -859,10 +857,10 @@ ServiceWorkerDatabase::Status ServiceWorkerDatabase::UpdateLastCheckTime( } ServiceWorkerDatabase::Status ServiceWorkerDatabase::DeleteRegistration( - int64 registration_id, + int64_t registration_id, const GURL& origin, RegistrationData* deleted_version, - std::vector<int64>* newly_purgeable_resources) { + std::vector<int64_t>* newly_purgeable_resources) { DCHECK(sequence_checker_.CalledOnValidSequencedThread()); DCHECK(deleted_version); deleted_version->version_id = kInvalidServiceWorkerVersionId; @@ -926,7 +924,7 @@ ServiceWorkerDatabase::Status ServiceWorkerDatabase::DeleteRegistration( } ServiceWorkerDatabase::Status ServiceWorkerDatabase::ReadUserData( - int64 registration_id, + int64_t registration_id, const std::string& user_data_name, std::string* user_data) { DCHECK(sequence_checker_.CalledOnValidSequencedThread()); @@ -949,7 +947,7 @@ ServiceWorkerDatabase::Status ServiceWorkerDatabase::ReadUserData( } ServiceWorkerDatabase::Status ServiceWorkerDatabase::WriteUserData( - int64 registration_id, + int64_t registration_id, const GURL& origin, const std::string& user_data_name, const std::string& user_data) { @@ -976,7 +974,7 @@ ServiceWorkerDatabase::Status ServiceWorkerDatabase::WriteUserData( } ServiceWorkerDatabase::Status ServiceWorkerDatabase::DeleteUserData( - int64 registration_id, + int64_t registration_id, const std::string& user_data_name) { DCHECK(sequence_checker_.CalledOnValidSequencedThread()); DCHECK_NE(kInvalidServiceWorkerRegistrationId, registration_id); @@ -997,7 +995,7 @@ ServiceWorkerDatabase::Status ServiceWorkerDatabase::DeleteUserData( ServiceWorkerDatabase::Status ServiceWorkerDatabase::ReadUserDataForAllRegistrations( const std::string& user_data_name, - std::vector<std::pair<int64, std::string>>* user_data) { + std::vector<std::pair<int64_t, std::string>>* user_data) { DCHECK(sequence_checker_.CalledOnValidSequencedThread()); DCHECK(user_data->empty()); @@ -1023,7 +1021,7 @@ ServiceWorkerDatabase::ReadUserDataForAllRegistrations( break; } - int64 registration_id; + int64_t registration_id; status = ParseId(registration_id_string, ®istration_id); if (status != STATUS_OK) { HandleReadResult(FROM_HERE, status); @@ -1047,13 +1045,14 @@ ServiceWorkerDatabase::ReadUserDataForAllRegistrations( return status; } -ServiceWorkerDatabase::Status -ServiceWorkerDatabase::GetUncommittedResourceIds(std::set<int64>* ids) { +ServiceWorkerDatabase::Status ServiceWorkerDatabase::GetUncommittedResourceIds( + std::set<int64_t>* ids) { return ReadResourceIds(kUncommittedResIdKeyPrefix, ids); } ServiceWorkerDatabase::Status -ServiceWorkerDatabase::WriteUncommittedResourceIds(const std::set<int64>& ids) { +ServiceWorkerDatabase::WriteUncommittedResourceIds( + const std::set<int64_t>& ids) { leveldb::WriteBatch batch; Status status = WriteResourceIdsInBatch(kUncommittedResIdKeyPrefix, ids, &batch); @@ -1062,13 +1061,13 @@ ServiceWorkerDatabase::WriteUncommittedResourceIds(const std::set<int64>& ids) { return WriteBatch(&batch); } -ServiceWorkerDatabase::Status -ServiceWorkerDatabase::GetPurgeableResourceIds(std::set<int64>* ids) { +ServiceWorkerDatabase::Status ServiceWorkerDatabase::GetPurgeableResourceIds( + std::set<int64_t>* ids) { return ReadResourceIds(kPurgeableResIdKeyPrefix, ids); } -ServiceWorkerDatabase::Status -ServiceWorkerDatabase::ClearPurgeableResourceIds(const std::set<int64>& ids) { +ServiceWorkerDatabase::Status ServiceWorkerDatabase::ClearPurgeableResourceIds( + const std::set<int64_t>& ids) { leveldb::WriteBatch batch; Status status = DeleteResourceIdsInBatch(kPurgeableResIdKeyPrefix, ids, &batch); @@ -1079,7 +1078,7 @@ ServiceWorkerDatabase::ClearPurgeableResourceIds(const std::set<int64>& ids) { ServiceWorkerDatabase::Status ServiceWorkerDatabase::PurgeUncommittedResourceIds( - const std::set<int64>& ids) { + const std::set<int64_t>& ids) { leveldb::WriteBatch batch; Status status = DeleteResourceIdsInBatch( kUncommittedResIdKeyPrefix, ids, &batch); @@ -1093,7 +1092,7 @@ ServiceWorkerDatabase::PurgeUncommittedResourceIds( ServiceWorkerDatabase::Status ServiceWorkerDatabase::DeleteAllDataForOrigins( const std::set<GURL>& origins, - std::vector<int64>* newly_purgeable_resources) { + std::vector<int64_t>* newly_purgeable_resources) { DCHECK(sequence_checker_.CalledOnValidSequencedThread()); Status status = LazyOpen(false); if (IsNewOrNonexistentDatabase(status)) @@ -1194,7 +1193,7 @@ ServiceWorkerDatabase::Status ServiceWorkerDatabase::LazyOpen( } db_.reset(db); - int64 db_version; + int64_t db_version; status = ReadDatabaseVersion(&db_version); if (status != STATUS_OK) return status; @@ -1255,7 +1254,7 @@ ServiceWorkerDatabase::UpgradeDatabaseSchemaFromV1ToV2() { return status; } - int64 registration_id; + int64_t registration_id; status = ParseId(parts[1], ®istration_id); if (status != STATUS_OK) { HandleReadResult(FROM_HERE, status); @@ -1276,7 +1275,7 @@ ServiceWorkerDatabase::UpgradeDatabaseSchemaFromV1ToV2() { ServiceWorkerDatabase::Status ServiceWorkerDatabase::ReadNextAvailableId( const char* id_key, - int64* next_avail_id) { + int64_t* next_avail_id) { DCHECK(id_key); DCHECK(next_avail_id); @@ -1299,7 +1298,7 @@ ServiceWorkerDatabase::Status ServiceWorkerDatabase::ReadNextAvailableId( } ServiceWorkerDatabase::Status ServiceWorkerDatabase::ReadRegistrationData( - int64 registration_id, + int64_t registration_id, const GURL& origin, RegistrationData* registration) { DCHECK(registration); @@ -1321,7 +1320,7 @@ ServiceWorkerDatabase::Status ServiceWorkerDatabase::ReadRegistrationData( } ServiceWorkerDatabase::Status ServiceWorkerDatabase::ReadResourceRecords( - int64 version_id, + int64_t version_id, std::vector<ResourceRecord>* resources) { DCHECK(resources->empty()); @@ -1355,8 +1354,8 @@ ServiceWorkerDatabase::Status ServiceWorkerDatabase::ReadResourceRecords( } ServiceWorkerDatabase::Status ServiceWorkerDatabase::DeleteResourceRecords( - int64 version_id, - std::vector<int64>* newly_purgeable_resources, + int64_t version_id, + std::vector<int64_t>* newly_purgeable_resources, leveldb::WriteBatch* batch) { DCHECK(batch); @@ -1376,7 +1375,7 @@ ServiceWorkerDatabase::Status ServiceWorkerDatabase::DeleteResourceRecords( if (!RemovePrefix(key, prefix, &unprefixed)) break; - int64 resource_id; + int64_t resource_id; status = ParseId(unprefixed, &resource_id); if (status != STATUS_OK) { HandleReadResult(FROM_HERE, status); @@ -1398,7 +1397,7 @@ ServiceWorkerDatabase::Status ServiceWorkerDatabase::DeleteResourceRecords( ServiceWorkerDatabase::Status ServiceWorkerDatabase::ReadResourceIds( const char* id_key_prefix, - std::set<int64>* ids) { + std::set<int64_t>* ids) { DCHECK(sequence_checker_.CalledOnValidSequencedThread()); DCHECK(id_key_prefix); DCHECK(ids->empty()); @@ -1422,7 +1421,7 @@ ServiceWorkerDatabase::Status ServiceWorkerDatabase::ReadResourceIds( if (!RemovePrefix(itr->key().ToString(), id_key_prefix, &unprefixed)) break; - int64 resource_id; + int64_t resource_id; status = ParseId(unprefixed, &resource_id); if (status != STATUS_OK) { HandleReadResult(FROM_HERE, status); @@ -1438,7 +1437,7 @@ ServiceWorkerDatabase::Status ServiceWorkerDatabase::ReadResourceIds( ServiceWorkerDatabase::Status ServiceWorkerDatabase::WriteResourceIdsInBatch( const char* id_key_prefix, - const std::set<int64>& ids, + const std::set<int64_t>& ids, leveldb::WriteBatch* batch) { DCHECK(sequence_checker_.CalledOnValidSequencedThread()); DCHECK(id_key_prefix); @@ -1449,8 +1448,8 @@ ServiceWorkerDatabase::Status ServiceWorkerDatabase::WriteResourceIdsInBatch( if (ids.empty()) return STATUS_OK; - for (std::set<int64>::const_iterator itr = ids.begin(); - itr != ids.end(); ++itr) { + for (std::set<int64_t>::const_iterator itr = ids.begin(); itr != ids.end(); + ++itr) { // Value should be empty. batch->Put(CreateResourceIdKey(id_key_prefix, *itr), ""); } @@ -1461,7 +1460,7 @@ ServiceWorkerDatabase::Status ServiceWorkerDatabase::WriteResourceIdsInBatch( ServiceWorkerDatabase::Status ServiceWorkerDatabase::DeleteResourceIdsInBatch( const char* id_key_prefix, - const std::set<int64>& ids, + const std::set<int64_t>& ids, leveldb::WriteBatch* batch) { DCHECK(sequence_checker_.CalledOnValidSequencedThread()); DCHECK(id_key_prefix); @@ -1472,8 +1471,8 @@ ServiceWorkerDatabase::Status ServiceWorkerDatabase::DeleteResourceIdsInBatch( if (status != STATUS_OK) return status; - for (std::set<int64>::const_iterator itr = ids.begin(); - itr != ids.end(); ++itr) { + for (std::set<int64_t>::const_iterator itr = ids.begin(); itr != ids.end(); + ++itr) { batch->Delete(CreateResourceIdKey(id_key_prefix, *itr)); } return STATUS_OK; @@ -1481,7 +1480,7 @@ ServiceWorkerDatabase::Status ServiceWorkerDatabase::DeleteResourceIdsInBatch( ServiceWorkerDatabase::Status ServiceWorkerDatabase::DeleteUserDataForRegistration( - int64 registration_id, + int64_t registration_id, leveldb::WriteBatch* batch) { DCHECK(batch); Status status = STATUS_OK; @@ -1506,7 +1505,7 @@ ServiceWorkerDatabase::DeleteUserDataForRegistration( } ServiceWorkerDatabase::Status ServiceWorkerDatabase::ReadDatabaseVersion( - int64* db_version) { + int64_t* db_version) { std::string value; Status status = LevelDBStatusToStatus( db_->Get(leveldb::ReadOptions(), kDatabaseVersionKey, &value)); @@ -1545,7 +1544,8 @@ ServiceWorkerDatabase::Status ServiceWorkerDatabase::WriteBatch( } void ServiceWorkerDatabase::BumpNextRegistrationIdIfNeeded( - int64 used_id, leveldb::WriteBatch* batch) { + int64_t used_id, + leveldb::WriteBatch* batch) { DCHECK(batch); if (next_avail_registration_id_ <= used_id) { next_avail_registration_id_ = used_id + 1; @@ -1554,7 +1554,8 @@ void ServiceWorkerDatabase::BumpNextRegistrationIdIfNeeded( } void ServiceWorkerDatabase::BumpNextResourceIdIfNeeded( - int64 used_id, leveldb::WriteBatch* batch) { + int64_t used_id, + leveldb::WriteBatch* batch) { DCHECK(batch); if (next_avail_resource_id_ <= used_id) { next_avail_resource_id_ = used_id + 1; @@ -1563,7 +1564,8 @@ void ServiceWorkerDatabase::BumpNextResourceIdIfNeeded( } void ServiceWorkerDatabase::BumpNextVersionIdIfNeeded( - int64 used_id, leveldb::WriteBatch* batch) { + int64_t used_id, + leveldb::WriteBatch* batch) { DCHECK(batch); if (next_avail_version_id_ <= used_id) { next_avail_version_id_ = used_id + 1; diff --git a/content/browser/service_worker/service_worker_database.h b/content/browser/service_worker/service_worker_database.h index 7fa022f..e43bcd2 100644 --- a/content/browser/service_worker/service_worker_database.h +++ b/content/browser/service_worker/service_worker_database.h @@ -5,6 +5,8 @@ #ifndef CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_DATABASE_H_ #define CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_DATABASE_H_ +#include <stdint.h> + #include <map> #include <set> #include <string> @@ -54,14 +56,14 @@ class CONTENT_EXPORT ServiceWorkerDatabase { struct CONTENT_EXPORT RegistrationData { // These values are immutable for the life of a registration. - int64 registration_id; + int64_t registration_id; GURL scope; // Versions are first stored once they successfully install and become // the waiting version. Then transition to the active version. The stored // version may be in the ACTIVATED state or in the INSTALLED state. GURL script; - int64 version_id; + int64_t version_id; bool is_active; bool has_fetch_handler; base::Time last_update_check; @@ -75,24 +77,23 @@ class CONTENT_EXPORT ServiceWorkerDatabase { }; struct ResourceRecord { - int64 resource_id; + int64_t resource_id; GURL url; // Signed so we can store -1 to specify an unknown or error state. When // stored to the database, this value should always be >= 0. - int64 size_bytes; + int64_t size_bytes; ResourceRecord() : resource_id(-1), size_bytes(0) {} - ResourceRecord(int64 id, GURL url, int64 size_bytes) + ResourceRecord(int64_t id, GURL url, int64_t size_bytes) : resource_id(id), url(url), size_bytes(size_bytes) {} }; // Reads next available ids from the database. Returns OK if they are // successfully read. Fills the arguments with an initial value and returns // OK if they are not found in the database. Otherwise, returns an error. - Status GetNextAvailableIds( - int64* next_avail_registration_id, - int64* next_avail_version_id, - int64* next_avail_resource_id); + Status GetNextAvailableIds(int64_t* next_avail_registration_id, + int64_t* next_avail_version_id, + int64_t* next_avail_resource_id); // Reads origins that have one or more than one registration from the // database. Returns OK if they are successfully read or not found. @@ -123,16 +124,15 @@ class CONTENT_EXPORT ServiceWorkerDatabase { // Reads a registration for |registration_id| and resource records associated // with it from the database. Returns OK if they are successfully read. // Otherwise, returns an error. - Status ReadRegistration( - int64 registration_id, - const GURL& origin, - RegistrationData* registration, - std::vector<ResourceRecord>* resources); + Status ReadRegistration(int64_t registration_id, + const GURL& origin, + RegistrationData* registration, + std::vector<ResourceRecord>* resources); // Looks up the origin for the registration with |registration_id|. Returns OK // if a registration was found and read successfully. Otherwise, returns an // error. - Status ReadRegistrationOrigin(int64 registration_id, GURL* origin); + Status ReadRegistrationOrigin(int64_t registration_id, GURL* origin); // Writes |registration| and |resources| into the database and does following // things: @@ -146,20 +146,17 @@ class CONTENT_EXPORT ServiceWorkerDatabase { Status WriteRegistration(const RegistrationData& registration, const std::vector<ResourceRecord>& resources, RegistrationData* deleted_version, - std::vector<int64>* newly_purgeable_resources); + std::vector<int64_t>* newly_purgeable_resources); // Updates a registration for |registration_id| to an active state. Returns OK // if it's successfully updated. Otherwise, returns an error. - Status UpdateVersionToActive( - int64 registration_id, - const GURL& origin); + Status UpdateVersionToActive(int64_t registration_id, const GURL& origin); // Updates last check time of a registration for |registration_id| by |time|. // Returns OK if it's successfully updated. Otherwise, returns an error. - Status UpdateLastCheckTime( - int64 registration_id, - const GURL& origin, - const base::Time& time); + Status UpdateLastCheckTime(int64_t registration_id, + const GURL& origin, + const base::Time& time); // Deletes a registration for |registration_id| and moves resource records // associated with it into the purgeable list. If deletion occurred, sets @@ -167,20 +164,20 @@ class CONTENT_EXPORT ServiceWorkerDatabase { // |newly_purgeable_resources| to its resources; otherwise, sets |version_id| // to -1. Returns OK if it's successfully deleted or not found in the // database. Otherwise, returns an error. - Status DeleteRegistration(int64 registration_id, + Status DeleteRegistration(int64_t registration_id, const GURL& origin, RegistrationData* deleted_version, - std::vector<int64>* newly_purgeable_resources); + std::vector<int64_t>* newly_purgeable_resources); // Reads user data for |registration_id| and |user_data_name| from the // database. - Status ReadUserData(int64 registration_id, + Status ReadUserData(int64_t registration_id, const std::string& user_data_name, std::string* user_data); // Writes |user_data| into the database. Returns NOT_FOUND if the registration // specified by |registration_id| does not exist in the database. - Status WriteUserData(int64 registration_id, + Status WriteUserData(int64_t registration_id, const GURL& origin, const std::string& user_data_name, const std::string& user_data); @@ -188,14 +185,14 @@ class CONTENT_EXPORT ServiceWorkerDatabase { // Deletes user data for |registration_id| and |user_data_name| from the // database. Returns OK if it's successfully deleted or not found in the // database. - Status DeleteUserData(int64 registration_id, + Status DeleteUserData(int64_t registration_id, const std::string& user_data_name); // Reads user data for all registrations that have data with |user_data_name| // from the database. Returns OK if they are successfully read or not found. Status ReadUserDataForAllRegistrations( const std::string& user_data_name, - std::vector<std::pair<int64, std::string>>* user_data); + std::vector<std::pair<int64_t, std::string>>* user_data); // Resources should belong to one of following resource lists: uncommitted, // committed and purgeable. @@ -208,31 +205,32 @@ class CONTENT_EXPORT ServiceWorkerDatabase { // Reads resource ids from the uncommitted list. Returns OK on success. // Otherwise clears |ids| and returns an error. - Status GetUncommittedResourceIds(std::set<int64>* ids); + Status GetUncommittedResourceIds(std::set<int64_t>* ids); // Writes resource ids into the uncommitted list. Returns OK on success. // Otherwise writes nothing and returns an error. - Status WriteUncommittedResourceIds(const std::set<int64>& ids); + Status WriteUncommittedResourceIds(const std::set<int64_t>& ids); // Reads resource ids from the purgeable list. Returns OK on success. // Otherwise clears |ids| and returns an error. - Status GetPurgeableResourceIds(std::set<int64>* ids); + Status GetPurgeableResourceIds(std::set<int64_t>* ids); // Deletes resource ids from the purgeable list. Returns OK on success. // Otherwise deletes nothing and returns an error. - Status ClearPurgeableResourceIds(const std::set<int64>& ids); + Status ClearPurgeableResourceIds(const std::set<int64_t>& ids); // Writes resource ids into the purgeable list and removes them from the // uncommitted list. Returns OK on success. Otherwise writes nothing and // returns an error. - Status PurgeUncommittedResourceIds(const std::set<int64>& ids); + Status PurgeUncommittedResourceIds(const std::set<int64_t>& ids); // Deletes all data for |origins|, namely, unique origin, registrations and // resource records. Resources are moved to the purgeable list. Returns OK if // they are successfully deleted or not found in the database. Otherwise, // returns an error. - Status DeleteAllDataForOrigins(const std::set<GURL>& origins, - std::vector<int64>* newly_purgeable_resources); + Status DeleteAllDataForOrigins( + const std::set<GURL>& origins, + std::vector<int64_t>* newly_purgeable_resources); // Completely deletes the contents of the database. // Be careful using this function. @@ -257,63 +255,53 @@ class CONTENT_EXPORT ServiceWorkerDatabase { // Reads the next available id for |id_key|. Returns OK if it's successfully // read. Fills |next_avail_id| with an initial value and returns OK if it's // not found in the database. Otherwise, returns an error. - Status ReadNextAvailableId( - const char* id_key, - int64* next_avail_id); + Status ReadNextAvailableId(const char* id_key, int64_t* next_avail_id); // Reads registration data for |registration_id| from the database. Returns OK // if successfully reads. Otherwise, returns an error. - Status ReadRegistrationData( - int64 registration_id, - const GURL& origin, - RegistrationData* registration); + Status ReadRegistrationData(int64_t registration_id, + const GURL& origin, + RegistrationData* registration); // Reads resource records for |version_id| from the database. Returns OK if // it's successfully read or not found in the database. Otherwise, returns an // error. - Status ReadResourceRecords( - int64 version_id, - std::vector<ResourceRecord>* resources); + Status ReadResourceRecords(int64_t version_id, + std::vector<ResourceRecord>* resources); // Deletes resource records for |version_id| from the database. Returns OK if // they are successfully deleted or not found in the database. Otherwise, // returns an error. - Status DeleteResourceRecords( - int64 version_id, - std::vector<int64>* newly_purgeable_resources, - leveldb::WriteBatch* batch); + Status DeleteResourceRecords(int64_t version_id, + std::vector<int64_t>* newly_purgeable_resources, + leveldb::WriteBatch* batch); // Reads resource ids for |id_key_prefix| from the database. Returns OK if // it's successfully read or not found in the database. Otherwise, returns an // error. - Status ReadResourceIds( - const char* id_key_prefix, - std::set<int64>* ids); + Status ReadResourceIds(const char* id_key_prefix, std::set<int64_t>* ids); // Write resource ids for |id_key_prefix| into the database. Returns OK on // success. Otherwise, returns writes nothing and returns an error. - Status WriteResourceIdsInBatch( - const char* id_key_prefix, - const std::set<int64>& ids, - leveldb::WriteBatch* batch); + Status WriteResourceIdsInBatch(const char* id_key_prefix, + const std::set<int64_t>& ids, + leveldb::WriteBatch* batch); // Deletes resource ids for |id_key_prefix| from the database. Returns OK if // it's successfully deleted or not found in the database. Otherwise, returns // an error. - Status DeleteResourceIdsInBatch( - const char* id_key_prefix, - const std::set<int64>& ids, - leveldb::WriteBatch* batch); + Status DeleteResourceIdsInBatch(const char* id_key_prefix, + const std::set<int64_t>& ids, + leveldb::WriteBatch* batch); // Deletes all user data for |registration_id| from the database. Returns OK // if they are successfully deleted or not found in the database. - Status DeleteUserDataForRegistration( - int64 registration_id, - leveldb::WriteBatch* batch); + Status DeleteUserDataForRegistration(int64_t registration_id, + leveldb::WriteBatch* batch); // Reads the current schema version from the database. If the database hasn't // been written anything yet, sets |db_version| to 0 and returns OK. - Status ReadDatabaseVersion(int64* db_version); + Status ReadDatabaseVersion(int64_t* db_version); // Writes a batch into the database. // NOTE: You must call this when you want to put something into the database @@ -322,15 +310,10 @@ class CONTENT_EXPORT ServiceWorkerDatabase { // Bumps the next available id if |used_id| is greater than or equal to the // cached one. - void BumpNextRegistrationIdIfNeeded( - int64 used_id, - leveldb::WriteBatch* batch); - void BumpNextResourceIdIfNeeded( - int64 used_id, - leveldb::WriteBatch* batch); - void BumpNextVersionIdIfNeeded( - int64 used_id, - leveldb::WriteBatch* batch); + void BumpNextRegistrationIdIfNeeded(int64_t used_id, + leveldb::WriteBatch* batch); + void BumpNextResourceIdIfNeeded(int64_t used_id, leveldb::WriteBatch* batch); + void BumpNextVersionIdIfNeeded(int64_t used_id, leveldb::WriteBatch* batch); bool IsOpen(); @@ -351,9 +334,9 @@ class CONTENT_EXPORT ServiceWorkerDatabase { scoped_ptr<leveldb::Env> env_; scoped_ptr<leveldb::DB> db_; - int64 next_avail_registration_id_; - int64 next_avail_resource_id_; - int64 next_avail_version_id_; + int64_t next_avail_registration_id_; + int64_t next_avail_resource_id_; + int64_t next_avail_version_id_; enum State { UNINITIALIZED, diff --git a/content/browser/service_worker/service_worker_database_task_manager.h b/content/browser/service_worker/service_worker_database_task_manager.h index a54b252a..dbe9aa2 100644 --- a/content/browser/service_worker/service_worker_database_task_manager.h +++ b/content/browser/service_worker/service_worker_database_task_manager.h @@ -5,6 +5,7 @@ #ifndef CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_DATABASE_TASK_MANAGER_H_ #define CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_DATABASE_TASK_MANAGER_H_ +#include "base/macros.h" #include "base/memory/ref_counted.h" #include "content/common/content_export.h" diff --git a/content/browser/service_worker/service_worker_database_unittest.cc b/content/browser/service_worker/service_worker_database_unittest.cc index 33a5f09..1552120 100644 --- a/content/browser/service_worker/service_worker_database_unittest.cc +++ b/content/browser/service_worker/service_worker_database_unittest.cc @@ -4,10 +4,14 @@ #include "content/browser/service_worker/service_worker_database.h" +#include <stddef.h> +#include <stdint.h> + #include <string> #include "base/files/file_util.h" #include "base/files/scoped_temp_dir.h" +#include "base/macros.h" #include "base/stl_util.h" #include "base/strings/string_number_conversions.h" #include "content/browser/service_worker/service_worker_database.pb.h" @@ -23,9 +27,9 @@ typedef ServiceWorkerDatabase::RegistrationData RegistrationData; typedef ServiceWorkerDatabase::ResourceRecord Resource; struct AvailableIds { - int64 reg_id; - int64 res_id; - int64 ver_id; + int64_t reg_id; + int64_t res_id; + int64_t ver_id; AvailableIds() : reg_id(-1), res_id(-1), ver_id(-1) {} ~AvailableIds() {} @@ -39,7 +43,9 @@ GURL URL(const GURL& origin, const std::string& path) { return out; } -Resource CreateResource(int64 resource_id, const GURL& url, uint64 size_bytes) { +Resource CreateResource(int64_t resource_id, + const GURL& url, + uint64_t size_bytes) { EXPECT_TRUE(url.is_valid()); return Resource(resource_id, url, size_bytes); } @@ -116,7 +122,7 @@ TEST(ServiceWorkerDatabaseTest, DatabaseVersion) { // Opening a new database does not write anything, so its schema version // should be 0. - int64 db_version = -1; + int64_t db_version = -1; EXPECT_EQ(ServiceWorkerDatabase::STATUS_OK, database->ReadDatabaseVersion(&db_version)); EXPECT_EQ(0u, db_version); @@ -126,7 +132,7 @@ TEST(ServiceWorkerDatabaseTest, DatabaseVersion) { std::vector<ServiceWorkerDatabase::ResourceRecord> resources; resources.push_back(CreateResource(1, URL(origin, "/resource"), 10)); ServiceWorkerDatabase::RegistrationData deleted_version; - std::vector<int64> newly_purgeable_resources; + std::vector<int64_t> newly_purgeable_resources; ServiceWorkerDatabase::RegistrationData data; data.resources_total_size_bytes = 10; ASSERT_EQ(ServiceWorkerDatabase::STATUS_OK, @@ -149,7 +155,7 @@ TEST(ServiceWorkerDatabaseTest, UpgradeSchemaToVersion2) { // Add a registration to the database. std::vector<ServiceWorkerDatabase::ResourceRecord> resources; ServiceWorkerDatabase::RegistrationData deleted_version; - std::vector<int64> newly_purgeable_resources; + std::vector<int64_t> newly_purgeable_resources; ServiceWorkerDatabase::RegistrationData data; data.registration_id = 100; data.scope = URL(origin, "/foo"); @@ -162,7 +168,7 @@ TEST(ServiceWorkerDatabaseTest, UpgradeSchemaToVersion2) { &newly_purgeable_resources)); // Sanity check on current version. - int64 db_version = -1; + int64_t db_version = -1; EXPECT_EQ(ServiceWorkerDatabase::STATUS_OK, database->ReadDatabaseVersion(&db_version)); EXPECT_LE(2, db_version); @@ -223,7 +229,7 @@ TEST(ServiceWorkerDatabaseTest, GetNextAvailableIds) { std::vector<Resource> resources1; RegistrationData data1; ServiceWorkerDatabase::RegistrationData deleted_version; - std::vector<int64> newly_purgeable_resources; + std::vector<int64_t> newly_purgeable_resources; data1.registration_id = 100; data1.scope = URL(origin, "/foo"); data1.script = URL(origin, "/script1.js"); @@ -241,10 +247,10 @@ TEST(ServiceWorkerDatabaseTest, GetNextAvailableIds) { EXPECT_EQ(0, ids.res_id); // Writing uncommitted resources bumps the next available id. - const int64 kUncommittedIds[] = {0, 1, 3, 5, 6, 10}; + const int64_t kUncommittedIds[] = {0, 1, 3, 5, 6, 10}; EXPECT_EQ( ServiceWorkerDatabase::STATUS_OK, - database->WriteUncommittedResourceIds(std::set<int64>( + database->WriteUncommittedResourceIds(std::set<int64_t>( kUncommittedIds, kUncommittedIds + arraysize(kUncommittedIds)))); EXPECT_EQ( ServiceWorkerDatabase::STATUS_OK, @@ -254,9 +260,9 @@ TEST(ServiceWorkerDatabaseTest, GetNextAvailableIds) { EXPECT_EQ(11, ids.res_id); // Writing purgeable resources bumps the next available id. - const int64 kPurgeableIds[] = {4, 12, 16, 17, 20}; + const int64_t kPurgeableIds[] = {4, 12, 16, 17, 20}; EXPECT_EQ(ServiceWorkerDatabase::STATUS_OK, - database->WriteUncommittedResourceIds(std::set<int64>( + database->WriteUncommittedResourceIds(std::set<int64_t>( kPurgeableIds, kPurgeableIds + arraysize(kPurgeableIds)))); EXPECT_EQ( ServiceWorkerDatabase::STATUS_OK, @@ -280,10 +286,10 @@ TEST(ServiceWorkerDatabaseTest, GetNextAvailableIds) { &newly_purgeable_resources)); // Same with resources. - int64 kLowResourceId = 15; + int64_t kLowResourceId = 15; EXPECT_EQ(ServiceWorkerDatabase::STATUS_OK, database->WriteUncommittedResourceIds( - std::set<int64>(&kLowResourceId, &kLowResourceId + 1))); + std::set<int64_t>(&kLowResourceId, &kLowResourceId + 1))); // Close and reopen the database to verify the stored values. database.reset(CreateDatabase(database_dir.path())); @@ -304,7 +310,7 @@ TEST(ServiceWorkerDatabaseTest, GetOriginsWithRegistrations) { EXPECT_TRUE(origins.empty()); ServiceWorkerDatabase::RegistrationData deleted_version; - std::vector<int64> newly_purgeable_resources; + std::vector<int64_t> newly_purgeable_resources; GURL origin1("http://example.com"); RegistrationData data1; @@ -415,7 +421,7 @@ TEST(ServiceWorkerDatabaseTest, GetRegistrationsForOrigin) { EXPECT_TRUE(resources_list.empty()); ServiceWorkerDatabase::RegistrationData deleted_version; - std::vector<int64> newly_purgeable_resources; + std::vector<int64_t> newly_purgeable_resources; RegistrationData data1; data1.registration_id = 100; @@ -517,7 +523,7 @@ TEST(ServiceWorkerDatabaseTest, GetAllRegistrations) { EXPECT_TRUE(registrations.empty()); ServiceWorkerDatabase::RegistrationData deleted_version; - std::vector<int64> newly_purgeable_resources; + std::vector<int64_t> newly_purgeable_resources; GURL origin1("http://www1.example.com"); RegistrationData data1; @@ -600,18 +606,18 @@ TEST(ServiceWorkerDatabaseTest, Registration_Basic) { // Write a resource to the uncommitted list to make sure that writing // registration removes resource ids associated with the registration from // the uncommitted list. - std::set<int64> uncommitted_ids; + std::set<int64_t> uncommitted_ids; uncommitted_ids.insert(resources[0].resource_id); EXPECT_EQ(ServiceWorkerDatabase::STATUS_OK, database->WriteUncommittedResourceIds(uncommitted_ids)); - std::set<int64> uncommitted_ids_out; + std::set<int64_t> uncommitted_ids_out; EXPECT_EQ(ServiceWorkerDatabase::STATUS_OK, database->GetUncommittedResourceIds(&uncommitted_ids_out)); EXPECT_EQ(uncommitted_ids, uncommitted_ids_out); ServiceWorkerDatabase::RegistrationData deleted_version; deleted_version.version_id = 222; // Dummy initial value - std::vector<int64> newly_purgeable_resources; + std::vector<int64_t> newly_purgeable_resources; EXPECT_EQ(ServiceWorkerDatabase::STATUS_OK, database->WriteRegistration( @@ -660,7 +666,7 @@ TEST(ServiceWorkerDatabaseTest, Registration_Basic) { database->ReadRegistrationOrigin(data.registration_id, &origin_out)); // Resources should be purgeable because these are no longer referred. - std::set<int64> purgeable_ids_out; + std::set<int64_t> purgeable_ids_out; EXPECT_EQ(ServiceWorkerDatabase::STATUS_OK, database->GetPurgeableResourceIds(&purgeable_ids_out)); EXPECT_EQ(2u, purgeable_ids_out.size()); @@ -683,12 +689,12 @@ TEST(ServiceWorkerDatabaseTest, DeleteNonExistentRegistration) { resources.push_back(CreateResource(1, URL(origin, "/resource1"), 19)); resources.push_back(CreateResource(2, URL(origin, "/resource2"), 29129)); - const int64 kNonExistentRegistrationId = 999; - const int64 kArbitraryVersionId = 222; // Used as a dummy initial value + const int64_t kNonExistentRegistrationId = 999; + const int64_t kArbitraryVersionId = 222; // Used as a dummy initial value ServiceWorkerDatabase::RegistrationData deleted_version; deleted_version.version_id = kArbitraryVersionId; - std::vector<int64> newly_purgeable_resources; + std::vector<int64_t> newly_purgeable_resources; EXPECT_EQ(ServiceWorkerDatabase::STATUS_OK, database->WriteRegistration( data, resources, &deleted_version, &newly_purgeable_resources)); @@ -736,7 +742,7 @@ TEST(ServiceWorkerDatabaseTest, Registration_Overwrite) { ServiceWorkerDatabase::RegistrationData deleted_version; deleted_version.version_id = 222; // Dummy inital value - std::vector<int64> newly_purgeable_resources; + std::vector<int64_t> newly_purgeable_resources; EXPECT_EQ( ServiceWorkerDatabase::STATUS_OK, @@ -780,7 +786,7 @@ TEST(ServiceWorkerDatabaseTest, Registration_Overwrite) { VerifyRegistrationData(updated_data, data_out); VerifyResourceRecords(resources2, resources_out); - std::set<int64> purgeable_ids_out; + std::set<int64_t> purgeable_ids_out; EXPECT_EQ(ServiceWorkerDatabase::STATUS_OK, database->GetPurgeableResourceIds(&purgeable_ids_out)); EXPECT_EQ(2u, purgeable_ids_out.size()); @@ -793,7 +799,7 @@ TEST(ServiceWorkerDatabaseTest, Registration_Multiple) { GURL origin("http://example.com"); ServiceWorkerDatabase::RegistrationData deleted_version; - std::vector<int64> newly_purgeable_resources; + std::vector<int64_t> newly_purgeable_resources; // Add registration1. RegistrationData data1; @@ -851,7 +857,7 @@ TEST(ServiceWorkerDatabaseTest, Registration_Multiple) { database->ReadRegistrationOrigin(data2.registration_id, &origin_out)); EXPECT_EQ(origin, origin_out); - std::set<int64> purgeable_ids_out; + std::set<int64_t> purgeable_ids_out; EXPECT_EQ(ServiceWorkerDatabase::STATUS_OK, database->GetPurgeableResourceIds(&purgeable_ids_out)); EXPECT_TRUE(purgeable_ids_out.empty()); @@ -911,7 +917,7 @@ TEST(ServiceWorkerDatabaseTest, Registration_UninitializedDatabase) { // Deleting non-existent registration should succeed. RegistrationData deleted_version; - std::vector<int64> newly_purgeable_resources; + std::vector<int64_t> newly_purgeable_resources; EXPECT_EQ(ServiceWorkerDatabase::STATUS_OK, database->DeleteRegistration( 100, origin, &deleted_version, &newly_purgeable_resources)); @@ -953,7 +959,7 @@ TEST(ServiceWorkerDatabaseTest, UserData_Basic) { std::vector<Resource> resources; resources.push_back(CreateResource(1, data.script, 100)); ServiceWorkerDatabase::RegistrationData deleted_version; - std::vector<int64> newly_purgeable_resources; + std::vector<int64_t> newly_purgeable_resources; ASSERT_EQ(ServiceWorkerDatabase::STATUS_OK, database->WriteRegistration( data, resources, &deleted_version, &newly_purgeable_resources)); @@ -1032,7 +1038,7 @@ TEST(ServiceWorkerDatabaseTest, UserData_DataIsolation) { resources2.push_back(CreateResource(2, data2.script, 200)); ServiceWorkerDatabase::RegistrationData deleted_version; - std::vector<int64> newly_purgeable_resources; + std::vector<int64_t> newly_purgeable_resources; ASSERT_EQ(ServiceWorkerDatabase::STATUS_OK, database->WriteRegistration(data1, resources1, &deleted_version, &newly_purgeable_resources)); @@ -1068,7 +1074,7 @@ TEST(ServiceWorkerDatabaseTest, UserData_DataIsolation) { EXPECT_EQ("data2", user_data_out); // Get all registrations with user data. - std::vector<std::pair<int64, std::string>> user_data_list; + std::vector<std::pair<int64_t, std::string>> user_data_list; ASSERT_EQ(ServiceWorkerDatabase::STATUS_OK, database->ReadUserDataForAllRegistrations("key", &user_data_list)); EXPECT_EQ(2u, user_data_list.size()); @@ -1123,7 +1129,7 @@ TEST(ServiceWorkerDatabaseTest, UserData_DeleteRegistration) { resources2.push_back(CreateResource(2, data2.script, 200)); ServiceWorkerDatabase::RegistrationData deleted_version; - std::vector<int64> newly_purgeable_resources; + std::vector<int64_t> newly_purgeable_resources; ASSERT_EQ(ServiceWorkerDatabase::STATUS_OK, database->WriteRegistration(data1, resources1, &deleted_version, &newly_purgeable_resources)); @@ -1212,7 +1218,7 @@ TEST(ServiceWorkerDatabaseTest, UpdateVersionToActive) { GURL origin("http://example.com"); ServiceWorkerDatabase::RegistrationData deleted_version; - std::vector<int64> newly_purgeable_resources; + std::vector<int64_t> newly_purgeable_resources; // Should be false because a registration does not exist. EXPECT_EQ(ServiceWorkerDatabase::STATUS_ERROR_NOT_FOUND, @@ -1272,7 +1278,7 @@ TEST(ServiceWorkerDatabaseTest, UpdateLastCheckTime) { scoped_ptr<ServiceWorkerDatabase> database(CreateDatabaseInMemory()); GURL origin("http://example.com"); ServiceWorkerDatabase::RegistrationData deleted_version; - std::vector<int64> newly_purgeable_resources; + std::vector<int64_t> newly_purgeable_resources; // Should be false because a registration does not exist. EXPECT_EQ(ServiceWorkerDatabase::STATUS_ERROR_NOT_FOUND, @@ -1335,20 +1341,20 @@ TEST(ServiceWorkerDatabaseTest, UncommittedAndPurgeableResourceIds) { scoped_ptr<ServiceWorkerDatabase> database(CreateDatabaseInMemory()); // Write {1, 2, 3} into the uncommitted list. - std::set<int64> ids1; + std::set<int64_t> ids1; ids1.insert(1); ids1.insert(2); ids1.insert(3); EXPECT_EQ(ServiceWorkerDatabase::STATUS_OK, database->WriteUncommittedResourceIds(ids1)); - std::set<int64> ids_out; + std::set<int64_t> ids_out; EXPECT_EQ(ServiceWorkerDatabase::STATUS_OK, database->GetUncommittedResourceIds(&ids_out)); EXPECT_EQ(ids1, ids_out); // Write {2, 4} into the uncommitted list. - std::set<int64> ids2; + std::set<int64_t> ids2; ids2.insert(2); ids2.insert(4); EXPECT_EQ(ServiceWorkerDatabase::STATUS_OK, @@ -1357,7 +1363,7 @@ TEST(ServiceWorkerDatabaseTest, UncommittedAndPurgeableResourceIds) { ids_out.clear(); EXPECT_EQ(ServiceWorkerDatabase::STATUS_OK, database->GetUncommittedResourceIds(&ids_out)); - std::set<int64> expected = base::STLSetUnion<std::set<int64>>(ids1, ids2); + std::set<int64_t> expected = base::STLSetUnion<std::set<int64_t>>(ids1, ids2); EXPECT_EQ(expected, ids_out); // Move {2, 4} from the uncommitted list to the purgeable list. @@ -1380,14 +1386,14 @@ TEST(ServiceWorkerDatabaseTest, UncommittedAndPurgeableResourceIds) { ids_out.clear(); EXPECT_EQ(ServiceWorkerDatabase::STATUS_OK, database->GetUncommittedResourceIds(&ids_out)); - expected = base::STLSetDifference<std::set<int64>>(ids1, ids2); + expected = base::STLSetDifference<std::set<int64_t>>(ids1, ids2); EXPECT_EQ(expected, ids_out); } TEST(ServiceWorkerDatabaseTest, DeleteAllDataForOrigin) { scoped_ptr<ServiceWorkerDatabase> database(CreateDatabaseInMemory()); ServiceWorkerDatabase::RegistrationData deleted_version; - std::vector<int64> newly_purgeable_resources; + std::vector<int64_t> newly_purgeable_resources; // Data associated with |origin1| will be removed. GURL origin1("http://example.com"); @@ -1510,7 +1516,7 @@ TEST(ServiceWorkerDatabaseTest, DeleteAllDataForOrigin) { EXPECT_EQ(origin2, origin_out); // The resources associated with |origin1| should be purgeable. - std::set<int64> purgeable_ids_out; + std::set<int64_t> purgeable_ids_out; EXPECT_EQ(ServiceWorkerDatabase::STATUS_OK, database->GetPurgeableResourceIds(&purgeable_ids_out)); EXPECT_EQ(4u, purgeable_ids_out.size()); @@ -1567,7 +1573,7 @@ TEST(ServiceWorkerDatabaseTest, GetOriginsWithForeignFetchRegistrations) { EXPECT_TRUE(origins.empty()); ServiceWorkerDatabase::RegistrationData deleted_version; - std::vector<int64> newly_purgeable_resources; + std::vector<int64_t> newly_purgeable_resources; GURL origin1("http://example.com"); RegistrationData data1; diff --git a/content/browser/service_worker/service_worker_disk_cache.cc b/content/browser/service_worker/service_worker_disk_cache.cc index 98f6845..ef8f168 100644 --- a/content/browser/service_worker/service_worker_disk_cache.cc +++ b/content/browser/service_worker/service_worker_disk_cache.cc @@ -10,17 +10,17 @@ ServiceWorkerDiskCache::ServiceWorkerDiskCache() : AppCacheDiskCache(true /* use_simple_cache */) {} ServiceWorkerResponseReader::ServiceWorkerResponseReader( - int64 resource_id, + int64_t resource_id, ServiceWorkerDiskCache* disk_cache) : AppCacheResponseReader(resource_id, 0, disk_cache) {} ServiceWorkerResponseWriter::ServiceWorkerResponseWriter( - int64 resource_id, + int64_t resource_id, ServiceWorkerDiskCache* disk_cache) : AppCacheResponseWriter(resource_id, 0, disk_cache) {} ServiceWorkerResponseMetadataWriter::ServiceWorkerResponseMetadataWriter( - int64 resource_id, + int64_t resource_id, ServiceWorkerDiskCache* disk_cache) : AppCacheResponseMetadataWriter(resource_id, 0, disk_cache) {} diff --git a/content/browser/service_worker/service_worker_disk_cache.h b/content/browser/service_worker/service_worker_disk_cache.h index 603614f..90f29bc 100644 --- a/content/browser/service_worker/service_worker_disk_cache.h +++ b/content/browser/service_worker/service_worker_disk_cache.h @@ -5,6 +5,8 @@ #ifndef CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_DISK_CACHE_H_ #define CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_DISK_CACHE_H_ +#include <stdint.h> + #include "content/browser/appcache/appcache_disk_cache.h" #include "content/common/content_export.h" @@ -27,7 +29,7 @@ class CONTENT_EXPORT ServiceWorkerResponseReader protected: // Should only be constructed by the storage class. friend class ServiceWorkerStorage; - ServiceWorkerResponseReader(int64 resource_id, + ServiceWorkerResponseReader(int64_t resource_id, ServiceWorkerDiskCache* disk_cache); }; @@ -36,7 +38,7 @@ class CONTENT_EXPORT ServiceWorkerResponseWriter protected: // Should only be constructed by the storage class. friend class ServiceWorkerStorage; - ServiceWorkerResponseWriter(int64 resource_id, + ServiceWorkerResponseWriter(int64_t resource_id, ServiceWorkerDiskCache* disk_cache); }; @@ -45,7 +47,7 @@ class CONTENT_EXPORT ServiceWorkerResponseMetadataWriter protected: // Should only be constructed by the storage class. friend class ServiceWorkerStorage; - ServiceWorkerResponseMetadataWriter(int64 resource_id, + ServiceWorkerResponseMetadataWriter(int64_t resource_id, ServiceWorkerDiskCache* disk_cache); }; diff --git a/content/browser/service_worker/service_worker_dispatcher_host.cc b/content/browser/service_worker/service_worker_dispatcher_host.cc index 2b36dcf..1e264d8 100644 --- a/content/browser/service_worker/service_worker_dispatcher_host.cc +++ b/content/browser/service_worker/service_worker_dispatcher_host.cc @@ -5,6 +5,7 @@ #include "content/browser/service_worker/service_worker_dispatcher_host.h" #include "base/logging.h" +#include "base/macros.h" #include "base/profiler/scoped_tracker.h" #include "base/strings/utf_string_conversions.h" #include "base/trace_event/trace_event.h" @@ -45,9 +46,8 @@ const char kUserDeniedPermissionMessage[] = "The user denied permission to use Service Worker."; const char kInvalidStateErrorMessage[] = "The object is in an invalid state."; -const uint32 kFilteredMessageClasses[] = { - ServiceWorkerMsgStart, - EmbeddedWorkerMsgStart, +const uint32_t kFilteredMessageClasses[] = { + ServiceWorkerMsgStart, EmbeddedWorkerMsgStart, }; bool AllOriginsMatch(const GURL& url_a, const GURL& url_b, const GURL& url_c) { @@ -248,7 +248,7 @@ void ServiceWorkerDispatcherHost::RegisterServiceWorkerRegistrationHandle( ServiceWorkerHandle* ServiceWorkerDispatcherHost::FindServiceWorkerHandle( int provider_id, - int64 version_id) { + int64_t version_id) { for (IDMap<ServiceWorkerHandle, IDMapOwnPointer>::iterator iter(&handles_); !iter.IsAtEnd(); iter.Advance()) { ServiceWorkerHandle* handle = iter.GetCurrentValue(); @@ -366,10 +366,11 @@ void ServiceWorkerDispatcherHost::OnRegisterServiceWorker( request_id)); } -void ServiceWorkerDispatcherHost::OnUpdateServiceWorker(int thread_id, - int request_id, - int provider_id, - int64 registration_id) { +void ServiceWorkerDispatcherHost::OnUpdateServiceWorker( + int thread_id, + int request_id, + int provider_id, + int64_t registration_id) { TRACE_EVENT0("ServiceWorker", "ServiceWorkerDispatcherHost::OnUpdateServiceWorker"); if (!GetContext()) { @@ -450,7 +451,7 @@ void ServiceWorkerDispatcherHost::OnUnregisterServiceWorker( int thread_id, int request_id, int provider_id, - int64 registration_id) { + int64_t registration_id) { TRACE_EVENT0("ServiceWorker", "ServiceWorkerDispatcherHost::OnUnregisterServiceWorker"); if (!GetContext()) { @@ -780,8 +781,8 @@ void ServiceWorkerDispatcherHost::OnProviderDestroyed(int provider_id) { GetContext()->RemoveProviderHost(render_process_id_, provider_id); } -void ServiceWorkerDispatcherHost::OnSetHostedVersionId( - int provider_id, int64 version_id) { +void ServiceWorkerDispatcherHost::OnSetHostedVersionId(int provider_id, + int64_t version_id) { TRACE_EVENT0("ServiceWorker", "ServiceWorkerDispatcherHost::OnSetHostedVersionId"); if (!GetContext()) @@ -824,7 +825,7 @@ void ServiceWorkerDispatcherHost::OnSetHostedVersionId( ServiceWorkerRegistrationHandle* ServiceWorkerDispatcherHost::FindRegistrationHandle(int provider_id, - int64 registration_id) { + int64_t registration_id) { for (RegistrationHandleMap::iterator iter(®istration_handles_); !iter.IsAtEnd(); iter.Advance()) { ServiceWorkerRegistrationHandle* handle = iter.GetCurrentValue(); @@ -859,7 +860,7 @@ void ServiceWorkerDispatcherHost::RegistrationComplete( int request_id, ServiceWorkerStatusCode status, const std::string& status_message, - int64 registration_id) { + int64_t registration_id) { if (!GetContext()) return; @@ -897,7 +898,7 @@ void ServiceWorkerDispatcherHost::UpdateComplete( int request_id, ServiceWorkerStatusCode status, const std::string& status_message, - int64 registration_id) { + int64_t registration_id) { if (!GetContext()) return; diff --git a/content/browser/service_worker/service_worker_dispatcher_host.h b/content/browser/service_worker/service_worker_dispatcher_host.h index d907f9d..89ff789 100644 --- a/content/browser/service_worker/service_worker_dispatcher_host.h +++ b/content/browser/service_worker/service_worker_dispatcher_host.h @@ -5,9 +5,12 @@ #ifndef CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_DISPATCHER_HOST_H_ #define CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_DISPATCHER_HOST_H_ +#include <stdint.h> + #include <vector> #include "base/id_map.h" +#include "base/macros.h" #include "base/memory/scoped_ptr.h" #include "base/memory/weak_ptr.h" #include "base/strings/string16.h" @@ -63,7 +66,7 @@ class CONTENT_EXPORT ServiceWorkerDispatcherHost : public BrowserMessageFilter { scoped_ptr<ServiceWorkerRegistrationHandle> handle); ServiceWorkerHandle* FindServiceWorkerHandle(int provider_id, - int64 version_id); + int64_t version_id); // Returns the existing registration handle whose reference count is // incremented or a newly created one if it doesn't exist. @@ -92,11 +95,11 @@ class CONTENT_EXPORT ServiceWorkerDispatcherHost : public BrowserMessageFilter { void OnUpdateServiceWorker(int thread_id, int request_id, int provider_id, - int64 registration_id); + int64_t registration_id); void OnUnregisterServiceWorker(int thread_id, int request_id, int provider_id, - int64 registration_id); + int64_t registration_id); void OnGetRegistration(int thread_id, int request_id, int provider_id, @@ -109,7 +112,7 @@ class CONTENT_EXPORT ServiceWorkerDispatcherHost : public BrowserMessageFilter { int route_id, ServiceWorkerProviderType provider_type); void OnProviderDestroyed(int provider_id); - void OnSetHostedVersionId(int provider_id, int64 version_id); + void OnSetHostedVersionId(int provider_id, int64_t version_id); void OnWorkerReadyForInspection(int embedded_worker_id); void OnWorkerScriptLoaded(int embedded_worker_id); void OnWorkerThreadStarted(int embedded_worker_id, @@ -139,7 +142,7 @@ class CONTENT_EXPORT ServiceWorkerDispatcherHost : public BrowserMessageFilter { ServiceWorkerRegistrationHandle* FindRegistrationHandle( int provider_id, - int64 registration_handle_id); + int64_t registration_handle_id); void GetRegistrationObjectInfoAndVersionAttributes( base::WeakPtr<ServiceWorkerProviderHost> provider_host, @@ -153,14 +156,14 @@ class CONTENT_EXPORT ServiceWorkerDispatcherHost : public BrowserMessageFilter { int request_id, ServiceWorkerStatusCode status, const std::string& status_message, - int64 registration_id); + int64_t registration_id); void UpdateComplete(int thread_id, int provider_id, int request_id, ServiceWorkerStatusCode status, const std::string& status_message, - int64 registration_id); + int64_t registration_id); void UnregistrationComplete(int thread_id, int request_id, diff --git a/content/browser/service_worker/service_worker_dispatcher_host_unittest.cc b/content/browser/service_worker/service_worker_dispatcher_host_unittest.cc index fde3c47..2d9d36e 100644 --- a/content/browser/service_worker/service_worker_dispatcher_host_unittest.cc +++ b/content/browser/service_worker/service_worker_dispatcher_host_unittest.cc @@ -4,6 +4,8 @@ #include "content/browser/service_worker/service_worker_dispatcher_host.h" +#include <stdint.h> + #include "base/command_line.h" #include "base/files/file_path.h" #include "base/run_loop.h" @@ -81,62 +83,62 @@ class ServiceWorkerDispatcherHostTest : public testing::Test { return helper_->context_wrapper(); } - void SendRegister(int64 provider_id, GURL pattern, GURL worker_url) { + void SendRegister(int64_t provider_id, GURL pattern, GURL worker_url) { dispatcher_host_->OnMessageReceived( ServiceWorkerHostMsg_RegisterServiceWorker( -1, -1, provider_id, pattern, worker_url)); base::RunLoop().RunUntilIdle(); } - void Register(int64 provider_id, + void Register(int64_t provider_id, GURL pattern, GURL worker_url, - uint32 expected_message) { + uint32_t expected_message) { SendRegister(provider_id, pattern, worker_url); EXPECT_TRUE(dispatcher_host_->ipc_sink()->GetUniqueMessageMatching( expected_message)); dispatcher_host_->ipc_sink()->ClearMessages(); } - void SendUnregister(int64 provider_id, int64 registration_id) { + void SendUnregister(int64_t provider_id, int64_t registration_id) { dispatcher_host_->OnMessageReceived( ServiceWorkerHostMsg_UnregisterServiceWorker(-1, -1, provider_id, registration_id)); base::RunLoop().RunUntilIdle(); } - void Unregister(int64 provider_id, - int64 registration_id, - uint32 expected_message) { + void Unregister(int64_t provider_id, + int64_t registration_id, + uint32_t expected_message) { SendUnregister(provider_id, registration_id); EXPECT_TRUE(dispatcher_host_->ipc_sink()->GetUniqueMessageMatching( expected_message)); dispatcher_host_->ipc_sink()->ClearMessages(); } - void SendGetRegistration(int64 provider_id, GURL document_url) { + void SendGetRegistration(int64_t provider_id, GURL document_url) { dispatcher_host_->OnMessageReceived( ServiceWorkerHostMsg_GetRegistration( -1, -1, provider_id, document_url)); base::RunLoop().RunUntilIdle(); } - void GetRegistration(int64 provider_id, + void GetRegistration(int64_t provider_id, GURL document_url, - uint32 expected_message) { + uint32_t expected_message) { SendGetRegistration(provider_id, document_url); EXPECT_TRUE(dispatcher_host_->ipc_sink()->GetUniqueMessageMatching( expected_message)); dispatcher_host_->ipc_sink()->ClearMessages(); } - void SendGetRegistrations(int64 provider_id) { + void SendGetRegistrations(int64_t provider_id) { dispatcher_host_->OnMessageReceived( ServiceWorkerHostMsg_GetRegistrations(-1, -1, provider_id)); base::RunLoop().RunUntilIdle(); } - void GetRegistrations(int64 provider_id, uint32 expected_message) { + void GetRegistrations(int64_t provider_id, uint32_t expected_message) { SendGetRegistrations(provider_id); EXPECT_TRUE(dispatcher_host_->ipc_sink()->GetUniqueMessageMatching( expected_message)); @@ -175,7 +177,7 @@ TEST_F(ServiceWorkerDispatcherHostTest, ContentBrowserClient* old_browser_client = SetBrowserClientForTesting(&test_browser_client); - const int64 kProviderId = 99; // Dummy value + const int64_t kProviderId = 99; // Dummy value scoped_ptr<ServiceWorkerProviderHost> host( CreateServiceWorkerProviderHost(kProviderId)); host->SetDocumentUrl(GURL("https://www.example.com/foo")); @@ -193,7 +195,7 @@ TEST_F(ServiceWorkerDispatcherHostTest, // Add a registration into a live registration map so that Unregister() can // find it. - const int64 kRegistrationId = 999; // Dummy value + const int64_t kRegistrationId = 999; // Dummy value scoped_refptr<ServiceWorkerRegistration> registration( new ServiceWorkerRegistration(GURL("https://www.example.com/"), kRegistrationId, context()->AsWeakPtr())); @@ -204,7 +206,7 @@ TEST_F(ServiceWorkerDispatcherHostTest, } TEST_F(ServiceWorkerDispatcherHostTest, Register_HTTPS) { - const int64 kProviderId = 99; // Dummy value + const int64_t kProviderId = 99; // Dummy value scoped_ptr<ServiceWorkerProviderHost> host( CreateServiceWorkerProviderHost(kProviderId)); host->SetDocumentUrl(GURL("https://www.example.com/foo")); @@ -217,7 +219,7 @@ TEST_F(ServiceWorkerDispatcherHostTest, Register_HTTPS) { } TEST_F(ServiceWorkerDispatcherHostTest, Register_NonSecureTransportLocalhost) { - const int64 kProviderId = 99; // Dummy value + const int64_t kProviderId = 99; // Dummy value scoped_ptr<ServiceWorkerProviderHost> host( CreateServiceWorkerProviderHost(kProviderId)); host->SetDocumentUrl(GURL("http://127.0.0.3:81/foo")); @@ -230,7 +232,7 @@ TEST_F(ServiceWorkerDispatcherHostTest, Register_NonSecureTransportLocalhost) { } TEST_F(ServiceWorkerDispatcherHostTest, Register_InvalidScopeShouldFail) { - const int64 kProviderId = 99; // Dummy value + const int64_t kProviderId = 99; // Dummy value scoped_ptr<ServiceWorkerProviderHost> host( CreateServiceWorkerProviderHost(kProviderId)); host->SetDocumentUrl(GURL("https://www.example.com/foo")); @@ -242,7 +244,7 @@ TEST_F(ServiceWorkerDispatcherHostTest, Register_InvalidScopeShouldFail) { } TEST_F(ServiceWorkerDispatcherHostTest, Register_InvalidScriptShouldFail) { - const int64 kProviderId = 99; // Dummy value + const int64_t kProviderId = 99; // Dummy value scoped_ptr<ServiceWorkerProviderHost> host( CreateServiceWorkerProviderHost(kProviderId)); host->SetDocumentUrl(GURL("https://www.example.com/foo")); @@ -253,7 +255,7 @@ TEST_F(ServiceWorkerDispatcherHostTest, Register_InvalidScriptShouldFail) { } TEST_F(ServiceWorkerDispatcherHostTest, Register_NonSecureOriginShouldFail) { - const int64 kProviderId = 99; // Dummy value + const int64_t kProviderId = 99; // Dummy value scoped_ptr<ServiceWorkerProviderHost> host( CreateServiceWorkerProviderHost(kProviderId)); host->SetDocumentUrl(GURL("http://www.example.com/foo")); @@ -266,7 +268,7 @@ TEST_F(ServiceWorkerDispatcherHostTest, Register_NonSecureOriginShouldFail) { } TEST_F(ServiceWorkerDispatcherHostTest, Register_CrossOriginShouldFail) { - const int64 kProviderId = 99; // Dummy value + const int64_t kProviderId = 99; // Dummy value scoped_ptr<ServiceWorkerProviderHost> host( CreateServiceWorkerProviderHost(kProviderId)); host->SetDocumentUrl(GURL("https://www.example.com/foo")); @@ -310,7 +312,7 @@ TEST_F(ServiceWorkerDispatcherHostTest, Register_CrossOriginShouldFail) { } TEST_F(ServiceWorkerDispatcherHostTest, Register_BadCharactersShouldFail) { - const int64 kProviderId = 99; // Dummy value + const int64_t kProviderId = 99; // Dummy value scoped_ptr<ServiceWorkerProviderHost> host( CreateServiceWorkerProviderHost(kProviderId)); host->SetDocumentUrl(GURL("https://www.example.com/")); @@ -343,7 +345,7 @@ TEST_F(ServiceWorkerDispatcherHostTest, Register_BadCharactersShouldFail) { TEST_F(ServiceWorkerDispatcherHostTest, Register_FileSystemDocumentShouldFail) { - const int64 kProviderId = 99; // Dummy value + const int64_t kProviderId = 99; // Dummy value scoped_ptr<ServiceWorkerProviderHost> host( CreateServiceWorkerProviderHost(kProviderId)); host->SetDocumentUrl(GURL("filesystem:https://www.example.com/temporary/a")); @@ -367,7 +369,7 @@ TEST_F(ServiceWorkerDispatcherHostTest, TEST_F(ServiceWorkerDispatcherHostTest, Register_FileSystemScriptOrScopeShouldFail) { - const int64 kProviderId = 99; // Dummy value + const int64_t kProviderId = 99; // Dummy value scoped_ptr<ServiceWorkerProviderHost> host( CreateServiceWorkerProviderHost(kProviderId)); host->SetDocumentUrl(GURL("https://www.example.com/temporary/")); @@ -434,7 +436,7 @@ TEST_F(ServiceWorkerDispatcherHostTest, ProviderCreatedAndDestroyed) { } TEST_F(ServiceWorkerDispatcherHostTest, GetRegistration_SameOrigin) { - const int64 kProviderId = 99; // Dummy value + const int64_t kProviderId = 99; // Dummy value scoped_ptr<ServiceWorkerProviderHost> host( CreateServiceWorkerProviderHost(kProviderId)); host->SetDocumentUrl(GURL("https://www.example.com/foo")); @@ -446,7 +448,7 @@ TEST_F(ServiceWorkerDispatcherHostTest, GetRegistration_SameOrigin) { } TEST_F(ServiceWorkerDispatcherHostTest, GetRegistration_CrossOriginShouldFail) { - const int64 kProviderId = 99; // Dummy value + const int64_t kProviderId = 99; // Dummy value scoped_ptr<ServiceWorkerProviderHost> host( CreateServiceWorkerProviderHost(kProviderId)); host->SetDocumentUrl(GURL("https://www.example.com/foo")); @@ -458,7 +460,7 @@ TEST_F(ServiceWorkerDispatcherHostTest, GetRegistration_CrossOriginShouldFail) { TEST_F(ServiceWorkerDispatcherHostTest, GetRegistration_InvalidScopeShouldFail) { - const int64 kProviderId = 99; // Dummy value + const int64_t kProviderId = 99; // Dummy value scoped_ptr<ServiceWorkerProviderHost> host( CreateServiceWorkerProviderHost(kProviderId)); host->SetDocumentUrl(GURL("https://www.example.com/foo")); @@ -470,7 +472,7 @@ TEST_F(ServiceWorkerDispatcherHostTest, TEST_F(ServiceWorkerDispatcherHostTest, GetRegistration_NonSecureOriginShouldFail) { - const int64 kProviderId = 99; // Dummy value + const int64_t kProviderId = 99; // Dummy value scoped_ptr<ServiceWorkerProviderHost> host( CreateServiceWorkerProviderHost(kProviderId)); host->SetDocumentUrl(GURL("http://www.example.com/foo")); @@ -492,7 +494,7 @@ TEST_F(ServiceWorkerDispatcherHostTest, GetRegistration_EarlyContextDeletion) { } TEST_F(ServiceWorkerDispatcherHostTest, GetRegistrations_SecureOrigin) { - const int64 kProviderId = 99; // Dummy value + const int64_t kProviderId = 99; // Dummy value scoped_ptr<ServiceWorkerProviderHost> host( CreateServiceWorkerProviderHost(kProviderId)); host->SetDocumentUrl(GURL("https://www.example.com/foo")); @@ -503,7 +505,7 @@ TEST_F(ServiceWorkerDispatcherHostTest, GetRegistrations_SecureOrigin) { TEST_F(ServiceWorkerDispatcherHostTest, GetRegistrations_NonSecureOriginShouldFail) { - const int64 kProviderId = 99; // Dummy value + const int64_t kProviderId = 99; // Dummy value scoped_ptr<ServiceWorkerProviderHost> host( CreateServiceWorkerProviderHost(kProviderId)); host->SetDocumentUrl(GURL("http://www.example.com/foo")); @@ -526,7 +528,7 @@ TEST_F(ServiceWorkerDispatcherHostTest, CleanupOnRendererCrash) { int process_id = helper_->mock_render_process_id(); // Add a provider and worker. - const int64 kProviderId = 99; // Dummy value + const int64_t kProviderId = 99; // Dummy value dispatcher_host_->OnMessageReceived(ServiceWorkerHostMsg_ProviderCreated( kProviderId, MSG_ROUTING_NONE, SERVICE_WORKER_PROVIDER_FOR_WINDOW)); diff --git a/content/browser/service_worker/service_worker_fetch_dispatcher.h b/content/browser/service_worker/service_worker_fetch_dispatcher.h index f0165b6..518be84 100644 --- a/content/browser/service_worker/service_worker_fetch_dispatcher.h +++ b/content/browser/service_worker/service_worker_fetch_dispatcher.h @@ -5,8 +5,8 @@ #ifndef CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_FETCH_DISPATCHER_H_ #define CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_FETCH_DISPATCHER_H_ -#include "base/basictypes.h" #include "base/callback.h" +#include "base/macros.h" #include "base/memory/weak_ptr.h" #include "content/common/service_worker/service_worker_status_code.h" #include "content/common/service_worker/service_worker_types.h" diff --git a/content/browser/service_worker/service_worker_handle.h b/content/browser/service_worker/service_worker_handle.h index 8fe2bd9..a9c0e44 100644 --- a/content/browser/service_worker/service_worker_handle.h +++ b/content/browser/service_worker/service_worker_handle.h @@ -5,7 +5,7 @@ #ifndef CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_HANDLE_H_ #define CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_HANDLE_H_ -#include "base/basictypes.h" +#include "base/macros.h" #include "base/memory/ref_counted.h" #include "base/memory/scoped_ptr.h" #include "base/memory/weak_ptr.h" diff --git a/content/browser/service_worker/service_worker_handle_unittest.cc b/content/browser/service_worker/service_worker_handle_unittest.cc index 066dd39..25514ff 100644 --- a/content/browser/service_worker/service_worker_handle_unittest.cc +++ b/content/browser/service_worker/service_worker_handle_unittest.cc @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "base/basictypes.h" +#include "base/macros.h" #include "base/run_loop.h" #include "content/browser/service_worker/embedded_worker_registry.h" #include "content/browser/service_worker/embedded_worker_test_helper.h" diff --git a/content/browser/service_worker/service_worker_info.cc b/content/browser/service_worker/service_worker_info.cc index 90571016..7d40512 100644 --- a/content/browser/service_worker/service_worker_info.cc +++ b/content/browser/service_worker/service_worker_info.cc @@ -36,8 +36,8 @@ ServiceWorkerVersionInfo::ServiceWorkerVersionInfo( ServiceWorkerVersion::RunningStatus running_status, ServiceWorkerVersion::Status status, const GURL& script_url, - int64 registration_id, - int64 version_id, + int64_t registration_id, + int64_t version_id, int process_id, int thread_id, int devtools_agent_route_id) @@ -48,8 +48,7 @@ ServiceWorkerVersionInfo::ServiceWorkerVersionInfo( version_id(version_id), process_id(process_id), thread_id(thread_id), - devtools_agent_route_id(devtools_agent_route_id) { -} + devtools_agent_route_id(devtools_agent_route_id) {} ServiceWorkerVersionInfo::~ServiceWorkerVersionInfo() {} @@ -61,7 +60,7 @@ ServiceWorkerRegistrationInfo::ServiceWorkerRegistrationInfo() ServiceWorkerRegistrationInfo::ServiceWorkerRegistrationInfo( const GURL& pattern, - int64 registration_id, + int64_t registration_id, DeleteFlag delete_flag) : pattern(pattern), registration_id(registration_id), @@ -71,7 +70,7 @@ ServiceWorkerRegistrationInfo::ServiceWorkerRegistrationInfo( ServiceWorkerRegistrationInfo::ServiceWorkerRegistrationInfo( const GURL& pattern, - int64 registration_id, + int64_t registration_id, DeleteFlag delete_flag, ForceUpdateOnPageLoad force_update_on_page_load, const ServiceWorkerVersionInfo& active_version, diff --git a/content/browser/service_worker/service_worker_info.h b/content/browser/service_worker/service_worker_info.h index f7bd894..b1c0a73 100644 --- a/content/browser/service_worker/service_worker_info.h +++ b/content/browser/service_worker/service_worker_info.h @@ -5,6 +5,8 @@ #ifndef CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_INFO_H_ #define CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_INFO_H_ +#include <stdint.h> + #include <vector> #include "base/time/time.h" @@ -30,8 +32,8 @@ struct CONTENT_EXPORT ServiceWorkerVersionInfo { ServiceWorkerVersionInfo(ServiceWorkerVersion::RunningStatus running_status, ServiceWorkerVersion::Status status, const GURL& script_url, - int64 registration_id, - int64 version_id, + int64_t registration_id, + int64_t version_id, int process_id, int thread_id, int devtools_agent_route_id); @@ -40,8 +42,8 @@ struct CONTENT_EXPORT ServiceWorkerVersionInfo { ServiceWorkerVersion::RunningStatus running_status; ServiceWorkerVersion::Status status; GURL script_url; - int64 registration_id; - int64 version_id; + int64_t registration_id; + int64_t version_id; int process_id; int thread_id; int devtools_agent_route_id; @@ -56,11 +58,11 @@ struct CONTENT_EXPORT ServiceWorkerRegistrationInfo { enum ForceUpdateOnPageLoad { IS_NOT_FORCED, IS_FORCED }; ServiceWorkerRegistrationInfo(); ServiceWorkerRegistrationInfo(const GURL& pattern, - int64 registration_id, + int64_t registration_id, DeleteFlag delete_flag); ServiceWorkerRegistrationInfo( const GURL& pattern, - int64 registration_id, + int64_t registration_id, DeleteFlag delete_flag, ForceUpdateOnPageLoad force_update_on_page_load, const ServiceWorkerVersionInfo& active_version, @@ -70,7 +72,7 @@ struct CONTENT_EXPORT ServiceWorkerRegistrationInfo { ~ServiceWorkerRegistrationInfo(); GURL pattern; - int64 registration_id; + int64_t registration_id; DeleteFlag delete_flag; ForceUpdateOnPageLoad force_update_on_page_load; ServiceWorkerVersionInfo active_version; diff --git a/content/browser/service_worker/service_worker_internals_ui.cc b/content/browser/service_worker/service_worker_internals_ui.cc index 0e50fa4..cf46466 100644 --- a/content/browser/service_worker/service_worker_internals_ui.cc +++ b/content/browser/service_worker/service_worker_internals_ui.cc @@ -4,6 +4,8 @@ #include "content/browser/service_worker/service_worker_internals_ui.h" +#include <stdint.h> + #include <string> #include <vector> @@ -64,7 +66,7 @@ void OperationCompleteCallback(WeakPtr<ServiceWorkerInternalsUI> internals, void CallServiceWorkerVersionMethodWithVersionID( ServiceWorkerInternalsUI::ServiceWorkerVersionMethod method, scoped_refptr<ServiceWorkerContextWrapper> context, - int64 version_id, + int64_t version_id, const ServiceWorkerInternalsUI::StatusCallback& callback) { if (!BrowserThread::CurrentlyOn(BrowserThread::IO)) { BrowserThread::PostTask( @@ -89,7 +91,7 @@ void CallServiceWorkerVersionMethodWithVersionID( void DispatchPushEventWithVersionID( scoped_refptr<ServiceWorkerContextWrapper> context, - int64 version_id, + int64_t version_id, const ServiceWorkerInternalsUI::StatusCallback& callback) { if (!BrowserThread::CurrentlyOn(BrowserThread::IO)) { BrowserThread::PostTask( @@ -251,14 +253,14 @@ class ServiceWorkerInternalsUI::PartitionObserver : partition_id_(partition_id), web_ui_(web_ui) {} ~PartitionObserver() override {} // ServiceWorkerContextObserver overrides: - void OnRunningStateChanged(int64 version_id, + void OnRunningStateChanged(int64_t version_id, ServiceWorkerVersion::RunningStatus) override { DCHECK_CURRENTLY_ON(BrowserThread::UI); web_ui_->CallJavascriptFunction( "serviceworker.onRunningStateChanged", FundamentalValue(partition_id_), StringValue(base::Int64ToString(version_id))); } - void OnVersionStateChanged(int64 version_id, + void OnVersionStateChanged(int64_t version_id, ServiceWorkerVersion::Status) override { DCHECK_CURRENTLY_ON(BrowserThread::UI); web_ui_->CallJavascriptFunction( @@ -266,7 +268,7 @@ class ServiceWorkerInternalsUI::PartitionObserver FundamentalValue(partition_id_), StringValue(base::Int64ToString(version_id))); } - void OnErrorReported(int64 version_id, + void OnErrorReported(int64_t version_id, int process_id, int thread_id, const ErrorInfo& info) override { @@ -285,7 +287,7 @@ class ServiceWorkerInternalsUI::PartitionObserver web_ui_->CallJavascriptFunction("serviceworker.onErrorReported", args.get()); } - void OnReportConsoleMessage(int64 version_id, + void OnReportConsoleMessage(int64_t version_id, int process_id, int thread_id, const ConsoleMessage& message) override { @@ -305,13 +307,13 @@ class ServiceWorkerInternalsUI::PartitionObserver web_ui_->CallJavascriptFunction("serviceworker.onConsoleMessageReported", args.get()); } - void OnRegistrationStored(int64 registration_id, + void OnRegistrationStored(int64_t registration_id, const GURL& pattern) override { DCHECK_CURRENTLY_ON(BrowserThread::UI); web_ui_->CallJavascriptFunction("serviceworker.onRegistrationStored", StringValue(pattern.spec())); } - void OnRegistrationDeleted(int64 registration_id, + void OnRegistrationDeleted(int64_t registration_id, const GURL& pattern) override { web_ui_->CallJavascriptFunction("serviceworker.onRegistrationDeleted", StringValue(pattern.spec())); @@ -491,7 +493,7 @@ void ServiceWorkerInternalsUI::CallServiceWorkerVersionMethod( int partition_id; scoped_refptr<ServiceWorkerContextWrapper> context; std::string version_id_string; - int64 version_id = 0; + int64_t version_id = 0; if (!args->GetInteger(0, &callback_id) || !args->GetDictionary(1, &cmd_args) || !cmd_args->GetInteger("partition_id", &partition_id) || @@ -512,7 +514,7 @@ void ServiceWorkerInternalsUI::DispatchPushEvent( DCHECK_CURRENTLY_ON(BrowserThread::UI); int callback_id; int partition_id; - int64 version_id = 0; + int64_t version_id = 0; std::string version_id_string; const DictionaryValue* cmd_args = NULL; scoped_refptr<ServiceWorkerContextWrapper> context; diff --git a/content/browser/service_worker/service_worker_job_coordinator.cc b/content/browser/service_worker/service_worker_job_coordinator.cc index 62ace7d..da417c7 100644 --- a/content/browser/service_worker/service_worker_job_coordinator.cc +++ b/content/browser/service_worker/service_worker_job_coordinator.cc @@ -4,6 +4,8 @@ #include "content/browser/service_worker/service_worker_job_coordinator.h" +#include <stddef.h> + #include "base/memory/scoped_ptr.h" #include "base/stl_util.h" #include "content/browser/service_worker/service_worker_register_job_base.h" diff --git a/content/browser/service_worker/service_worker_job_coordinator.h b/content/browser/service_worker/service_worker_job_coordinator.h index b4fa8a28..728b820 100644 --- a/content/browser/service_worker/service_worker_job_coordinator.h +++ b/content/browser/service_worker/service_worker_job_coordinator.h @@ -8,6 +8,7 @@ #include <deque> #include <map> +#include "base/macros.h" #include "content/browser/service_worker/service_worker_register_job.h" #include "content/browser/service_worker/service_worker_unregister_job.h" #include "content/common/content_export.h" diff --git a/content/browser/service_worker/service_worker_job_unittest.cc b/content/browser/service_worker/service_worker_job_unittest.cc index d8cd7ef..a5572a4 100644 --- a/content/browser/service_worker/service_worker_job_unittest.cc +++ b/content/browser/service_worker/service_worker_job_unittest.cc @@ -2,8 +2,11 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. +#include <stdint.h> + #include "base/files/scoped_temp_dir.h" #include "base/logging.h" +#include "base/macros.h" #include "base/run_loop.h" #include "content/browser/browser_thread_impl.h" #include "content/browser/service_worker/embedded_worker_registry.h" @@ -82,7 +85,7 @@ ServiceWorkerStorage::FindRegistrationCallback SaveFoundRegistration( void SaveUnregistrationCallback(ServiceWorkerStatusCode expected_status, bool* called, - int64 registration_id, + int64_t registration_id, ServiceWorkerStatusCode status) { EXPECT_EQ(expected_status, status); *called = true; @@ -354,7 +357,7 @@ class FailToStartWorkerTestHelper : public EmbeddedWorkerTestHelper { FailToStartWorkerTestHelper() : EmbeddedWorkerTestHelper(base::FilePath()) {} void OnStartWorker(int embedded_worker_id, - int64 service_worker_version_id, + int64_t service_worker_version_id, const GURL& scope, const GURL& script_url) override { EmbeddedWorkerInstance* worker = registry()->GetWorker(embedded_worker_id); @@ -721,10 +724,11 @@ void OnIOComplete(int* rv_out, int rv) { *rv_out = rv; } -void WriteResponse( - ServiceWorkerStorage* storage, int64 id, - const std::string& headers, - IOBuffer* body, int length) { +void WriteResponse(ServiceWorkerStorage* storage, + int64_t id, + const std::string& headers, + IOBuffer* body, + int length) { scoped_ptr<ServiceWorkerResponseWriter> writer = storage->CreateResponseWriter(id); @@ -748,9 +752,9 @@ void WriteResponse( EXPECT_EQ(length, rv); } -void WriteStringResponse( - ServiceWorkerStorage* storage, int64 id, - const std::string& body) { +void WriteStringResponse(ServiceWorkerStorage* storage, + int64_t id, + const std::string& body) { scoped_refptr<IOBuffer> body_buffer(new WrappedIOBuffer(body.data())); const char kHttpHeaders[] = "HTTP/1.0 200 HONKYDORY\0\0"; std::string headers(kHttpHeaders, arraysize(kHttpHeaders)); @@ -763,13 +767,13 @@ class UpdateJobTestHelper public ServiceWorkerVersion::Listener { public: struct AttributeChangeLogEntry { - int64 registration_id; + int64_t registration_id; ChangedVersionAttributesMask mask; ServiceWorkerRegistrationInfo info; }; struct StateChangeLogEntry { - int64 version_id; + int64_t version_id; ServiceWorkerVersion::Status status; }; @@ -805,11 +809,11 @@ class UpdateJobTestHelper // EmbeddedWorkerTestHelper overrides void OnStartWorker(int embedded_worker_id, - int64 version_id, + int64_t version_id, const GURL& scope, const GURL& script) override { const std::string kMockScriptBody = "mock_script"; - const uint64 kMockScriptSize = 19284; + const uint64_t kMockScriptSize = 19284; ServiceWorkerVersion* version = context()->GetLiveVersion(version_id); ServiceWorkerRegistration* registration = context()->GetLiveRegistration(version->registration_id()); @@ -821,7 +825,7 @@ class UpdateJobTestHelper if (!is_update) { // Spoof caching the script for the initial version. - int64 resource_id = storage()->NewResourceId(); + int64_t resource_id = storage()->NewResourceId(); version->script_cache_map()->NotifyStartedCaching(script, resource_id); WriteStringResponse(storage(), resource_id, kMockScriptBody); version->script_cache_map()->NotifyFinishedCaching( @@ -834,7 +838,7 @@ class UpdateJobTestHelper } // Spoof caching the script for the new version. - int64 resource_id = storage()->NewResourceId(); + int64_t resource_id = storage()->NewResourceId(); version->script_cache_map()->NotifyStartedCaching(script, resource_id); WriteStringResponse(storage(), resource_id, "mock_different_script"); version->script_cache_map()->NotifyFinishedCaching( @@ -888,7 +892,7 @@ class EvictIncumbentVersionHelper : public UpdateJobTestHelper { ~EvictIncumbentVersionHelper() override {} void OnStartWorker(int embedded_worker_id, - int64 version_id, + int64_t version_id, const GURL& scope, const GURL& script) override { ServiceWorkerVersion* version = context()->GetLiveVersion(version_id); diff --git a/content/browser/service_worker/service_worker_metrics.h b/content/browser/service_worker/service_worker_metrics.h index b02e4da..ebf941d 100644 --- a/content/browser/service_worker/service_worker_metrics.h +++ b/content/browser/service_worker/service_worker_metrics.h @@ -5,6 +5,8 @@ #ifndef CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_METRICS_H_ #define CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_METRICS_H_ +#include <stddef.h> + #include "base/macros.h" #include "content/browser/service_worker/service_worker_database.h" #include "content/common/service_worker/service_worker_types.h" diff --git a/content/browser/service_worker/service_worker_process_manager.cc b/content/browser/service_worker/service_worker_process_manager.cc index 36715bc..cb1f589 100644 --- a/content/browser/service_worker/service_worker_process_manager.cc +++ b/content/browser/service_worker/service_worker_process_manager.cc @@ -4,6 +4,8 @@ #include "content/browser/service_worker/service_worker_process_manager.h" +#include <stddef.h> + #include <algorithm> #include <utility> diff --git a/content/browser/service_worker/service_worker_process_manager_unittest.cc b/content/browser/service_worker/service_worker_process_manager_unittest.cc index bb0c1ff..622412a 100644 --- a/content/browser/service_worker/service_worker_process_manager_unittest.cc +++ b/content/browser/service_worker/service_worker_process_manager_unittest.cc @@ -2,8 +2,8 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "base/basictypes.h" #include "base/bind.h" +#include "base/macros.h" #include "base/run_loop.h" #include "content/browser/service_worker/service_worker_process_manager.h" #include "content/public/test/mock_render_process_host.h" diff --git a/content/browser/service_worker/service_worker_provider_host.cc b/content/browser/service_worker/service_worker_provider_host.cc index 174b44a..359010c 100644 --- a/content/browser/service_worker/service_worker_provider_host.cc +++ b/content/browser/service_worker/service_worker_provider_host.cc @@ -216,7 +216,7 @@ void ServiceWorkerProviderHost::SetControllerVersionAttribute( notify_controllerchange)); } -bool ServiceWorkerProviderHost::SetHostedVersionId(int64 version_id) { +bool ServiceWorkerProviderHost::SetHostedVersionId(int64_t version_id) { if (!context_) return true; // System is shutting down. if (active_version()) @@ -323,7 +323,7 @@ void ServiceWorkerProviderHost::RemoveMatchingRegistration( void ServiceWorkerProviderHost::AddAllMatchingRegistrations() { DCHECK(context_); - const std::map<int64, ServiceWorkerRegistration*>& registrations = + const std::map<int64_t, ServiceWorkerRegistration*>& registrations = context_->GetLiveRegistrations(); for (const auto& key_registration : registrations) { ServiceWorkerRegistration* registration = key_registration.second; diff --git a/content/browser/service_worker/service_worker_provider_host.h b/content/browser/service_worker/service_worker_provider_host.h index 1ed95fa..cab3ff0 100644 --- a/content/browser/service_worker/service_worker_provider_host.h +++ b/content/browser/service_worker/service_worker_provider_host.h @@ -5,10 +5,14 @@ #ifndef CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_PROVIDER_HOST_H_ #define CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_PROVIDER_HOST_H_ +#include <stddef.h> +#include <stdint.h> + #include <set> #include <vector> #include "base/gtest_prod_util.h" +#include "base/macros.h" #include "base/memory/ref_counted.h" #include "base/memory/weak_ptr.h" #include "content/browser/service_worker/service_worker_registration.h" @@ -131,7 +135,7 @@ class CONTENT_EXPORT ServiceWorkerProviderHost // Returns false if the version is not in the expected STARTING in our // process state. That would be indicative of a bad IPC message. - bool SetHostedVersionId(int64 versions_id); + bool SetHostedVersionId(int64_t versions_id); // Returns a handler for a request, the handler may return NULL if // the request doesn't require special handling. diff --git a/content/browser/service_worker/service_worker_provider_host_unittest.cc b/content/browser/service_worker/service_worker_provider_host_unittest.cc index 463d5ca..642260b0 100644 --- a/content/browser/service_worker/service_worker_provider_host_unittest.cc +++ b/content/browser/service_worker/service_worker_provider_host_unittest.cc @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "base/basictypes.h" +#include "base/macros.h" #include "base/memory/weak_ptr.h" #include "base/thread_task_runner_handle.h" #include "content/browser/service_worker/embedded_worker_test_helper.h" diff --git a/content/browser/service_worker/service_worker_quota_client.h b/content/browser/service_worker/service_worker_quota_client.h index a1cf91d..3c6f84f 100644 --- a/content/browser/service_worker/service_worker_quota_client.h +++ b/content/browser/service_worker/service_worker_quota_client.h @@ -5,6 +5,7 @@ #ifndef CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_QUOTA_CLIENT_H_ #define CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_QUOTA_CLIENT_H_ +#include "base/macros.h" #include "base/memory/ref_counted.h" #include "content/common/content_export.h" #include "storage/browser/quota/quota_client.h" diff --git a/content/browser/service_worker/service_worker_read_from_cache_job.cc b/content/browser/service_worker/service_worker_read_from_cache_job.cc index 3b0d658..bd9844b 100644 --- a/content/browser/service_worker/service_worker_read_from_cache_job.cc +++ b/content/browser/service_worker/service_worker_read_from_cache_job.cc @@ -28,7 +28,7 @@ ServiceWorkerReadFromCacheJob::ServiceWorkerReadFromCacheJob( ResourceType resource_type, base::WeakPtr<ServiceWorkerContextCore> context, const scoped_refptr<ServiceWorkerVersion>& version, - int64 resource_id) + int64_t resource_id) : net::URLRequestJob(request, network_delegate), resource_type_(resource_type), resource_id_(resource_id), diff --git a/content/browser/service_worker/service_worker_read_from_cache_job.h b/content/browser/service_worker/service_worker_read_from_cache_job.h index 0ee30e6..41b40ca 100644 --- a/content/browser/service_worker/service_worker_read_from_cache_job.h +++ b/content/browser/service_worker/service_worker_read_from_cache_job.h @@ -5,8 +5,11 @@ #ifndef CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_READ_FROM_CACHE_JOB_H_ #define CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_READ_FROM_CACHE_JOB_H_ +#include <stdint.h> + #include <string> +#include "base/macros.h" #include "base/memory/ref_counted.h" #include "base/memory/weak_ptr.h" #include "content/browser/service_worker/service_worker_disk_cache.h" @@ -33,7 +36,7 @@ class CONTENT_EXPORT ServiceWorkerReadFromCacheJob ResourceType resource_type, base::WeakPtr<ServiceWorkerContextCore> context, const scoped_refptr<ServiceWorkerVersion>& version, - int64 resource_id); + int64_t resource_id); ~ServiceWorkerReadFromCacheJob() override; private: @@ -66,7 +69,7 @@ class CONTENT_EXPORT ServiceWorkerReadFromCacheJob void Done(const net::URLRequestStatus& status); const ResourceType resource_type_; - const int64 resource_id_; + const int64_t resource_id_; base::WeakPtr<ServiceWorkerContextCore> context_; scoped_refptr<ServiceWorkerVersion> version_; diff --git a/content/browser/service_worker/service_worker_read_from_cache_job_unittest.cc b/content/browser/service_worker/service_worker_read_from_cache_job_unittest.cc index 93c86a1..aa7508b 100644 --- a/content/browser/service_worker/service_worker_read_from_cache_job_unittest.cc +++ b/content/browser/service_worker/service_worker_read_from_cache_job_unittest.cc @@ -4,6 +4,9 @@ #include "content/browser/service_worker/service_worker_read_from_cache_job.h" +#include <stdint.h> + +#include "base/macros.h" #include "base/run_loop.h" #include "content/browser/fileapi/mock_url_request_delegate.h" #include "content/browser/service_worker/embedded_worker_test_helper.h" @@ -23,11 +26,11 @@ namespace content { namespace { -const int64 kRegistrationId = 1; -const int64 kVersionId = 2; -const int64 kMainScriptResourceId = 10; -const int64 kImportedScriptResourceId = 11; -const int64 kResourceSize = 100; +const int64_t kRegistrationId = 1; +const int64_t kVersionId = 2; +const int64_t kMainScriptResourceId = 10; +const int64_t kImportedScriptResourceId = 11; +const int64_t kResourceSize = 100; void DidStoreRegistration(ServiceWorkerStatusCode* status_out, const base::Closure& quit_closure, @@ -88,7 +91,7 @@ class ServiceWorkerReadFromCacheJobTest : public testing::Test { ASSERT_TRUE(WriteResource(imported_script_.resource_id)); } - bool WriteResource(int64 resource_id) { + bool WriteResource(int64_t resource_id) { const char kHttpHeaders[] = "HTTP/1.0 200 OK\0Content-Length: 5\0\0"; const char kHttpBody[] = "Hello"; const int length = arraysize(kHttpBody); @@ -210,7 +213,7 @@ TEST_F(ServiceWorkerReadFromCacheJobTest, ResourceNotFound) { scoped_ptr<net::URLRequest> request = url_request_context_->CreateRequest( GURL("http://example.com/nonexistent"), net::DEFAULT_PRIORITY, &delegate_); - const int64 kNonexistentResourceId = 100; + const int64_t kNonexistentResourceId = 100; scoped_ptr<ServiceWorkerReadFromCacheJob> job( new ServiceWorkerReadFromCacheJob( request.get(), nullptr /* NetworkDelegate */, diff --git a/content/browser/service_worker/service_worker_register_job.cc b/content/browser/service_worker/service_worker_register_job.cc index 244905e..69f5acd 100644 --- a/content/browser/service_worker/service_worker_register_job.cc +++ b/content/browser/service_worker/service_worker_register_job.cc @@ -4,6 +4,8 @@ #include "content/browser/service_worker/service_worker_register_job.h" +#include <stdint.h> + #include <vector> #include "base/location.h" @@ -274,7 +276,7 @@ void ServiceWorkerRegisterJob::ContinueWithUpdate( void ServiceWorkerRegisterJob::RegisterAndContinue() { SetPhase(REGISTER); - int64 registration_id = context_->storage()->NewRegistrationId(); + int64_t registration_id = context_->storage()->NewRegistrationId(); if (registration_id == kInvalidServiceWorkerRegistrationId) { Complete(SERVICE_WORKER_ERROR_ABORT); return; @@ -331,7 +333,7 @@ void ServiceWorkerRegisterJob::UpdateAndContinue() { SetPhase(UPDATE); context_->storage()->NotifyInstallingRegistration(registration()); - int64 version_id = context_->storage()->NewVersionId(); + int64_t version_id = context_->storage()->NewVersionId(); if (version_id == kInvalidServiceWorkerVersionId) { Complete(SERVICE_WORKER_ERROR_ABORT); return; diff --git a/content/browser/service_worker/service_worker_register_job.h b/content/browser/service_worker/service_worker_register_job.h index a439b0c..15033bc 100644 --- a/content/browser/service_worker/service_worker_register_job.h +++ b/content/browser/service_worker/service_worker_register_job.h @@ -7,6 +7,7 @@ #include <vector> +#include "base/macros.h" #include "base/memory/weak_ptr.h" #include "content/browser/service_worker/embedded_worker_instance.h" #include "content/browser/service_worker/service_worker_register_job_base.h" diff --git a/content/browser/service_worker/service_worker_registration.cc b/content/browser/service_worker/service_worker_registration.cc index 1a2f536..fbb87a0 100644 --- a/content/browser/service_worker/service_worker_registration.cc +++ b/content/browser/service_worker/service_worker_registration.cc @@ -25,7 +25,7 @@ ServiceWorkerVersionInfo GetVersionInfo(ServiceWorkerVersion* version) { ServiceWorkerRegistration::ServiceWorkerRegistration( const GURL& pattern, - int64 registration_id, + int64_t registration_id, base::WeakPtr<ServiceWorkerContextCore> context) : pattern_(pattern), registration_id_(registration_id), diff --git a/content/browser/service_worker/service_worker_registration.h b/content/browser/service_worker/service_worker_registration.h index accb464..dab2043 100644 --- a/content/browser/service_worker/service_worker_registration.h +++ b/content/browser/service_worker/service_worker_registration.h @@ -5,10 +5,12 @@ #ifndef CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_REGISTRATION_H_ #define CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_REGISTRATION_H_ +#include <stdint.h> + #include <string> -#include "base/basictypes.h" #include "base/logging.h" +#include "base/macros.h" #include "base/memory/ref_counted.h" #include "base/memory/scoped_ptr.h" #include "content/browser/service_worker/service_worker_version.h" @@ -50,10 +52,10 @@ class CONTENT_EXPORT ServiceWorkerRegistration }; ServiceWorkerRegistration(const GURL& pattern, - int64 registration_id, + int64_t registration_id, base::WeakPtr<ServiceWorkerContextCore> context); - int64 id() const { return registration_id_; } + int64_t id() const { return registration_id_; } const GURL& pattern() const { return pattern_; } bool is_deleted() const { return is_deleted_; } @@ -168,7 +170,7 @@ class CONTENT_EXPORT ServiceWorkerRegistration ServiceWorkerStatusCode status); const GURL pattern_; - const int64 registration_id_; + const int64_t registration_id_; bool is_deleted_; bool is_uninstalling_; bool is_uninstalled_; diff --git a/content/browser/service_worker/service_worker_registration_handle.h b/content/browser/service_worker/service_worker_registration_handle.h index bbe0cf8..6fb4e07d 100644 --- a/content/browser/service_worker/service_worker_registration_handle.h +++ b/content/browser/service_worker/service_worker_registration_handle.h @@ -5,6 +5,7 @@ #ifndef CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_REGISTRATION_HANDLE_H_ #define CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_REGISTRATION_HANDLE_H_ +#include "base/macros.h" #include "base/memory/ref_counted.h" #include "base/memory/scoped_ptr.h" #include "base/memory/weak_ptr.h" diff --git a/content/browser/service_worker/service_worker_registration_unittest.cc b/content/browser/service_worker/service_worker_registration_unittest.cc index f7a644c..0bbe673 100644 --- a/content/browser/service_worker/service_worker_registration_unittest.cc +++ b/content/browser/service_worker/service_worker_registration_unittest.cc @@ -4,6 +4,8 @@ #include "content/browser/service_worker/service_worker_registration.h" +#include <stdint.h> + #include "base/files/scoped_temp_dir.h" #include "base/logging.h" #include "base/run_loop.h" @@ -87,15 +89,15 @@ class ServiceWorkerRegistrationTest : public testing::Test { TEST_F(ServiceWorkerRegistrationTest, SetAndUnsetVersions) { const GURL kScope("http://www.example.not/"); const GURL kScript("http://www.example.not/service_worker.js"); - int64 kRegistrationId = 1L; + int64_t kRegistrationId = 1L; scoped_refptr<ServiceWorkerRegistration> registration = new ServiceWorkerRegistration( kScope, kRegistrationId, context_ptr_); - const int64 version_1_id = 1L; - const int64 version_2_id = 2L; + const int64_t version_1_id = 1L; + const int64_t version_2_id = 2L; scoped_refptr<ServiceWorkerVersion> version_1 = new ServiceWorkerVersion( registration.get(), kScript, version_1_id, context_ptr_); scoped_refptr<ServiceWorkerVersion> version_2 = new ServiceWorkerVersion( @@ -156,7 +158,7 @@ TEST_F(ServiceWorkerRegistrationTest, SetAndUnsetVersions) { TEST_F(ServiceWorkerRegistrationTest, FailedRegistrationNoCrash) { const GURL kScope("http://www.example.not/"); - int64 kRegistrationId = 1L; + int64_t kRegistrationId = 1L; scoped_refptr<ServiceWorkerRegistration> registration = new ServiceWorkerRegistration( kScope, diff --git a/content/browser/service_worker/service_worker_request_handler.cc b/content/browser/service_worker/service_worker_request_handler.cc index 9cb0b2d..bd27e42 100644 --- a/content/browser/service_worker/service_worker_request_handler.cc +++ b/content/browser/service_worker/service_worker_request_handler.cc @@ -6,6 +6,7 @@ #include <string> +#include "base/macros.h" #include "content/browser/service_worker/service_worker_context_core.h" #include "content/browser/service_worker/service_worker_context_wrapper.h" #include "content/browser/service_worker/service_worker_navigation_handle_core.h" diff --git a/content/browser/service_worker/service_worker_request_handler.h b/content/browser/service_worker/service_worker_request_handler.h index 332c9a9..9f9c7eb 100644 --- a/content/browser/service_worker/service_worker_request_handler.h +++ b/content/browser/service_worker/service_worker_request_handler.h @@ -5,7 +5,7 @@ #ifndef CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_REQUEST_HANDLER_H_ #define CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_REQUEST_HANDLER_H_ -#include "base/basictypes.h" +#include "base/macros.h" #include "base/memory/weak_ptr.h" #include "base/supports_user_data.h" #include "base/time/time.h" diff --git a/content/browser/service_worker/service_worker_script_cache_map.cc b/content/browser/service_worker/service_worker_script_cache_map.cc index c99fef8..5a9f2b3 100644 --- a/content/browser/service_worker/service_worker_script_cache_map.cc +++ b/content/browser/service_worker/service_worker_script_cache_map.cc @@ -24,15 +24,15 @@ ServiceWorkerScriptCacheMap::ServiceWorkerScriptCacheMap( ServiceWorkerScriptCacheMap::~ServiceWorkerScriptCacheMap() { } -int64 ServiceWorkerScriptCacheMap::LookupResourceId(const GURL& url) { +int64_t ServiceWorkerScriptCacheMap::LookupResourceId(const GURL& url) { ResourceMap::const_iterator found = resource_map_.find(url); if (found == resource_map_.end()) return kInvalidServiceWorkerResourceId; return found->second.resource_id; } -void ServiceWorkerScriptCacheMap::NotifyStartedCaching( - const GURL& url, int64 resource_id) { +void ServiceWorkerScriptCacheMap::NotifyStartedCaching(const GURL& url, + int64_t resource_id) { DCHECK_EQ(kInvalidServiceWorkerResourceId, LookupResourceId(url)); DCHECK(owner_->status() == ServiceWorkerVersion::NEW || owner_->status() == ServiceWorkerVersion::INSTALLING) @@ -46,7 +46,7 @@ void ServiceWorkerScriptCacheMap::NotifyStartedCaching( void ServiceWorkerScriptCacheMap::NotifyFinishedCaching( const GURL& url, - int64 size_bytes, + int64_t size_bytes, const net::URLRequestStatus& status, const std::string& status_message) { DCHECK_NE(kInvalidServiceWorkerResourceId, LookupResourceId(url)); diff --git a/content/browser/service_worker/service_worker_script_cache_map.h b/content/browser/service_worker/service_worker_script_cache_map.h index b4cf74b..f2c27c6 100644 --- a/content/browser/service_worker/service_worker_script_cache_map.h +++ b/content/browser/service_worker/service_worker_script_cache_map.h @@ -5,10 +5,13 @@ #ifndef CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_SCRIPT_CACHE_MAP_H_ #define CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_SCRIPT_CACHE_MAP_H_ +#include <stddef.h> +#include <stdint.h> + #include <map> #include <vector> -#include "base/basictypes.h" +#include "base/macros.h" #include "base/memory/weak_ptr.h" #include "content/browser/service_worker/service_worker_database.h" #include "content/common/content_export.h" @@ -27,13 +30,13 @@ class ServiceWorkerResponseMetadataWriter; // for a particular version's implicit script resources. class CONTENT_EXPORT ServiceWorkerScriptCacheMap { public: - int64 LookupResourceId(const GURL& url); + int64_t LookupResourceId(const GURL& url); // Used during the initial run of a new version to build the map // of resources ids. - void NotifyStartedCaching(const GURL& url, int64 resource_id); + void NotifyStartedCaching(const GURL& url, int64_t resource_id); void NotifyFinishedCaching(const GURL& url, - int64 size_bytes, + int64_t size_bytes, const net::URLRequestStatus& status, const std::string& status_message); diff --git a/content/browser/service_worker/service_worker_storage.cc b/content/browser/service_worker/service_worker_storage.cc index 76cf507..4bb270f 100644 --- a/content/browser/service_worker/service_worker_storage.cc +++ b/content/browser/service_worker/service_worker_storage.cc @@ -4,6 +4,8 @@ #include "content/browser/service_worker/service_worker_storage.h" +#include <stddef.h> + #include "base/bind_helpers.h" #include "base/files/file_util.h" #include "base/message_loop/message_loop.h" @@ -175,7 +177,7 @@ void ServiceWorkerStorage::FindRegistrationForDocument( // To connect this TRACE_EVENT with the callback, TimeTicks is used for // callback id. - int64 callback_id = base::TimeTicks::Now().ToInternalValue(); + int64_t callback_id = base::TimeTicks::Now().ToInternalValue(); TRACE_EVENT_ASYNC_BEGIN1( "ServiceWorker", "ServiceWorkerStorage::FindRegistrationForDocument", @@ -248,7 +250,7 @@ ServiceWorkerRegistration* ServiceWorkerStorage::GetUninstallingRegistration( } void ServiceWorkerStorage::FindRegistrationForId( - int64 registration_id, + int64_t registration_id, const GURL& origin, const FindRegistrationCallback& callback) { if (!LazyInitialize(base::Bind( @@ -294,7 +296,7 @@ void ServiceWorkerStorage::FindRegistrationForId( } void ServiceWorkerStorage::FindRegistrationForIdOnly( - int64 registration_id, + int64_t registration_id, const FindRegistrationCallback& callback) { if (!LazyInitialize( base::Bind(&ServiceWorkerStorage::FindRegistrationForIdOnly, @@ -412,7 +414,7 @@ void ServiceWorkerStorage::StoreRegistration( return; } - uint64 resources_total_size_bytes = 0; + uint64_t resources_total_size_bytes = 0; for (const auto& resource : resources) { resources_total_size_bytes += resource.size_bytes; } @@ -477,10 +479,9 @@ void ServiceWorkerStorage::UpdateLastUpdateCheckTime( registration->last_update_check())); } -void ServiceWorkerStorage::DeleteRegistration( - int64 registration_id, - const GURL& origin, - const StatusCallback& callback) { +void ServiceWorkerStorage::DeleteRegistration(int64_t registration_id, + const GURL& origin, + const StatusCallback& callback) { DCHECK(state_ == INITIALIZED || state_ == DISABLED) << state_; if (IsDisabled()) { RunSoon(FROM_HERE, base::Bind(callback, SERVICE_WORKER_ERROR_ABORT)); @@ -515,24 +516,24 @@ void ServiceWorkerStorage::DeleteRegistration( } scoped_ptr<ServiceWorkerResponseReader> -ServiceWorkerStorage::CreateResponseReader(int64 resource_id) { +ServiceWorkerStorage::CreateResponseReader(int64_t resource_id) { return make_scoped_ptr( new ServiceWorkerResponseReader(resource_id, disk_cache())); } scoped_ptr<ServiceWorkerResponseWriter> -ServiceWorkerStorage::CreateResponseWriter(int64 resource_id) { +ServiceWorkerStorage::CreateResponseWriter(int64_t resource_id) { return make_scoped_ptr( new ServiceWorkerResponseWriter(resource_id, disk_cache())); } scoped_ptr<ServiceWorkerResponseMetadataWriter> -ServiceWorkerStorage::CreateResponseMetadataWriter(int64 resource_id) { +ServiceWorkerStorage::CreateResponseMetadataWriter(int64_t resource_id) { return make_scoped_ptr( new ServiceWorkerResponseMetadataWriter(resource_id, disk_cache())); } -void ServiceWorkerStorage::StoreUncommittedResourceId(int64 resource_id) { +void ServiceWorkerStorage::StoreUncommittedResourceId(int64_t resource_id) { DCHECK_NE(kInvalidServiceWorkerResourceId, resource_id); DCHECK_EQ(INITIALIZED, state_); @@ -543,18 +544,18 @@ void ServiceWorkerStorage::StoreUncommittedResourceId(int64 resource_id) { database_task_manager_->GetTaskRunner(), FROM_HERE, base::Bind(&ServiceWorkerDatabase::WriteUncommittedResourceIds, base::Unretained(database_.get()), - std::set<int64>(&resource_id, &resource_id + 1)), + std::set<int64_t>(&resource_id, &resource_id + 1)), base::Bind(&ServiceWorkerStorage::DidWriteUncommittedResourceIds, weak_factory_.GetWeakPtr())); } -void ServiceWorkerStorage::DoomUncommittedResource(int64 resource_id) { +void ServiceWorkerStorage::DoomUncommittedResource(int64_t resource_id) { DCHECK_NE(kInvalidServiceWorkerResourceId, resource_id); - DoomUncommittedResources(std::set<int64>(&resource_id, &resource_id + 1)); + DoomUncommittedResources(std::set<int64_t>(&resource_id, &resource_id + 1)); } void ServiceWorkerStorage::DoomUncommittedResources( - const std::set<int64>& resource_ids) { + const std::set<int64_t>& resource_ids) { PostTaskAndReplyWithResult( database_task_manager_->GetTaskRunner(), FROM_HERE, base::Bind(&ServiceWorkerDatabase::PurgeUncommittedResourceIds, @@ -563,12 +564,11 @@ void ServiceWorkerStorage::DoomUncommittedResources( weak_factory_.GetWeakPtr(), resource_ids)); } -void ServiceWorkerStorage::StoreUserData( - int64 registration_id, - const GURL& origin, - const std::string& key, - const std::string& data, - const StatusCallback& callback) { +void ServiceWorkerStorage::StoreUserData(int64_t registration_id, + const GURL& origin, + const std::string& key, + const std::string& data, + const StatusCallback& callback) { DCHECK(state_ == INITIALIZED || state_ == DISABLED) << state_; if (IsDisabled()) { RunSoon(FROM_HERE, base::Bind(callback, SERVICE_WORKER_ERROR_ABORT)); @@ -591,10 +591,9 @@ void ServiceWorkerStorage::StoreUserData( callback)); } -void ServiceWorkerStorage::GetUserData( - int64 registration_id, - const std::string& key, - const GetUserDataCallback& callback) { +void ServiceWorkerStorage::GetUserData(int64_t registration_id, + const std::string& key, + const GetUserDataCallback& callback) { DCHECK(state_ == INITIALIZED || state_ == DISABLED) << state_; if (IsDisabled()) { RunSoon(FROM_HERE, @@ -620,10 +619,9 @@ void ServiceWorkerStorage::GetUserData( callback))); } -void ServiceWorkerStorage::ClearUserData( - int64 registration_id, - const std::string& key, - const StatusCallback& callback) { +void ServiceWorkerStorage::ClearUserData(int64_t registration_id, + const std::string& key, + const StatusCallback& callback) { DCHECK(state_ == INITIALIZED || state_ == DISABLED) << state_; if (IsDisabled()) { RunSoon(FROM_HERE, base::Bind(callback, SERVICE_WORKER_ERROR_ABORT)); @@ -654,9 +652,10 @@ void ServiceWorkerStorage::GetUserDataForAllRegistrations( base::Bind(&ServiceWorkerStorage::GetUserDataForAllRegistrations, weak_factory_.GetWeakPtr(), key, callback))) { if (state_ != INITIALIZING) { - RunSoon(FROM_HERE, - base::Bind(callback, std::vector<std::pair<int64, std::string>>(), - SERVICE_WORKER_ERROR_ABORT)); + RunSoon( + FROM_HERE, + base::Bind(callback, std::vector<std::pair<int64_t, std::string>>(), + SERVICE_WORKER_ERROR_ABORT)); } return; } @@ -664,7 +663,7 @@ void ServiceWorkerStorage::GetUserDataForAllRegistrations( if (key.empty()) { RunSoon(FROM_HERE, - base::Bind(callback, std::vector<std::pair<int64, std::string>>(), + base::Bind(callback, std::vector<std::pair<int64_t, std::string>>(), SERVICE_WORKER_ERROR_FAILED)); return; } @@ -699,21 +698,21 @@ void ServiceWorkerStorage::DeleteAndStartOver(const StatusCallback& callback) { weak_factory_.GetWeakPtr(), callback)); } -int64 ServiceWorkerStorage::NewRegistrationId() { +int64_t ServiceWorkerStorage::NewRegistrationId() { if (state_ == DISABLED) return kInvalidServiceWorkerRegistrationId; DCHECK_EQ(INITIALIZED, state_); return next_registration_id_++; } -int64 ServiceWorkerStorage::NewVersionId() { +int64_t ServiceWorkerStorage::NewVersionId() { if (state_ == DISABLED) return kInvalidServiceWorkerVersionId; DCHECK_EQ(INITIALIZED, state_); return next_version_id_++; } -int64 ServiceWorkerStorage::NewResourceId() { +int64_t ServiceWorkerStorage::NewResourceId() { if (state_ == DISABLED) return kInvalidServiceWorkerResourceId; DCHECK_EQ(INITIALIZED, state_); @@ -736,7 +735,7 @@ void ServiceWorkerStorage::NotifyDoneInstallingRegistration( ResourceList resources; version->script_cache_map()->GetResources(&resources); - std::set<int64> resource_ids; + std::set<int64_t> resource_ids; for (const auto& resource : resources) resource_ids.insert(resource.resource_id); DoomUncommittedResources(resource_ids); @@ -861,7 +860,7 @@ void ServiceWorkerStorage::DidReadInitialData( void ServiceWorkerStorage::DidFindRegistrationForDocument( const GURL& document_url, const FindRegistrationCallback& callback, - int64 callback_id, + int64_t callback_id, const ServiceWorkerDatabase::RegistrationData& data, const ResourceList& resources, ServiceWorkerDatabase::Status status) { @@ -979,7 +978,7 @@ void ServiceWorkerStorage::DidGetRegistrations( } // Add all stored registrations. - std::set<int64> registration_ids; + std::set<int64_t> registration_ids; std::vector<scoped_refptr<ServiceWorkerRegistration>> registrations; size_t index = 0; for (const auto& registration_data : *registration_data_list) { @@ -1014,7 +1013,7 @@ void ServiceWorkerStorage::DidGetRegistrationsInfos( } // Add all stored registrations. - std::set<int64> pushed_registrations; + std::set<int64_t> pushed_registrations; std::vector<ServiceWorkerRegistrationInfo> infos; for (const auto& registration_data : *registration_data_list) { const bool inserted = @@ -1074,7 +1073,7 @@ void ServiceWorkerStorage::DidStoreRegistration( const ServiceWorkerDatabase::RegistrationData& new_version, const GURL& origin, const ServiceWorkerDatabase::RegistrationData& deleted_version, - const std::vector<int64>& newly_purgeable_resources, + const std::vector<int64_t>& newly_purgeable_resources, ServiceWorkerDatabase::Status status) { if (status != ServiceWorkerDatabase::STATUS_OK) { ScheduleDeleteAndStartOver(); @@ -1121,7 +1120,7 @@ void ServiceWorkerStorage::DidDeleteRegistration( const DidDeleteRegistrationParams& params, OriginState origin_state, const ServiceWorkerDatabase::RegistrationData& deleted_version, - const std::vector<int64>& newly_purgeable_resources, + const std::vector<int64_t>& newly_purgeable_resources, ServiceWorkerDatabase::Status status) { pending_deletions_.erase(params.registration_id); if (status != ServiceWorkerDatabase::STATUS_OK) { @@ -1155,7 +1154,7 @@ void ServiceWorkerStorage::DidWriteUncommittedResourceIds( } void ServiceWorkerStorage::DidPurgeUncommittedResourceIds( - const std::set<int64>& resource_ids, + const std::set<int64_t>& resource_ids, ServiceWorkerDatabase::Status status) { if (status != ServiceWorkerDatabase::STATUS_OK) { ScheduleDeleteAndStartOver(); @@ -1198,7 +1197,7 @@ void ServiceWorkerStorage::DidDeleteUserData( void ServiceWorkerStorage::DidGetUserDataForAllRegistrations( const GetUserDataForAllRegistrationsCallback& callback, - const std::vector<std::pair<int64, std::string>>& user_data, + const std::vector<std::pair<int64_t, std::string>>& user_data, ServiceWorkerDatabase::Status status) { if (status != ServiceWorkerDatabase::STATUS_OK) ScheduleDeleteAndStartOver(); @@ -1268,7 +1267,7 @@ ServiceWorkerStorage::FindInstallingRegistrationForPattern(const GURL& scope) { } ServiceWorkerRegistration* -ServiceWorkerStorage::FindInstallingRegistrationForId(int64 registration_id) { +ServiceWorkerStorage::FindInstallingRegistrationForId(int64_t registration_id) { RegistrationRefsById::const_iterator found = installing_registrations_.find(registration_id); if (found == installing_registrations_.end()) @@ -1315,17 +1314,17 @@ void ServiceWorkerStorage::OnDiskCacheInitialized(int rv) { } void ServiceWorkerStorage::StartPurgingResources( - const std::set<int64>& resource_ids) { + const std::set<int64_t>& resource_ids) { DCHECK(has_checked_for_stale_resources_); - for (int64 resource_id : resource_ids) + for (int64_t resource_id : resource_ids) purgeable_resource_ids_.push_back(resource_id); ContinuePurgingResources(); } void ServiceWorkerStorage::StartPurgingResources( - const std::vector<int64>& resource_ids) { + const std::vector<int64_t>& resource_ids) { DCHECK(has_checked_for_stale_resources_); - for (int64 resource_id : resource_ids) + for (int64_t resource_id : resource_ids) purgeable_resource_ids_.push_back(resource_id); ContinuePurgingResources(); } @@ -1345,14 +1344,14 @@ void ServiceWorkerStorage::ContinuePurgingResources() { // Do one at a time until we're done, use RunSoon to avoid recursion when // DoomEntry returns immediately. is_purge_pending_ = true; - int64 id = purgeable_resource_ids_.front(); + int64_t id = purgeable_resource_ids_.front(); purgeable_resource_ids_.pop_front(); RunSoon(FROM_HERE, base::Bind(&ServiceWorkerStorage::PurgeResource, weak_factory_.GetWeakPtr(), id)); } -void ServiceWorkerStorage::PurgeResource(int64 id) { +void ServiceWorkerStorage::PurgeResource(int64_t id) { DCHECK(is_purge_pending_); int rv = disk_cache()->DoomEntry( id, base::Bind(&ServiceWorkerStorage::OnResourcePurged, @@ -1361,7 +1360,7 @@ void ServiceWorkerStorage::PurgeResource(int64 id) { OnResourcePurged(id, rv); } -void ServiceWorkerStorage::OnResourcePurged(int64 id, int rv) { +void ServiceWorkerStorage::OnResourcePurged(int64_t id, int rv) { DCHECK(is_purge_pending_); is_purge_pending_ = false; @@ -1369,10 +1368,9 @@ void ServiceWorkerStorage::OnResourcePurged(int64 id, int rv) { database_task_manager_->GetTaskRunner()->PostTask( FROM_HERE, - base::Bind(base::IgnoreResult( - &ServiceWorkerDatabase::ClearPurgeableResourceIds), - base::Unretained(database_.get()), - std::set<int64>(&id, &id + 1))); + base::Bind( + base::IgnoreResult(&ServiceWorkerDatabase::ClearPurgeableResourceIds), + base::Unretained(database_.get()), std::set<int64_t>(&id, &id + 1))); // Continue purging resources regardless of the previous result. ContinuePurgingResources(); @@ -1391,7 +1389,7 @@ void ServiceWorkerStorage::DeleteStaleResources() { } void ServiceWorkerStorage::DidCollectStaleResources( - const std::vector<int64>& stale_resource_ids, + const std::vector<int64_t>& stale_resource_ids, ServiceWorkerDatabase::Status status) { if (status != ServiceWorkerDatabase::STATUS_OK) { DCHECK_NE(ServiceWorkerDatabase::STATUS_ERROR_NOT_FOUND, status); @@ -1426,14 +1424,14 @@ void ServiceWorkerStorage::CollectStaleResourcesFromDB( ServiceWorkerDatabase* database, scoped_refptr<base::SequencedTaskRunner> original_task_runner, const GetResourcesCallback& callback) { - std::set<int64> ids; + std::set<int64_t> ids; ServiceWorkerDatabase::Status status = database->GetUncommittedResourceIds(&ids); if (status != ServiceWorkerDatabase::STATUS_OK) { original_task_runner->PostTask( FROM_HERE, - base::Bind( - callback, std::vector<int64>(ids.begin(), ids.end()), status)); + base::Bind(callback, std::vector<int64_t>(ids.begin(), ids.end()), + status)); return; } @@ -1441,8 +1439,8 @@ void ServiceWorkerStorage::CollectStaleResourcesFromDB( if (status != ServiceWorkerDatabase::STATUS_OK) { original_task_runner->PostTask( FROM_HERE, - base::Bind( - callback, std::vector<int64>(ids.begin(), ids.end()), status)); + base::Bind(callback, std::vector<int64_t>(ids.begin(), ids.end()), + status)); return; } @@ -1450,7 +1448,8 @@ void ServiceWorkerStorage::CollectStaleResourcesFromDB( status = database->GetPurgeableResourceIds(&ids); original_task_runner->PostTask( FROM_HERE, - base::Bind(callback, std::vector<int64>(ids.begin(), ids.end()), status)); + base::Bind(callback, std::vector<int64_t>(ids.begin(), ids.end()), + status)); } void ServiceWorkerStorage::ReadInitialDataFromDB( @@ -1487,19 +1486,19 @@ void ServiceWorkerStorage::ReadInitialDataFromDB( void ServiceWorkerStorage::DeleteRegistrationFromDB( ServiceWorkerDatabase* database, scoped_refptr<base::SequencedTaskRunner> original_task_runner, - int64 registration_id, + int64_t registration_id, const GURL& origin, const DeleteRegistrationCallback& callback) { DCHECK(database); ServiceWorkerDatabase::RegistrationData deleted_version; - std::vector<int64> newly_purgeable_resources; + std::vector<int64_t> newly_purgeable_resources; ServiceWorkerDatabase::Status status = database->DeleteRegistration( registration_id, origin, &deleted_version, &newly_purgeable_resources); if (status != ServiceWorkerDatabase::STATUS_OK) { original_task_runner->PostTask( FROM_HERE, base::Bind(callback, OriginState::KEEP_ALL, deleted_version, - std::vector<int64>(), status)); + std::vector<int64_t>(), status)); return; } @@ -1510,7 +1509,7 @@ void ServiceWorkerStorage::DeleteRegistrationFromDB( if (status != ServiceWorkerDatabase::STATUS_OK) { original_task_runner->PostTask( FROM_HERE, base::Bind(callback, OriginState::KEEP_ALL, deleted_version, - std::vector<int64>(), status)); + std::vector<int64_t>(), status)); return; } @@ -1539,7 +1538,7 @@ void ServiceWorkerStorage::WriteRegistrationInDB( const WriteRegistrationCallback& callback) { DCHECK(database); ServiceWorkerDatabase::RegistrationData deleted_version; - std::vector<int64> newly_purgeable_resources; + std::vector<int64_t> newly_purgeable_resources; ServiceWorkerDatabase::Status status = database->WriteRegistration( data, resources, &deleted_version, &newly_purgeable_resources); original_task_runner->PostTask(FROM_HERE, @@ -1575,7 +1574,7 @@ void ServiceWorkerStorage::FindForDocumentInDB( // Find one with a pattern match. LongestScopeMatcher matcher(document_url); - int64 match = kInvalidServiceWorkerRegistrationId; + int64_t match = kInvalidServiceWorkerRegistrationId; for (const auto& registration_data : registration_data_list) if (matcher.MatchLongest(registration_data.scope)) match = registration_data.registration_id; @@ -1626,7 +1625,7 @@ void ServiceWorkerStorage::FindForPatternInDB( void ServiceWorkerStorage::FindForIdInDB( ServiceWorkerDatabase* database, scoped_refptr<base::SequencedTaskRunner> original_task_runner, - int64 registration_id, + int64_t registration_id, const GURL& origin, const FindInDBCallback& callback) { ServiceWorkerDatabase::RegistrationData data; @@ -1640,7 +1639,7 @@ void ServiceWorkerStorage::FindForIdInDB( void ServiceWorkerStorage::FindForIdOnlyInDB( ServiceWorkerDatabase* database, scoped_refptr<base::SequencedTaskRunner> original_task_runner, - int64 registration_id, + int64_t registration_id, const FindInDBCallback& callback) { GURL origin; ServiceWorkerDatabase::Status status = @@ -1659,7 +1658,7 @@ void ServiceWorkerStorage::FindForIdOnlyInDB( void ServiceWorkerStorage::GetUserDataInDB( ServiceWorkerDatabase* database, scoped_refptr<base::SequencedTaskRunner> original_task_runner, - int64 registration_id, + int64_t registration_id, const std::string& key, const GetUserDataInDBCallback& callback) { std::string data; @@ -1674,7 +1673,7 @@ void ServiceWorkerStorage::GetUserDataForAllRegistrationsInDB( scoped_refptr<base::SequencedTaskRunner> original_task_runner, const std::string& key, const GetUserDataForAllRegistrationsInDBCallback& callback) { - std::vector<std::pair<int64, std::string>> user_data; + std::vector<std::pair<int64_t, std::string>> user_data; ServiceWorkerDatabase::Status status = database->ReadUserDataForAllRegistrations(key, &user_data); original_task_runner->PostTask(FROM_HERE, @@ -1686,7 +1685,7 @@ void ServiceWorkerStorage::DeleteAllDataForOriginsFromDB( const std::set<GURL>& origins) { DCHECK(database); - std::vector<int64> newly_purgeable_resources; + std::vector<int64_t> newly_purgeable_resources; database->DeleteAllDataForOrigins(origins, &newly_purgeable_resources); } diff --git a/content/browser/service_worker/service_worker_storage.h b/content/browser/service_worker/service_worker_storage.h index 7317a63..92042de 100644 --- a/content/browser/service_worker/service_worker_storage.h +++ b/content/browser/service_worker/service_worker_storage.h @@ -5,6 +5,8 @@ #ifndef CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_STORAGE_H_ #define CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_STORAGE_H_ +#include <stdint.h> + #include <deque> #include <map> #include <set> @@ -14,6 +16,7 @@ #include "base/bind.h" #include "base/files/file_path.h" #include "base/gtest_prod_util.h" +#include "base/macros.h" #include "base/memory/weak_ptr.h" #include "content/browser/service_worker/service_worker_database.h" #include "content/browser/service_worker/service_worker_database_task_manager.h" @@ -63,9 +66,8 @@ class CONTENT_EXPORT ServiceWorkerStorage void(const std::string& data, ServiceWorkerStatusCode status)> GetUserDataCallback; typedef base::Callback<void( - const std::vector<std::pair<int64, std::string>>& user_data, - ServiceWorkerStatusCode status)> - GetUserDataForAllRegistrationsCallback; + const std::vector<std::pair<int64_t, std::string>>& user_data, + ServiceWorkerStatusCode status)> GetUserDataForAllRegistrationsCallback; ~ServiceWorkerStorage() override; @@ -95,7 +97,7 @@ class CONTENT_EXPORT ServiceWorkerStorage const FindRegistrationCallback& callback); void FindRegistrationForPattern(const GURL& scope, const FindRegistrationCallback& callback); - void FindRegistrationForId(int64 registration_id, + void FindRegistrationForId(int64_t registration_id, const GURL& origin, const FindRegistrationCallback& callback); @@ -104,7 +106,7 @@ class CONTENT_EXPORT ServiceWorkerStorage // is all that is available this method can be used instead. // Like |FindRegistrationForId| this method may complete immediately (the // callback may be called prior to the method returning) or asynchronously. - void FindRegistrationForIdOnly(int64 registration_id, + void FindRegistrationForIdOnly(int64_t registration_id, const FindRegistrationCallback& callback); ServiceWorkerRegistration* GetUninstallingRegistration(const GURL& scope); @@ -136,38 +138,38 @@ class CONTENT_EXPORT ServiceWorkerStorage // Deletes the registration data for |registration_id|. If the registration's // version is live, its script resources will remain available. // PurgeResources should be called when it's OK to delete them. - void DeleteRegistration(int64 registration_id, + void DeleteRegistration(int64_t registration_id, const GURL& origin, const StatusCallback& callback); scoped_ptr<ServiceWorkerResponseReader> CreateResponseReader( - int64 resource_id); + int64_t resource_id); scoped_ptr<ServiceWorkerResponseWriter> CreateResponseWriter( - int64 resource_id); + int64_t resource_id); scoped_ptr<ServiceWorkerResponseMetadataWriter> CreateResponseMetadataWriter( - int64 resource_id); + int64_t resource_id); // Adds |resource_id| to the set of resources that are in the disk cache // but not yet stored with a registration. - void StoreUncommittedResourceId(int64 resource_id); + void StoreUncommittedResourceId(int64_t resource_id); // Removes resource ids from uncommitted list, adds them to the purgeable list // and purges them. - void DoomUncommittedResource(int64 resource_id); - void DoomUncommittedResources(const std::set<int64>& resource_ids); + void DoomUncommittedResource(int64_t resource_id); + void DoomUncommittedResources(const std::set<int64_t>& resource_ids); // Provide a storage mechanism to read/write arbitrary data associated with // a registration. Each registration has its own key namespace. Stored data // is deleted when the associated registraton is deleted. - void GetUserData(int64 registration_id, + void GetUserData(int64_t registration_id, const std::string& key, const GetUserDataCallback& callback); - void StoreUserData(int64 registration_id, + void StoreUserData(int64_t registration_id, const GURL& origin, const std::string& key, const std::string& data, const StatusCallback& callback); - void ClearUserData(int64 registration_id, + void ClearUserData(int64_t registration_id, const std::string& key, const StatusCallback& callback); // Returns all registrations that have user data with a particular key, as @@ -186,15 +188,15 @@ class CONTENT_EXPORT ServiceWorkerStorage // Returns a new registration id which is guaranteed to be unique in the // storage. Returns kInvalidServiceWorkerRegistrationId if the storage is // disabled. - int64 NewRegistrationId(); + int64_t NewRegistrationId(); // Returns a new version id which is guaranteed to be unique in the storage. // Returns kInvalidServiceWorkerVersionId if the storage is disabled. - int64 NewVersionId(); + int64_t NewVersionId(); // Returns a new resource id which is guaranteed to be unique in the storage. // Returns kInvalidServiceWorkerResourceId if the storage is disabled. - int64 NewResourceId(); + int64_t NewResourceId(); // Intended for use only by ServiceWorkerRegisterJob and // ServiceWorkerRegistration. @@ -248,9 +250,9 @@ class CONTENT_EXPORT ServiceWorkerStorage DeleteAndStartOver_OpenedFileExists); struct InitialData { - int64 next_registration_id; - int64 next_version_id; - int64 next_resource_id; + int64_t next_registration_id; + int64_t next_version_id; + int64_t next_resource_id; std::set<GURL> origins; std::set<GURL> foreign_fetch_origins; @@ -260,7 +262,7 @@ class CONTENT_EXPORT ServiceWorkerStorage // Because there are too many params for base::Bind to wrap a closure around. struct DidDeleteRegistrationParams { - int64 registration_id; + int64_t registration_id; GURL origin; StatusCallback callback; @@ -279,7 +281,7 @@ class CONTENT_EXPORT ServiceWorkerStorage }; typedef std::vector<ServiceWorkerDatabase::RegistrationData> RegistrationList; - typedef std::map<int64, scoped_refptr<ServiceWorkerRegistration> > + typedef std::map<int64_t, scoped_refptr<ServiceWorkerRegistration>> RegistrationRefsById; typedef base::Callback<void(scoped_ptr<InitialData> data, ServiceWorkerDatabase::Status status)> @@ -289,12 +291,12 @@ class CONTENT_EXPORT ServiceWorkerStorage typedef base::Callback<void( const GURL& origin, const ServiceWorkerDatabase::RegistrationData& deleted_version_data, - const std::vector<int64>& newly_purgeable_resources, + const std::vector<int64_t>& newly_purgeable_resources, ServiceWorkerDatabase::Status status)> WriteRegistrationCallback; typedef base::Callback<void( OriginState origin_state, const ServiceWorkerDatabase::RegistrationData& deleted_version_data, - const std::vector<int64>& newly_purgeable_resources, + const std::vector<int64_t>& newly_purgeable_resources, ServiceWorkerDatabase::Status status)> DeleteRegistrationCallback; typedef base::Callback<void( const ServiceWorkerDatabase::RegistrationData& data, @@ -304,10 +306,10 @@ class CONTENT_EXPORT ServiceWorkerStorage const std::string& data, ServiceWorkerDatabase::Status)> GetUserDataInDBCallback; typedef base::Callback<void( - const std::vector<std::pair<int64, std::string>>& user_data, + const std::vector<std::pair<int64_t, std::string>>& user_data, ServiceWorkerDatabase::Status)> GetUserDataForAllRegistrationsInDBCallback; - typedef base::Callback<void(const std::vector<int64>& resource_ids, + typedef base::Callback<void(const std::vector<int64_t>& resource_ids, ServiceWorkerDatabase::Status status)> GetResourcesCallback; @@ -329,7 +331,7 @@ class CONTENT_EXPORT ServiceWorkerStorage void DidFindRegistrationForDocument( const GURL& document_url, const FindRegistrationCallback& callback, - int64 callback_id, + int64_t callback_id, const ServiceWorkerDatabase::RegistrationData& data, const ResourceList& resources, ServiceWorkerDatabase::Status status); @@ -358,7 +360,7 @@ class CONTENT_EXPORT ServiceWorkerStorage const ServiceWorkerDatabase::RegistrationData& new_version, const GURL& origin, const ServiceWorkerDatabase::RegistrationData& deleted_version, - const std::vector<int64>& newly_purgeable_resources, + const std::vector<int64_t>& newly_purgeable_resources, ServiceWorkerDatabase::Status status); void DidUpdateToActiveState( const StatusCallback& callback, @@ -367,10 +369,10 @@ class CONTENT_EXPORT ServiceWorkerStorage const DidDeleteRegistrationParams& params, OriginState origin_state, const ServiceWorkerDatabase::RegistrationData& deleted_version, - const std::vector<int64>& newly_purgeable_resources, + const std::vector<int64_t>& newly_purgeable_resources, ServiceWorkerDatabase::Status status); void DidWriteUncommittedResourceIds(ServiceWorkerDatabase::Status status); - void DidPurgeUncommittedResourceIds(const std::set<int64>& resource_ids, + void DidPurgeUncommittedResourceIds(const std::set<int64_t>& resource_ids, ServiceWorkerDatabase::Status status); void DidStoreUserData( const StatusCallback& callback, @@ -384,7 +386,7 @@ class CONTENT_EXPORT ServiceWorkerStorage ServiceWorkerDatabase::Status status); void DidGetUserDataForAllRegistrations( const GetUserDataForAllRegistrationsCallback& callback, - const std::vector<std::pair<int64, std::string>>& user_data, + const std::vector<std::pair<int64_t, std::string>>& user_data, ServiceWorkerDatabase::Status status); void ReturnFoundRegistration( const FindRegistrationCallback& callback, @@ -399,25 +401,25 @@ class CONTENT_EXPORT ServiceWorkerStorage ServiceWorkerRegistration* FindInstallingRegistrationForPattern( const GURL& scope); ServiceWorkerRegistration* FindInstallingRegistrationForId( - int64 registration_id); + int64_t registration_id); // Lazy disk_cache getter. ServiceWorkerDiskCache* disk_cache(); void InitializeDiskCache(); void OnDiskCacheInitialized(int rv); - void StartPurgingResources(const std::set<int64>& resource_ids); - void StartPurgingResources(const std::vector<int64>& resource_ids); + void StartPurgingResources(const std::set<int64_t>& resource_ids); + void StartPurgingResources(const std::vector<int64_t>& resource_ids); void StartPurgingResources(const ResourceList& resources); void ContinuePurgingResources(); - void PurgeResource(int64 id); - void OnResourcePurged(int64 id, int rv); + void PurgeResource(int64_t id); + void OnResourcePurged(int64_t id, int rv); // Deletes purgeable and uncommitted resources left over from the previous // browser session. This must be called once per session before any database // operation that may mutate the purgeable or uncommitted resource lists. void DeleteStaleResources(); - void DidCollectStaleResources(const std::vector<int64>& stale_resource_ids, + void DidCollectStaleResources(const std::vector<int64_t>& stale_resource_ids, ServiceWorkerDatabase::Status status); void ClearSessionOnlyOrigins(); @@ -434,7 +436,7 @@ class CONTENT_EXPORT ServiceWorkerStorage static void DeleteRegistrationFromDB( ServiceWorkerDatabase* database, scoped_refptr<base::SequencedTaskRunner> original_task_runner, - int64 registration_id, + int64_t registration_id, const GURL& origin, const DeleteRegistrationCallback& callback); static void WriteRegistrationInDB( @@ -456,18 +458,18 @@ class CONTENT_EXPORT ServiceWorkerStorage static void FindForIdInDB( ServiceWorkerDatabase* database, scoped_refptr<base::SequencedTaskRunner> original_task_runner, - int64 registration_id, + int64_t registration_id, const GURL& origin, const FindInDBCallback& callback); static void FindForIdOnlyInDB( ServiceWorkerDatabase* database, scoped_refptr<base::SequencedTaskRunner> original_task_runner, - int64 registration_id, + int64_t registration_id, const FindInDBCallback& callback); static void GetUserDataInDB( ServiceWorkerDatabase* database, scoped_refptr<base::SequencedTaskRunner> original_task_runner, - int64 registration_id, + int64_t registration_id, const std::string& key, const GetUserDataInDBCallback& callback); static void GetUserDataForAllRegistrationsInDB( @@ -498,9 +500,9 @@ class CONTENT_EXPORT ServiceWorkerStorage // Pending database tasks waiting for initialization. std::vector<base::Closure> pending_tasks_; - int64 next_registration_id_; - int64 next_version_id_; - int64 next_resource_id_; + int64_t next_registration_id_; + int64_t next_version_id_; + int64_t next_resource_id_; enum State { UNINITIALIZED, @@ -525,10 +527,10 @@ class CONTENT_EXPORT ServiceWorkerStorage scoped_ptr<ServiceWorkerDiskCache> disk_cache_; - std::deque<int64> purgeable_resource_ids_; + std::deque<int64_t> purgeable_resource_ids_; bool is_purge_pending_; bool has_checked_for_stale_resources_; - std::set<int64> pending_deletions_; + std::set<int64_t> pending_deletions_; base::WeakPtrFactory<ServiceWorkerStorage> weak_factory_; diff --git a/content/browser/service_worker/service_worker_storage_unittest.cc b/content/browser/service_worker/service_worker_storage_unittest.cc index 8e65963..2cc2c49 100644 --- a/content/browser/service_worker/service_worker_storage_unittest.cc +++ b/content/browser/service_worker/service_worker_storage_unittest.cc @@ -2,13 +2,17 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. +#include <stdint.h> + #include <string> #include "base/files/file_util.h" #include "base/files/scoped_temp_dir.h" #include "base/logging.h" +#include "base/macros.h" #include "base/run_loop.h" #include "base/thread_task_runner_handle.h" +#include "build/build_config.h" #include "content/browser/browser_thread_impl.h" #include "content/browser/service_worker/service_worker_context_core.h" #include "content/browser/service_worker/service_worker_disk_cache.h" @@ -116,19 +120,20 @@ void GetUserDataCallback( void GetUserDataForAllRegistrationsCallback( bool* was_called, - std::vector<std::pair<int64, std::string>>* data_out, + std::vector<std::pair<int64_t, std::string>>* data_out, ServiceWorkerStatusCode* status_out, - const std::vector<std::pair<int64, std::string>>& data, + const std::vector<std::pair<int64_t, std::string>>& data, ServiceWorkerStatusCode status) { *was_called = true; *data_out = data; *status_out = status; } -void WriteResponse( - ServiceWorkerStorage* storage, int64 id, - const std::string& headers, - IOBuffer* body, int length) { +void WriteResponse(ServiceWorkerStorage* storage, + int64_t id, + const std::string& headers, + IOBuffer* body, + int length) { scoped_ptr<ServiceWorkerResponseWriter> writer = storage->CreateResponseWriter(id); @@ -153,15 +158,15 @@ void WriteResponse( } } -void WriteStringResponse( - ServiceWorkerStorage* storage, int64 id, - const std::string& headers, - const std::string& body) { +void WriteStringResponse(ServiceWorkerStorage* storage, + int64_t id, + const std::string& headers, + const std::string& body) { scoped_refptr<IOBuffer> body_buffer(new WrappedIOBuffer(body.data())); WriteResponse(storage, id, headers, body_buffer.get(), body.length()); } -void WriteBasicResponse(ServiceWorkerStorage* storage, int64 id) { +void WriteBasicResponse(ServiceWorkerStorage* storage, int64_t id) { scoped_ptr<ServiceWorkerResponseWriter> writer = storage->CreateResponseWriter(id); @@ -171,7 +176,8 @@ void WriteBasicResponse(ServiceWorkerStorage* storage, int64 id) { WriteStringResponse(storage, id, headers, std::string(kHttpBody)); } -bool VerifyBasicResponse(ServiceWorkerStorage* storage, int64 id, +bool VerifyBasicResponse(ServiceWorkerStorage* storage, + int64_t id, bool expected_positive_result) { const std::string kExpectedHttpBody("Hello"); scoped_ptr<ServiceWorkerResponseReader> reader = @@ -212,7 +218,7 @@ bool VerifyBasicResponse(ServiceWorkerStorage* storage, int64 id, } int WriteResponseMetadata(ServiceWorkerStorage* storage, - int64 id, + int64_t id, const std::string& metadata) { scoped_refptr<IOBuffer> body_buffer(new WrappedIOBuffer(metadata.data())); scoped_ptr<ServiceWorkerResponseMetadataWriter> metadata_writer = @@ -241,7 +247,7 @@ int ClearMetadata(ServiceWorkerVersion* version, const GURL& url) { } bool VerifyResponseMetadata(ServiceWorkerStorage* storage, - int64 id, + int64_t id, const std::string& expected_metadata) { scoped_ptr<ServiceWorkerResponseReader> reader = storage->CreateResponseReader(id); @@ -297,7 +303,7 @@ class ServiceWorkerStorageTest : public testing::Test { // A static class method for friendliness. static void VerifyPurgeableListStatusCallback( ServiceWorkerDatabase* database, - std::set<int64> *purgeable_ids, + std::set<int64_t>* purgeable_ids, bool* was_called, ServiceWorkerStatusCode* result, ServiceWorkerStatusCode status) { @@ -327,9 +333,8 @@ class ServiceWorkerStorageTest : public testing::Test { return result; } - ServiceWorkerStatusCode DeleteRegistration( - int64 registration_id, - const GURL& origin) { + ServiceWorkerStatusCode DeleteRegistration(int64_t registration_id, + const GURL& origin) { bool was_called = false; ServiceWorkerStatusCode result = SERVICE_WORKER_ERROR_FAILED; storage()->DeleteRegistration( @@ -361,10 +366,9 @@ class ServiceWorkerStorageTest : public testing::Test { EXPECT_TRUE(was_called); } - ServiceWorkerStatusCode GetUserData( - int64 registration_id, - const std::string& key, - std::string* data) { + ServiceWorkerStatusCode GetUserData(int64_t registration_id, + const std::string& key, + std::string* data) { bool was_called = false; ServiceWorkerStatusCode result = SERVICE_WORKER_ERROR_FAILED; storage()->GetUserData( @@ -376,11 +380,10 @@ class ServiceWorkerStorageTest : public testing::Test { return result; } - ServiceWorkerStatusCode StoreUserData( - int64 registration_id, - const GURL& origin, - const std::string& key, - const std::string& data) { + ServiceWorkerStatusCode StoreUserData(int64_t registration_id, + const GURL& origin, + const std::string& key, + const std::string& data) { bool was_called = false; ServiceWorkerStatusCode result = SERVICE_WORKER_ERROR_FAILED; storage()->StoreUserData( @@ -392,9 +395,8 @@ class ServiceWorkerStorageTest : public testing::Test { return result; } - ServiceWorkerStatusCode ClearUserData( - int64 registration_id, - const std::string& key) { + ServiceWorkerStatusCode ClearUserData(int64_t registration_id, + const std::string& key) { bool was_called = false; ServiceWorkerStatusCode result = SERVICE_WORKER_ERROR_FAILED; storage()->ClearUserData( @@ -407,7 +409,7 @@ class ServiceWorkerStorageTest : public testing::Test { ServiceWorkerStatusCode GetUserDataForAllRegistrations( const std::string& key, - std::vector<std::pair<int64, std::string>>* data) { + std::vector<std::pair<int64_t, std::string>>* data) { bool was_called = false; ServiceWorkerStatusCode result = SERVICE_WORKER_ERROR_FAILED; storage()->GetUserDataForAllRegistrations( @@ -462,7 +464,7 @@ class ServiceWorkerStorageTest : public testing::Test { } ServiceWorkerStatusCode FindRegistrationForId( - int64 registration_id, + int64_t registration_id, const GURL& origin, scoped_refptr<ServiceWorkerRegistration>* registration) { bool was_called = false; @@ -476,7 +478,7 @@ class ServiceWorkerStorageTest : public testing::Test { } ServiceWorkerStatusCode FindRegistrationForIdOnly( - int64 registration_id, + int64_t registration_id, scoped_refptr<ServiceWorkerRegistration>* registration) { bool was_called = false; ServiceWorkerStatusCode result = SERVICE_WORKER_ERROR_FAILED; @@ -499,11 +501,11 @@ TEST_F(ServiceWorkerStorageTest, StoreFindUpdateDeleteRegistration) { const GURL kScript("http://www.test.not/script.js"); const GURL kDocumentUrl("http://www.test.not/scope/document.html"); const GURL kResource1("http://www.test.not/scope/resource1.js"); - const int64 kResource1Size = 1591234; + const int64_t kResource1Size = 1591234; const GURL kResource2("http://www.test.not/scope/resource2.js"); - const int64 kResource2Size = 51; - const int64 kRegistrationId = 0; - const int64 kVersionId = 0; + const int64_t kResource2Size = 51; + const int64_t kRegistrationId = 0; + const int64_t kVersionId = 0; const GURL kForeignFetchScope("http://www.test.not/scope/ff/"); const base::Time kToday = base::Time::Now(); const base::Time kYesterday = kToday - base::TimeDelta::FromDays(1); @@ -689,8 +691,8 @@ TEST_F(ServiceWorkerStorageTest, InstallingRegistrationsAreFindable) { const GURL kScope("http://www.test.not/scope/"); const GURL kScript("http://www.test.not/script.js"); const GURL kDocumentUrl("http://www.test.not/scope/document.html"); - const int64 kRegistrationId = 0; - const int64 kVersionId = 0; + const int64_t kRegistrationId = 0; + const int64_t kVersionId = 0; scoped_refptr<ServiceWorkerRegistration> found_registration; @@ -809,8 +811,8 @@ TEST_F(ServiceWorkerStorageTest, InstallingRegistrationsAreFindable) { TEST_F(ServiceWorkerStorageTest, StoreUserData) { const GURL kScope("http://www.test.not/scope/"); const GURL kScript("http://www.test.not/script.js"); - const int64 kRegistrationId = 0; - const int64 kVersionId = 0; + const int64_t kRegistrationId = 0; + const int64_t kVersionId = 0; LazyInitialize(); @@ -838,7 +840,7 @@ TEST_F(ServiceWorkerStorageTest, StoreUserData) { EXPECT_EQ("data", data_out); EXPECT_EQ(SERVICE_WORKER_ERROR_NOT_FOUND, GetUserData(kRegistrationId, "unknown_key", &data_out)); - std::vector<std::pair<int64, std::string>> data_list_out; + std::vector<std::pair<int64_t, std::string>> data_list_out; EXPECT_EQ(SERVICE_WORKER_OK, GetUserDataForAllRegistrations("key", &data_list_out)); ASSERT_EQ(1u, data_list_out.size()); @@ -927,7 +929,7 @@ class ServiceWorkerResourceStorageTest : public ServiceWorkerStorageTest { storage()->StoreUncommittedResourceId(resource_id1_); storage()->StoreUncommittedResourceId(resource_id2_); base::RunLoop().RunUntilIdle(); - std::set<int64> verify_ids; + std::set<int64_t> verify_ids; EXPECT_EQ(ServiceWorkerDatabase::STATUS_OK, storage()->database_->GetUncommittedResourceIds(&verify_ids)); EXPECT_EQ(2u, verify_ids.size()); @@ -954,12 +956,12 @@ class ServiceWorkerResourceStorageTest : public ServiceWorkerStorageTest { GURL script_; GURL import_; GURL document_url_; - int64 registration_id_; - int64 version_id_; - int64 resource_id1_; - uint64 resource_id1_size_; - int64 resource_id2_; - uint64 resource_id2_size_; + int64_t registration_id_; + int64_t version_id_; + int64_t resource_id1_; + uint64_t resource_id1_size_; + int64_t resource_id2_; + uint64_t resource_id2_size_; scoped_refptr<ServiceWorkerRegistration> registration_; }; @@ -977,7 +979,7 @@ TEST_F(ServiceWorkerResourceStorageTest, WriteMetadataWithServiceWorkerResponseMetadataWriter) { const char kMetadata1[] = "Test metadata"; const char kMetadata2[] = "small"; - int64 new_resource_id_ = storage()->NewResourceId(); + int64_t new_resource_id_ = storage()->NewResourceId(); // Writing metadata to nonexistent resoirce ID must fail. EXPECT_GE(0, WriteResponseMetadata(storage(), new_resource_id_, kMetadata1)); @@ -1035,7 +1037,7 @@ TEST_F(ServiceWorkerResourceStorageTest, TEST_F(ServiceWorkerResourceStorageTest, DeleteRegistration_NoLiveVersion) { bool was_called = false; ServiceWorkerStatusCode result = SERVICE_WORKER_ERROR_FAILED; - std::set<int64> verify_ids; + std::set<int64_t> verify_ids; registration_->SetWaitingVersion(NULL); registration_ = NULL; @@ -1067,7 +1069,7 @@ TEST_F(ServiceWorkerResourceStorageTest, DeleteRegistration_NoLiveVersion) { TEST_F(ServiceWorkerResourceStorageTest, DeleteRegistration_WaitingVersion) { bool was_called = false; ServiceWorkerStatusCode result = SERVICE_WORKER_ERROR_FAILED; - std::set<int64> verify_ids; + std::set<int64_t> verify_ids; // Deleting the registration should result in the resources being added to the // purgeable list and then doomed in the disk cache and removed from that @@ -1119,7 +1121,7 @@ TEST_F(ServiceWorkerResourceStorageTest, DeleteRegistration_ActiveVersion) { bool was_called = false; ServiceWorkerStatusCode result = SERVICE_WORKER_ERROR_FAILED; - std::set<int64> verify_ids; + std::set<int64_t> verify_ids; // Deleting the registration should move the resources to the purgeable list // but keep them available. @@ -1170,7 +1172,7 @@ TEST_F(ServiceWorkerResourceStorageDiskTest, CleanupOnRestart) { bool was_called = false; ServiceWorkerStatusCode result = SERVICE_WORKER_ERROR_FAILED; - std::set<int64> verify_ids; + std::set<int64_t> verify_ids; // Deleting the registration should move the resources to the purgeable list // but keep them available. @@ -1195,7 +1197,7 @@ TEST_F(ServiceWorkerResourceStorageDiskTest, CleanupOnRestart) { EXPECT_TRUE(VerifyBasicResponse(storage(), resource_id2_, true)); // Also add an uncommitted resource. - int64 kStaleUncommittedResourceId = storage()->NewResourceId(); + int64_t kStaleUncommittedResourceId = storage()->NewResourceId(); storage()->StoreUncommittedResourceId(kStaleUncommittedResourceId); base::RunLoop().RunUntilIdle(); verify_ids.clear(); @@ -1224,7 +1226,7 @@ TEST_F(ServiceWorkerResourceStorageDiskTest, CleanupOnRestart) { base::RunLoop().RunUntilIdle(); // Store a new uncommitted resource. This triggers stale resource cleanup. - int64 kNewResourceId = storage()->NewResourceId(); + int64_t kNewResourceId = storage()->NewResourceId(); WriteBasicResponse(storage(), kNewResourceId); storage()->StoreUncommittedResourceId(kNewResourceId); base::RunLoop().RunUntilIdle(); @@ -1341,7 +1343,7 @@ TEST_F(ServiceWorkerResourceStorageTest, UpdateRegistration) { bool was_called = false; ServiceWorkerStatusCode result = SERVICE_WORKER_ERROR_FAILED; - std::set<int64> verify_ids; + std::set<int64_t> verify_ids; // Make an updated registration. scoped_refptr<ServiceWorkerVersion> live_version = new ServiceWorkerVersion( @@ -1396,8 +1398,8 @@ TEST_F(ServiceWorkerStorageTest, FindRegistration_LongestScopeMatch) { // Registration for "/scope/". const GURL kScope1("http://www.example.com/scope/"); const GURL kScript1("http://www.example.com/script1.js"); - const int64 kRegistrationId1 = 1; - const int64 kVersionId1 = 1; + const int64_t kRegistrationId1 = 1; + const int64_t kVersionId1 = 1; scoped_refptr<ServiceWorkerRegistration> live_registration1 = new ServiceWorkerRegistration( kScope1, kRegistrationId1, context_ptr_); @@ -1414,8 +1416,8 @@ TEST_F(ServiceWorkerStorageTest, FindRegistration_LongestScopeMatch) { // Registration for "/scope/foo". const GURL kScope2("http://www.example.com/scope/foo"); const GURL kScript2("http://www.example.com/script2.js"); - const int64 kRegistrationId2 = 2; - const int64 kVersionId2 = 2; + const int64_t kRegistrationId2 = 2; + const int64_t kVersionId2 = 2; scoped_refptr<ServiceWorkerRegistration> live_registration2 = new ServiceWorkerRegistration( kScope2, kRegistrationId2, context_ptr_); @@ -1432,8 +1434,8 @@ TEST_F(ServiceWorkerStorageTest, FindRegistration_LongestScopeMatch) { // Registration for "/scope/foobar". const GURL kScope3("http://www.example.com/scope/foobar"); const GURL kScript3("http://www.example.com/script3.js"); - const int64 kRegistrationId3 = 3; - const int64 kVersionId3 = 3; + const int64_t kRegistrationId3 = 3; + const int64_t kVersionId3 = 3; scoped_refptr<ServiceWorkerRegistration> live_registration3 = new ServiceWorkerRegistration( kScope3, kRegistrationId3, context_ptr_); @@ -1494,8 +1496,8 @@ TEST_F(ServiceWorkerStorageDiskTest, OriginHasForeignFetchRegistrations) { // Registration 1 for http://www.example.com const GURL kScope1("http://www.example.com/scope/"); const GURL kScript1("http://www.example.com/script1.js"); - const int64 kRegistrationId1 = 1; - const int64 kVersionId1 = 1; + const int64_t kRegistrationId1 = 1; + const int64_t kVersionId1 = 1; scoped_refptr<ServiceWorkerRegistration> live_registration1 = new ServiceWorkerRegistration(kScope1, kRegistrationId1, context_ptr_); scoped_refptr<ServiceWorkerVersion> live_version1 = new ServiceWorkerVersion( @@ -1511,8 +1513,8 @@ TEST_F(ServiceWorkerStorageDiskTest, OriginHasForeignFetchRegistrations) { // Registration 2 for http://www.example.com const GURL kScope2("http://www.example.com/scope/foo"); const GURL kScript2("http://www.example.com/script2.js"); - const int64 kRegistrationId2 = 2; - const int64 kVersionId2 = 2; + const int64_t kRegistrationId2 = 2; + const int64_t kVersionId2 = 2; scoped_refptr<ServiceWorkerRegistration> live_registration2 = new ServiceWorkerRegistration(kScope2, kRegistrationId2, context_ptr_); scoped_refptr<ServiceWorkerVersion> live_version2 = new ServiceWorkerVersion( @@ -1528,8 +1530,8 @@ TEST_F(ServiceWorkerStorageDiskTest, OriginHasForeignFetchRegistrations) { // Registration for http://www.test.com const GURL kScope3("http://www.test.com/scope/foobar"); const GURL kScript3("http://www.test.com/script3.js"); - const int64 kRegistrationId3 = 3; - const int64 kVersionId3 = 3; + const int64_t kRegistrationId3 = 3; + const int64_t kVersionId3 = 3; scoped_refptr<ServiceWorkerRegistration> live_registration3 = new ServiceWorkerRegistration(kScope3, kRegistrationId3, context_ptr_); scoped_refptr<ServiceWorkerVersion> live_version3 = new ServiceWorkerVersion( diff --git a/content/browser/service_worker/service_worker_unregister_job.cc b/content/browser/service_worker/service_worker_unregister_job.cc index 155d9fc..c0fc9dc 100644 --- a/content/browser/service_worker/service_worker_unregister_job.cc +++ b/content/browser/service_worker/service_worker_unregister_job.cc @@ -80,21 +80,21 @@ void ServiceWorkerUnregisterJob::OnRegistrationFound( Complete(registration->id(), SERVICE_WORKER_OK); } -void ServiceWorkerUnregisterJob::Complete(int64 registration_id, +void ServiceWorkerUnregisterJob::Complete(int64_t registration_id, ServiceWorkerStatusCode status) { CompleteInternal(registration_id, status); context_->job_coordinator()->FinishJob(pattern_, this); } void ServiceWorkerUnregisterJob::CompleteInternal( - int64 registration_id, + int64_t registration_id, ServiceWorkerStatusCode status) { if (!is_promise_resolved_) ResolvePromise(registration_id, status); } void ServiceWorkerUnregisterJob::ResolvePromise( - int64 registration_id, + int64_t registration_id, ServiceWorkerStatusCode status) { DCHECK(!is_promise_resolved_); is_promise_resolved_ = true; diff --git a/content/browser/service_worker/service_worker_unregister_job.h b/content/browser/service_worker/service_worker_unregister_job.h index 282167e..a614253 100644 --- a/content/browser/service_worker/service_worker_unregister_job.h +++ b/content/browser/service_worker/service_worker_unregister_job.h @@ -5,8 +5,11 @@ #ifndef CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_UNREGISTER_JOB_H_ #define CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_UNREGISTER_JOB_H_ +#include <stdint.h> + #include <vector> +#include "base/macros.h" #include "base/memory/weak_ptr.h" #include "content/browser/service_worker/service_worker_register_job_base.h" #include "content/common/service_worker/service_worker_status_code.h" @@ -27,7 +30,7 @@ class ServiceWorkerStorage; // ServiceWorkerRegistration itself. class ServiceWorkerUnregisterJob : public ServiceWorkerRegisterJobBase { public: - typedef base::Callback<void(int64 registration_id, + typedef base::Callback<void(int64_t registration_id, ServiceWorkerStatusCode status)> UnregistrationCallback; @@ -49,9 +52,10 @@ class ServiceWorkerUnregisterJob : public ServiceWorkerRegisterJobBase { void OnRegistrationFound( ServiceWorkerStatusCode status, const scoped_refptr<ServiceWorkerRegistration>& registration); - void Complete(int64 registration_id, ServiceWorkerStatusCode status); - void CompleteInternal(int64 registration_id, ServiceWorkerStatusCode status); - void ResolvePromise(int64 registration_id, ServiceWorkerStatusCode status); + void Complete(int64_t registration_id, ServiceWorkerStatusCode status); + void CompleteInternal(int64_t registration_id, + ServiceWorkerStatusCode status); + void ResolvePromise(int64_t registration_id, ServiceWorkerStatusCode status); base::WeakPtr<ServiceWorkerContextCore> context_; const GURL pattern_; diff --git a/content/browser/service_worker/service_worker_url_request_job.cc b/content/browser/service_worker/service_worker_url_request_job.cc index 277d775..919602b 100644 --- a/content/browser/service_worker/service_worker_url_request_job.cc +++ b/content/browser/service_worker/service_worker_url_request_job.cc @@ -4,6 +4,7 @@ #include "content/browser/service_worker/service_worker_url_request_job.h" +#include <stddef.h> #include <stdint.h> #include <limits> diff --git a/content/browser/service_worker/service_worker_url_request_job.h b/content/browser/service_worker/service_worker_url_request_job.h index 8a50a49..ea2860d 100644 --- a/content/browser/service_worker/service_worker_url_request_job.h +++ b/content/browser/service_worker/service_worker_url_request_job.h @@ -5,9 +5,12 @@ #ifndef CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_URL_REQUEST_JOB_H_ #define CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_URL_REQUEST_JOB_H_ +#include <stdint.h> + #include <map> #include <string> +#include "base/macros.h" #include "base/memory/ref_counted.h" #include "base/memory/weak_ptr.h" #include "base/time/time.h" @@ -182,7 +185,7 @@ class CONTENT_EXPORT ServiceWorkerURLRequestJob // Creates BlobDataHandle of the request body from |body_|. This handle // |request_body_blob_data_handle_| will be deleted when // ServiceWorkerURLRequestJob is deleted. - bool CreateRequestBodyBlob(std::string* blob_uuid, uint64* blob_size); + bool CreateRequestBodyBlob(std::string* blob_uuid, uint64_t* blob_size); // For FORWARD_TO_SERVICE_WORKER case. void DidPrepareFetchEvent(); diff --git a/content/browser/service_worker/service_worker_url_request_job_unittest.cc b/content/browser/service_worker/service_worker_url_request_job_unittest.cc index 669e5df..74400a6 100644 --- a/content/browser/service_worker/service_worker_url_request_job_unittest.cc +++ b/content/browser/service_worker/service_worker_url_request_job_unittest.cc @@ -2,10 +2,12 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. +#include <stdint.h> + #include <vector> -#include "base/basictypes.h" #include "base/callback.h" +#include "base/macros.h" #include "base/memory/scoped_ptr.h" #include "base/message_loop/message_loop.h" #include "base/run_loop.h" @@ -490,7 +492,7 @@ TEST_F(ServiceWorkerURLRequestJobTest, DeletedProviderHostBeforeFetchEvent) { // Responds to fetch events with a blob. class BlobResponder : public EmbeddedWorkerTestHelper { public: - BlobResponder(const std::string& blob_uuid, uint64 blob_size) + BlobResponder(const std::string& blob_uuid, uint64_t blob_size) : EmbeddedWorkerTestHelper(base::FilePath()), blob_uuid_(blob_uuid), blob_size_(blob_size) {} @@ -510,7 +512,7 @@ class BlobResponder : public EmbeddedWorkerTestHelper { } std::string blob_uuid_; - uint64 blob_size_; + uint64_t blob_size_; private: DISALLOW_COPY_AND_ASSIGN(BlobResponder); diff --git a/content/browser/service_worker/service_worker_version.cc b/content/browser/service_worker/service_worker_version.cc index 2635365b..10f9de5 100644 --- a/content/browser/service_worker/service_worker_version.cc +++ b/content/browser/service_worker/service_worker_version.cc @@ -4,6 +4,8 @@ #include "content/browser/service_worker/service_worker_version.h" +#include <stddef.h> + #include <algorithm> #include <map> #include <string> @@ -11,6 +13,7 @@ #include "base/command_line.h" #include "base/guid.h" #include "base/location.h" +#include "base/macros.h" #include "base/memory/ref_counted.h" #include "base/metrics/histogram_macros.h" #include "base/single_thread_task_runner.h" @@ -378,7 +381,7 @@ class ServiceWorkerVersion::PingController { ServiceWorkerVersion::ServiceWorkerVersion( ServiceWorkerRegistration* registration, const GURL& script_url, - int64 version_id, + int64_t version_id, base::WeakPtr<ServiceWorkerContextCore> context) : version_id_(version_id), registration_id_(registration->id()), @@ -1464,7 +1467,7 @@ void ServiceWorkerVersion::OnOpenWindowFinished( void ServiceWorkerVersion::OnSetCachedMetadata(const GURL& url, const std::vector<char>& data) { - int64 callback_id = base::TimeTicks::Now().ToInternalValue(); + int64_t callback_id = base::TimeTicks::Now().ToInternalValue(); TRACE_EVENT_ASYNC_BEGIN1("ServiceWorker", "ServiceWorkerVersion::OnSetCachedMetadata", callback_id, "URL", url.spec()); @@ -1473,7 +1476,7 @@ void ServiceWorkerVersion::OnSetCachedMetadata(const GURL& url, weak_factory_.GetWeakPtr(), callback_id)); } -void ServiceWorkerVersion::OnSetCachedMetadataFinished(int64 callback_id, +void ServiceWorkerVersion::OnSetCachedMetadataFinished(int64_t callback_id, int result) { TRACE_EVENT_ASYNC_END1("ServiceWorker", "ServiceWorkerVersion::OnSetCachedMetadata", @@ -1482,7 +1485,7 @@ void ServiceWorkerVersion::OnSetCachedMetadataFinished(int64 callback_id, } void ServiceWorkerVersion::OnClearCachedMetadata(const GURL& url) { - int64 callback_id = base::TimeTicks::Now().ToInternalValue(); + int64_t callback_id = base::TimeTicks::Now().ToInternalValue(); TRACE_EVENT_ASYNC_BEGIN1("ServiceWorker", "ServiceWorkerVersion::OnClearCachedMetadata", callback_id, "URL", url.spec()); @@ -1491,7 +1494,7 @@ void ServiceWorkerVersion::OnClearCachedMetadata(const GURL& url) { weak_factory_.GetWeakPtr(), callback_id)); } -void ServiceWorkerVersion::OnClearCachedMetadataFinished(int64 callback_id, +void ServiceWorkerVersion::OnClearCachedMetadataFinished(int64_t callback_id, int result) { TRACE_EVENT_ASYNC_END1("ServiceWorker", "ServiceWorkerVersion::OnClearCachedMetadata", diff --git a/content/browser/service_worker/service_worker_version.h b/content/browser/service_worker/service_worker_version.h index cbeb655..3575f81 100644 --- a/content/browser/service_worker/service_worker_version.h +++ b/content/browser/service_worker/service_worker_version.h @@ -5,16 +5,18 @@ #ifndef CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_VERSION_H_ #define CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_VERSION_H_ +#include <stdint.h> + #include <map> #include <queue> #include <set> #include <string> #include <vector> -#include "base/basictypes.h" #include "base/callback.h" #include "base/gtest_prod_util.h" #include "base/id_map.h" +#include "base/macros.h" #include "base/memory/ref_counted.h" #include "base/memory/scoped_ptr.h" #include "base/observer_list.h" @@ -127,14 +129,13 @@ class CONTENT_EXPORT ServiceWorkerVersion virtual ~Listener() {} }; - ServiceWorkerVersion( - ServiceWorkerRegistration* registration, - const GURL& script_url, - int64 version_id, - base::WeakPtr<ServiceWorkerContextCore> context); + ServiceWorkerVersion(ServiceWorkerRegistration* registration, + const GURL& script_url, + int64_t version_id, + base::WeakPtr<ServiceWorkerContextCore> context); - int64 version_id() const { return version_id_; } - int64 registration_id() const { return registration_id_; } + int64_t version_id() const { return version_id_; } + int64_t registration_id() const { return registration_id_; } const GURL& script_url() const { return script_url_; } const GURL& scope() const { return scope_; } RunningStatus running_status() const { @@ -486,9 +487,9 @@ class CONTENT_EXPORT ServiceWorkerVersion const ServiceWorkerClientInfo& client_info); void OnSetCachedMetadata(const GURL& url, const std::vector<char>& data); - void OnSetCachedMetadataFinished(int64 callback_id, int result); + void OnSetCachedMetadataFinished(int64_t callback_id, int result); void OnClearCachedMetadata(const GURL& url); - void OnClearCachedMetadataFinished(int64 callback_id, int result); + void OnClearCachedMetadataFinished(int64_t callback_id, int result); void OnPostMessageToClient( const std::string& client_uuid, @@ -597,8 +598,8 @@ class CONTENT_EXPORT ServiceWorkerVersion // event ended). void OnBeginEvent(); - const int64 version_id_; - const int64 registration_id_; + const int64_t version_id_; + const int64_t registration_id_; const GURL script_url_; const GURL scope_; std::vector<GURL> foreign_fetch_scopes_; diff --git a/content/browser/service_worker/service_worker_version_unittest.cc b/content/browser/service_worker/service_worker_version_unittest.cc index 115722f..649d563 100644 --- a/content/browser/service_worker/service_worker_version_unittest.cc +++ b/content/browser/service_worker/service_worker_version_unittest.cc @@ -2,7 +2,9 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "base/basictypes.h" +#include <stdint.h> + +#include "base/macros.h" #include "base/run_loop.h" #include "content/browser/message_port_service.h" #include "content/browser/service_worker/embedded_worker_registry.h" @@ -253,7 +255,7 @@ class MessageReceiverDisallowStart : public MessageReceiver { ~MessageReceiverDisallowStart() override {} void OnStartWorker(int embedded_worker_id, - int64 service_worker_version_id, + int64_t service_worker_version_id, const GURL& scope, const GURL& script_url) override { // Do nothing. diff --git a/content/browser/service_worker/service_worker_write_to_cache_job.cc b/content/browser/service_worker/service_worker_write_to_cache_job.cc index fc3074d..f0b6a52 100644 --- a/content/browser/service_worker/service_worker_write_to_cache_job.cc +++ b/content/browser/service_worker/service_worker_write_to_cache_job.cc @@ -59,8 +59,8 @@ ServiceWorkerWriteToCacheJob::ServiceWorkerWriteToCacheJob( base::WeakPtr<ServiceWorkerContextCore> context, ServiceWorkerVersion* version, int extra_load_flags, - int64 resource_id, - int64 incumbent_resource_id) + int64_t resource_id, + int64_t incumbent_resource_id) : net::URLRequestJob(request, network_delegate), resource_type_(resource_type), context_(context), diff --git a/content/browser/service_worker/service_worker_write_to_cache_job.h b/content/browser/service_worker/service_worker_write_to_cache_job.h index e614912..8cb483c 100644 --- a/content/browser/service_worker/service_worker_write_to_cache_job.h +++ b/content/browser/service_worker/service_worker_write_to_cache_job.h @@ -5,9 +5,12 @@ #ifndef CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_WRITE_TO_CACHE_JOB_H_ #define CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_WRITE_TO_CACHE_JOB_H_ +#include <stdint.h> + #include <string> #include "base/gtest_prod_util.h" +#include "base/macros.h" #include "base/memory/weak_ptr.h" #include "content/browser/service_worker/service_worker_disk_cache.h" #include "content/browser/service_worker/service_worker_version.h" @@ -49,8 +52,8 @@ class CONTENT_EXPORT ServiceWorkerWriteToCacheJob base::WeakPtr<ServiceWorkerContextCore> context, ServiceWorkerVersion* version, int extra_load_flags, - int64 resource_id, - int64 incumbent_resource_id); + int64_t resource_id, + int64_t incumbent_resource_id); private: FRIEND_TEST_ALL_PREFIXES(ServiceWorkerContextRequestHandlerTest, @@ -135,8 +138,8 @@ class CONTENT_EXPORT ServiceWorkerWriteToCacheJob int io_buffer_bytes_; base::WeakPtr<ServiceWorkerContextCore> context_; GURL url_; - int64 resource_id_; - int64 incumbent_resource_id_; + int64_t resource_id_; + int64_t incumbent_resource_id_; scoped_ptr<net::URLRequest> net_request_; scoped_ptr<net::HttpResponseInfo> http_info_; scoped_ptr<ServiceWorkerResponseWriter> writer_; diff --git a/content/browser/service_worker/service_worker_write_to_cache_job_unittest.cc b/content/browser/service_worker/service_worker_write_to_cache_job_unittest.cc index 4836383..f5fd757 100644 --- a/content/browser/service_worker/service_worker_write_to_cache_job_unittest.cc +++ b/content/browser/service_worker/service_worker_write_to_cache_job_unittest.cc @@ -2,7 +2,11 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. +#include <stddef.h> +#include <stdint.h> + #include "base/location.h" +#include "base/macros.h" #include "base/run_loop.h" #include "base/single_thread_task_runner.h" #include "base/thread_task_runner_handle.h" @@ -424,7 +428,7 @@ class ServiceWorkerWriteToCacheJobTest : public testing::Test { GURL script_url_; int next_provider_id_ = 1; - int64 next_version_id_ = 1L; + int64_t next_version_id_ = 1L; }; TEST_F(ServiceWorkerWriteToCacheJobTest, Normal) { |