Commit 8a13f005 authored by Nicholas Verne's avatar Nicholas Verne Committed by Commit Bot

Starts the mojoification of AppCache.

First, convert all enums and structs used by existing IPCs to mojo

Next CL will define the Host and Renderer interfaces.

Bug: 611938
Change-Id: I689b7399ad903197073ca15763d73d5bfff3207f
Reviewed-on: https://chromium-review.googlesource.com/790174Reviewed-by: default avatarKen Buchanan <kenrb@chromium.org>
Reviewed-by: default avatarNick Carter <nick@chromium.org>
Reviewed-by: default avatarJoshua Bell <jsbell@chromium.org>
Commit-Queue: Nicholas Verne <nverne@chromium.org>
Cr-Commit-Position: refs/heads/master@{#520772}
parent 3879fc9a
...@@ -158,7 +158,7 @@ void AppCacheDispatcherHost::OnGetStatus(int host_id, IPC::Message* reply_msg) { ...@@ -158,7 +158,7 @@ void AppCacheDispatcherHost::OnGetStatus(int host_id, IPC::Message* reply_msg) {
return; return;
} }
GetStatusCallback(APPCACHE_STATUS_UNCACHED, reply_msg); GetStatusCallback(AppCacheStatus::APPCACHE_STATUS_UNCACHED, reply_msg);
} }
void AppCacheDispatcherHost::OnStartUpdate(int host_id, void AppCacheDispatcherHost::OnStartUpdate(int host_id,
......
...@@ -24,8 +24,8 @@ void AppCacheFrontendProxy::OnStatusChanged(const std::vector<int>& host_ids, ...@@ -24,8 +24,8 @@ void AppCacheFrontendProxy::OnStatusChanged(const std::vector<int>& host_ids,
void AppCacheFrontendProxy::OnEventRaised(const std::vector<int>& host_ids, void AppCacheFrontendProxy::OnEventRaised(const std::vector<int>& host_ids,
AppCacheEventID event_id) { AppCacheEventID event_id) {
DCHECK_NE(APPCACHE_PROGRESS_EVENT, DCHECK_NE(AppCacheEventID::APPCACHE_PROGRESS_EVENT,
event_id); // See OnProgressEventRaised. event_id); // See OnProgressEventRaised.
sender_->Send(new AppCacheMsg_EventRaised(host_ids, event_id)); sender_->Send(new AppCacheMsg_EventRaised(host_ids, event_id));
} }
......
...@@ -20,9 +20,9 @@ namespace { ...@@ -20,9 +20,9 @@ namespace {
class TestAppCacheFrontend : public content::AppCacheFrontend { class TestAppCacheFrontend : public content::AppCacheFrontend {
public: public:
TestAppCacheFrontend() TestAppCacheFrontend()
: last_host_id_(-1), last_cache_id_(-1), : last_host_id_(-1),
last_status_(content::APPCACHE_STATUS_OBSOLETE) { last_cache_id_(-1),
} last_status_(content::AppCacheStatus::APPCACHE_STATUS_OBSOLETE) {}
void OnCacheSelected(int host_id, void OnCacheSelected(int host_id,
const content::AppCacheInfo& info) override { const content::AppCacheInfo& info) override {
...@@ -192,12 +192,12 @@ TEST_F(AppCacheGroupTest, CleanupUnusedGroup) { ...@@ -192,12 +192,12 @@ TEST_F(AppCacheGroupTest, CleanupUnusedGroup) {
host1.AssociateCompleteCache(cache1); host1.AssociateCompleteCache(cache1);
EXPECT_EQ(frontend.last_host_id_, host1.host_id()); EXPECT_EQ(frontend.last_host_id_, host1.host_id());
EXPECT_EQ(frontend.last_cache_id_, cache1->cache_id()); EXPECT_EQ(frontend.last_cache_id_, cache1->cache_id());
EXPECT_EQ(frontend.last_status_, APPCACHE_STATUS_IDLE); EXPECT_EQ(frontend.last_status_, AppCacheStatus::APPCACHE_STATUS_IDLE);
host2.AssociateCompleteCache(cache1); host2.AssociateCompleteCache(cache1);
EXPECT_EQ(frontend.last_host_id_, host2.host_id()); EXPECT_EQ(frontend.last_host_id_, host2.host_id());
EXPECT_EQ(frontend.last_cache_id_, cache1->cache_id()); EXPECT_EQ(frontend.last_cache_id_, cache1->cache_id());
EXPECT_EQ(frontend.last_status_, APPCACHE_STATUS_IDLE); EXPECT_EQ(frontend.last_status_, AppCacheStatus::APPCACHE_STATUS_IDLE);
AppCache* cache2 = new AppCache(service.storage(), 222); AppCache* cache2 = new AppCache(service.storage(), 222);
cache2->set_complete(true); cache2->set_complete(true);
...@@ -210,7 +210,7 @@ TEST_F(AppCacheGroupTest, CleanupUnusedGroup) { ...@@ -210,7 +210,7 @@ TEST_F(AppCacheGroupTest, CleanupUnusedGroup) {
host2.AssociateNoCache(GURL()); host2.AssociateNoCache(GURL());
EXPECT_EQ(frontend.last_host_id_, host2.host_id()); EXPECT_EQ(frontend.last_host_id_, host2.host_id());
EXPECT_EQ(frontend.last_cache_id_, kAppCacheNoCacheId); EXPECT_EQ(frontend.last_cache_id_, kAppCacheNoCacheId);
EXPECT_EQ(frontend.last_status_, APPCACHE_STATUS_UNCACHED); EXPECT_EQ(frontend.last_status_, AppCacheStatus::APPCACHE_STATUS_UNCACHED);
} }
TEST_F(AppCacheGroupTest, StartUpdate) { TEST_F(AppCacheGroupTest, StartUpdate) {
...@@ -228,7 +228,8 @@ TEST_F(AppCacheGroupTest, StartUpdate) { ...@@ -228,7 +228,8 @@ TEST_F(AppCacheGroupTest, StartUpdate) {
group->StartUpdateWithHost(nullptr); group->StartUpdateWithHost(nullptr);
EXPECT_EQ(update, group->update_job_); EXPECT_EQ(update, group->update_job_);
// Deleting the update should restore the group to APPCACHE_STATUS_IDLE. // Deleting the update should restore the group to
// AppCacheStatus::APPCACHE_STATUS_IDLE.
delete update; delete update;
EXPECT_TRUE(group->update_job_ == nullptr); EXPECT_TRUE(group->update_job_ == nullptr);
EXPECT_EQ(AppCacheGroup::IDLE, group->update_status()); EXPECT_EQ(AppCacheGroup::IDLE, group->update_status());
......
...@@ -136,15 +136,13 @@ bool AppCacheHost::SelectCache(const GURL& document_url, ...@@ -136,15 +136,13 @@ bool AppCacheHost::SelectCache(const GURL& document_url,
!policy->CanCreateAppCache(manifest_url, first_party_url_)) { !policy->CanCreateAppCache(manifest_url, first_party_url_)) {
FinishCacheSelection(nullptr, nullptr); FinishCacheSelection(nullptr, nullptr);
std::vector<int> host_ids(1, host_id_); std::vector<int> host_ids(1, host_id_);
frontend_->OnEventRaised(host_ids, APPCACHE_CHECKING_EVENT); frontend_->OnEventRaised(host_ids,
AppCacheEventID::APPCACHE_CHECKING_EVENT);
frontend_->OnErrorEventRaised( frontend_->OnErrorEventRaised(
host_ids, host_ids, AppCacheErrorDetails(
AppCacheErrorDetails( "Cache creation was blocked by the content policy",
"Cache creation was blocked by the content policy", AppCacheErrorReason::APPCACHE_POLICY_ERROR, GURL(), 0,
APPCACHE_POLICY_ERROR, false /*is_cross_origin*/));
GURL(),
0,
false /*is_cross_origin*/));
frontend_->OnContentBlocked(host_id_, manifest_url); frontend_->OnContentBlocked(host_id_, manifest_url);
return true; return true;
} }
...@@ -340,22 +338,22 @@ AppCacheStatus AppCacheHost::GetStatus() { ...@@ -340,22 +338,22 @@ AppCacheStatus AppCacheHost::GetStatus() {
// 6.9.8 Application cache API // 6.9.8 Application cache API
AppCache* cache = associated_cache(); AppCache* cache = associated_cache();
if (!cache) if (!cache)
return APPCACHE_STATUS_UNCACHED; return AppCacheStatus::APPCACHE_STATUS_UNCACHED;
// A cache without an owning group represents the cache being constructed // A cache without an owning group represents the cache being constructed
// during the application cache update process. // during the application cache update process.
if (!cache->owning_group()) if (!cache->owning_group())
return APPCACHE_STATUS_DOWNLOADING; return AppCacheStatus::APPCACHE_STATUS_DOWNLOADING;
if (cache->owning_group()->is_obsolete()) if (cache->owning_group()->is_obsolete())
return APPCACHE_STATUS_OBSOLETE; return AppCacheStatus::APPCACHE_STATUS_OBSOLETE;
if (cache->owning_group()->update_status() == AppCacheGroup::CHECKING) if (cache->owning_group()->update_status() == AppCacheGroup::CHECKING)
return APPCACHE_STATUS_CHECKING; return AppCacheStatus::APPCACHE_STATUS_CHECKING;
if (cache->owning_group()->update_status() == AppCacheGroup::DOWNLOADING) if (cache->owning_group()->update_status() == AppCacheGroup::DOWNLOADING)
return APPCACHE_STATUS_DOWNLOADING; return AppCacheStatus::APPCACHE_STATUS_DOWNLOADING;
if (swappable_cache_.get()) if (swappable_cache_.get())
return APPCACHE_STATUS_UPDATE_READY; return AppCacheStatus::APPCACHE_STATUS_UPDATE_READY;
return APPCACHE_STATUS_IDLE; return AppCacheStatus::APPCACHE_STATUS_IDLE;
} }
void AppCacheHost::LoadOrCreateGroup(const GURL& manifest_url) { void AppCacheHost::LoadOrCreateGroup(const GURL& manifest_url) {
......
...@@ -561,6 +561,7 @@ mojom("mojo_bindings") { ...@@ -561,6 +561,7 @@ mojom("mojo_bindings") {
cpp_only = true cpp_only = true
sources = [ sources = [
"appcache.mojom",
"associated_interfaces.mojom", "associated_interfaces.mojom",
"child.mojom", "child.mojom",
"child_control.mojom", "child_control.mojom",
......
// Copyright 2017 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
module content.mojom;
import "content/public/common/appcache_info.mojom";
import "url/mojo/url.mojom";
enum AppCacheEventID {
APPCACHE_CHECKING_EVENT,
APPCACHE_ERROR_EVENT,
APPCACHE_NO_UPDATE_EVENT,
APPCACHE_DOWNLOADING_EVENT,
APPCACHE_PROGRESS_EVENT,
APPCACHE_UPDATE_READY_EVENT,
APPCACHE_CACHED_EVENT,
APPCACHE_OBSOLETE_EVENT,
};
enum AppCacheErrorReason {
APPCACHE_MANIFEST_ERROR,
APPCACHE_SIGNATURE_ERROR,
APPCACHE_RESOURCE_ERROR,
APPCACHE_CHANGED_ERROR,
APPCACHE_ABORT_ERROR,
APPCACHE_QUOTA_ERROR,
APPCACHE_POLICY_ERROR,
APPCACHE_UNKNOWN_ERROR,
};
struct AppCacheResourceInfo {
url.mojom.Url url;
int64 size;
bool is_master;
bool is_manifest;
bool is_intercept;
bool is_fallback;
bool is_foreign;
bool is_explicit;
int64 response_id;
};
struct AppCacheErrorDetails {
string message;
AppCacheErrorReason reason = APPCACHE_UNKNOWN_ERROR;
url.mojom.Url url;
int32 status;
bool is_cross_origin;
};
...@@ -20,58 +20,6 @@ const char kHttpHEADMethod[] = "HEAD"; ...@@ -20,58 +20,6 @@ const char kHttpHEADMethod[] = "HEAD";
const base::FilePath::CharType kAppCacheDatabaseName[] = const base::FilePath::CharType kAppCacheDatabaseName[] =
FILE_PATH_LITERAL("Index"); FILE_PATH_LITERAL("Index");
AppCacheInfo::AppCacheInfo()
: cache_id(kAppCacheNoCacheId),
group_id(0),
status(APPCACHE_STATUS_UNCACHED),
size(0),
is_complete(false) {
}
AppCacheInfo::AppCacheInfo(const AppCacheInfo& other) = default;
AppCacheInfo::~AppCacheInfo() {
}
AppCacheResourceInfo::AppCacheResourceInfo()
: url(),
size(0),
is_master(false),
is_manifest(false),
is_intercept(false),
is_fallback(false),
is_foreign(false),
is_explicit(false),
response_id(kAppCacheNoResponseId) {
}
AppCacheResourceInfo::AppCacheResourceInfo(const AppCacheResourceInfo& other) =
default;
AppCacheResourceInfo::~AppCacheResourceInfo() {
}
AppCacheErrorDetails::AppCacheErrorDetails()
: message(),
reason(APPCACHE_UNKNOWN_ERROR),
url(),
status(0),
is_cross_origin(false) {}
AppCacheErrorDetails::AppCacheErrorDetails(
std::string in_message,
AppCacheErrorReason in_reason,
GURL in_url,
int in_status,
bool in_is_cross_origin)
: message(in_message),
reason(in_reason),
url(in_url),
status(in_status),
is_cross_origin(in_is_cross_origin) {}
AppCacheErrorDetails::~AppCacheErrorDetails() {}
AppCacheNamespace::AppCacheNamespace() AppCacheNamespace::AppCacheNamespace()
: type(APPCACHE_FALLBACK_NAMESPACE), is_pattern(false) {} : type(APPCACHE_FALLBACK_NAMESPACE), is_pattern(false) {}
......
...@@ -10,6 +10,7 @@ ...@@ -10,6 +10,7 @@
#include <string> #include <string>
#include "base/files/file_path.h" #include "base/files/file_path.h"
#include "content/common/appcache.mojom.h"
#include "content/public/common/appcache_info.h" #include "content/public/common/appcache_info.h"
#include "mojo/public/cpp/system/message_pipe.h" #include "mojo/public/cpp/system/message_pipe.h"
...@@ -22,17 +23,10 @@ namespace content { ...@@ -22,17 +23,10 @@ namespace content {
// Defines constants, types, and abstract classes used in the main // Defines constants, types, and abstract classes used in the main
// process and in child processes. // process and in child processes.
enum AppCacheEventID { using mojom::AppCacheEventID;
APPCACHE_CHECKING_EVENT, using mojom::AppCacheErrorReason;
APPCACHE_ERROR_EVENT, using mojom::AppCacheResourceInfo;
APPCACHE_NO_UPDATE_EVENT, using mojom::AppCacheErrorDetails;
APPCACHE_DOWNLOADING_EVENT,
APPCACHE_PROGRESS_EVENT,
APPCACHE_UPDATE_READY_EVENT,
APPCACHE_CACHED_EVENT,
APPCACHE_OBSOLETE_EVENT,
APPCACHE_EVENT_ID_LAST = APPCACHE_OBSOLETE_EVENT
};
// Temporarily renumber them in wierd way, to help remove LOG_TIP from WebKit // Temporarily renumber them in wierd way, to help remove LOG_TIP from WebKit
enum AppCacheLogLevel { enum AppCacheLogLevel {
...@@ -48,51 +42,6 @@ enum AppCacheNamespaceType { ...@@ -48,51 +42,6 @@ enum AppCacheNamespaceType {
APPCACHE_NETWORK_NAMESPACE APPCACHE_NETWORK_NAMESPACE
}; };
enum AppCacheErrorReason {
APPCACHE_MANIFEST_ERROR,
APPCACHE_SIGNATURE_ERROR,
APPCACHE_RESOURCE_ERROR,
APPCACHE_CHANGED_ERROR,
APPCACHE_ABORT_ERROR,
APPCACHE_QUOTA_ERROR,
APPCACHE_POLICY_ERROR,
APPCACHE_UNKNOWN_ERROR,
APPCACHE_ERROR_REASON_LAST = APPCACHE_UNKNOWN_ERROR
};
// Type to hold information about a single appcache resource.
struct CONTENT_EXPORT AppCacheResourceInfo {
AppCacheResourceInfo();
AppCacheResourceInfo(const AppCacheResourceInfo& other);
~AppCacheResourceInfo();
GURL url;
int64_t size;
bool is_master;
bool is_manifest;
bool is_intercept;
bool is_fallback;
bool is_foreign;
bool is_explicit;
int64_t response_id;
};
struct CONTENT_EXPORT AppCacheErrorDetails {
AppCacheErrorDetails();
AppCacheErrorDetails(std::string message,
AppCacheErrorReason reason,
GURL url,
int status,
bool is_cross_origin);
~AppCacheErrorDetails();
std::string message;
AppCacheErrorReason reason;
GURL url;
int status;
bool is_cross_origin;
};
typedef std::vector<AppCacheResourceInfo> AppCacheResourceInfoVector; typedef std::vector<AppCacheResourceInfo> AppCacheResourceInfoVector;
struct CONTENT_EXPORT AppCacheNamespace { struct CONTENT_EXPORT AppCacheNamespace {
......
...@@ -16,11 +16,11 @@ ...@@ -16,11 +16,11 @@
#define IPC_MESSAGE_START AppCacheMsgStart #define IPC_MESSAGE_START AppCacheMsgStart
IPC_ENUM_TRAITS_MAX_VALUE(content::AppCacheEventID, IPC_ENUM_TRAITS_MAX_VALUE(content::AppCacheEventID,
content::APPCACHE_EVENT_ID_LAST) content::AppCacheEventID::APPCACHE_OBSOLETE_EVENT)
IPC_ENUM_TRAITS_MAX_VALUE(content::AppCacheStatus, IPC_ENUM_TRAITS_MAX_VALUE(content::AppCacheStatus,
content::APPCACHE_STATUS_LAST) content::AppCacheStatus::APPCACHE_STATUS_OBSOLETE)
IPC_ENUM_TRAITS_MAX_VALUE(content::AppCacheErrorReason, IPC_ENUM_TRAITS_MAX_VALUE(content::AppCacheErrorReason,
content::APPCACHE_ERROR_REASON_LAST) content::AppCacheErrorReason::APPCACHE_UNKNOWN_ERROR)
IPC_STRUCT_TRAITS_BEGIN(content::AppCacheInfo) IPC_STRUCT_TRAITS_BEGIN(content::AppCacheInfo)
IPC_STRUCT_TRAITS_MEMBER(manifest_url) IPC_STRUCT_TRAITS_MEMBER(manifest_url)
......
...@@ -355,6 +355,7 @@ mojom("interfaces") { ...@@ -355,6 +355,7 @@ mojom("interfaces") {
] ]
sources = [ sources = [
"appcache_info.mojom",
"download_stream.mojom", "download_stream.mojom",
"network_service.mojom", "network_service.mojom",
"network_service_test.mojom", "network_service_test.mojom",
......
...@@ -11,6 +11,7 @@ ...@@ -11,6 +11,7 @@
#include "base/time/time.h" #include "base/time/time.h"
#include "content/common/content_export.h" #include "content/common/content_export.h"
#include "content/public/common/appcache_info.mojom.h"
#include "third_party/WebKit/public/platform/WebApplicationCacheHost.h" #include "third_party/WebKit/public/platform/WebApplicationCacheHost.h"
#include "url/gurl.h" #include "url/gurl.h"
...@@ -20,35 +21,13 @@ typedef base::OnceCallback<void(int)> OnceCompletionCallback; ...@@ -20,35 +21,13 @@ typedef base::OnceCallback<void(int)> OnceCompletionCallback;
static const int kAppCacheNoHostId = static const int kAppCacheNoHostId =
blink::WebApplicationCacheHost::kAppCacheNoHostId; blink::WebApplicationCacheHost::kAppCacheNoHostId;
static const int64_t kAppCacheNoCacheId = 0;
static const int64_t kAppCacheNoResponseId = 0; using mojom::kAppCacheNoCacheId;
static const int64_t kAppCacheUnknownCacheId = -1; using mojom::kAppCacheNoResponseId;
using mojom::kAppCacheUnknownCacheId;
enum AppCacheStatus {
APPCACHE_STATUS_UNCACHED, using mojom::AppCacheStatus;
APPCACHE_STATUS_IDLE, using mojom::AppCacheInfo;
APPCACHE_STATUS_CHECKING,
APPCACHE_STATUS_DOWNLOADING,
APPCACHE_STATUS_UPDATE_READY,
APPCACHE_STATUS_OBSOLETE,
APPCACHE_STATUS_LAST = APPCACHE_STATUS_OBSOLETE
};
struct CONTENT_EXPORT AppCacheInfo {
AppCacheInfo();
AppCacheInfo(const AppCacheInfo& other);
~AppCacheInfo();
GURL manifest_url;
base::Time creation_time;
base::Time last_update_time;
base::Time last_access_time;
int64_t cache_id;
int64_t group_id;
AppCacheStatus status;
int64_t size;
bool is_complete;
};
typedef std::vector<AppCacheInfo> AppCacheInfoVector; typedef std::vector<AppCacheInfo> AppCacheInfoVector;
......
// Copyright 2017 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
module content.mojom;
import "mojo/common/time.mojom";
import "url/mojo/url.mojom";
const int64 kAppCacheNoCacheId = 0;
const int64 kAppCacheNoResponseId = 0;
const int64 kAppCacheUnknownCacheId = -1;
enum AppCacheStatus {
APPCACHE_STATUS_UNCACHED,
APPCACHE_STATUS_IDLE,
APPCACHE_STATUS_CHECKING,
APPCACHE_STATUS_DOWNLOADING,
APPCACHE_STATUS_UPDATE_READY,
APPCACHE_STATUS_OBSOLETE,
};
struct AppCacheInfo {
url.mojom.Url manifest_url;
mojo.common.mojom.Time creation_time;
mojo.common.mojom.Time last_update_time;
mojo.common.mojom.Time last_access_time;
int64 cache_id;
int64 group_id;
AppCacheStatus status;
int64 size;
bool is_complete;
};
...@@ -49,7 +49,7 @@ void AppCacheBackendProxy::MarkAsForeignEntry( ...@@ -49,7 +49,7 @@ void AppCacheBackendProxy::MarkAsForeignEntry(
} }
AppCacheStatus AppCacheBackendProxy::GetStatus(int host_id) { AppCacheStatus AppCacheBackendProxy::GetStatus(int host_id) {
AppCacheStatus status = APPCACHE_STATUS_UNCACHED; AppCacheStatus status = AppCacheStatus::APPCACHE_STATUS_UNCACHED;
sender_->Send(new AppCacheHostMsg_GetStatus(host_id, &status)); sender_->Send(new AppCacheHostMsg_GetStatus(host_id, &status));
return status; return status;
} }
......
...@@ -37,9 +37,11 @@ void AppCacheFrontendImpl::OnStatusChanged(const std::vector<int>& host_ids, ...@@ -37,9 +37,11 @@ void AppCacheFrontendImpl::OnStatusChanged(const std::vector<int>& host_ids,
void AppCacheFrontendImpl::OnEventRaised(const std::vector<int>& host_ids, void AppCacheFrontendImpl::OnEventRaised(const std::vector<int>& host_ids,
AppCacheEventID event_id) { AppCacheEventID event_id) {
DCHECK(event_id != DCHECK_NE(
APPCACHE_PROGRESS_EVENT); // See OnProgressEventRaised. event_id,
DCHECK(event_id != APPCACHE_ERROR_EVENT); // See OnErrorEventRaised. AppCacheEventID::APPCACHE_PROGRESS_EVENT); // See OnProgressEventRaised.
DCHECK_NE(event_id,
AppCacheEventID::APPCACHE_ERROR_EVENT); // See OnErrorEventRaised.
for (std::vector<int>::const_iterator i = host_ids.begin(); for (std::vector<int>::const_iterator i = host_ids.begin();
i != host_ids.end(); ++i) { i != host_ids.end(); ++i) {
WebApplicationCacheHostImpl* host = GetHost(*i); WebApplicationCacheHostImpl* host = GetHost(*i);
...@@ -103,47 +105,51 @@ void AppCacheFrontendImpl::OnSetSubresourceFactory( ...@@ -103,47 +105,51 @@ void AppCacheFrontendImpl::OnSetSubresourceFactory(
"mismatched enum: " #a) "mismatched enum: " #a)
STATIC_ASSERT_ENUM(WebApplicationCacheHost::kUncached, STATIC_ASSERT_ENUM(WebApplicationCacheHost::kUncached,
APPCACHE_STATUS_UNCACHED); AppCacheStatus::APPCACHE_STATUS_UNCACHED);
STATIC_ASSERT_ENUM(WebApplicationCacheHost::kIdle, APPCACHE_STATUS_IDLE); STATIC_ASSERT_ENUM(WebApplicationCacheHost::kIdle,
AppCacheStatus::APPCACHE_STATUS_IDLE);
STATIC_ASSERT_ENUM(WebApplicationCacheHost::kChecking, STATIC_ASSERT_ENUM(WebApplicationCacheHost::kChecking,
APPCACHE_STATUS_CHECKING); AppCacheStatus::APPCACHE_STATUS_CHECKING);
STATIC_ASSERT_ENUM(WebApplicationCacheHost::kDownloading, STATIC_ASSERT_ENUM(WebApplicationCacheHost::kDownloading,
APPCACHE_STATUS_DOWNLOADING); AppCacheStatus::APPCACHE_STATUS_DOWNLOADING);
STATIC_ASSERT_ENUM(WebApplicationCacheHost::kUpdateReady, STATIC_ASSERT_ENUM(WebApplicationCacheHost::kUpdateReady,
APPCACHE_STATUS_UPDATE_READY); AppCacheStatus::APPCACHE_STATUS_UPDATE_READY);
STATIC_ASSERT_ENUM(WebApplicationCacheHost::kObsolete, STATIC_ASSERT_ENUM(WebApplicationCacheHost::kObsolete,
APPCACHE_STATUS_OBSOLETE); AppCacheStatus::APPCACHE_STATUS_OBSOLETE);
STATIC_ASSERT_ENUM(WebApplicationCacheHost::kCheckingEvent, STATIC_ASSERT_ENUM(WebApplicationCacheHost::kCheckingEvent,
APPCACHE_CHECKING_EVENT); AppCacheEventID::APPCACHE_CHECKING_EVENT);
STATIC_ASSERT_ENUM(WebApplicationCacheHost::kErrorEvent, APPCACHE_ERROR_EVENT); STATIC_ASSERT_ENUM(WebApplicationCacheHost::kErrorEvent,
AppCacheEventID::APPCACHE_ERROR_EVENT);
STATIC_ASSERT_ENUM(WebApplicationCacheHost::kNoUpdateEvent, STATIC_ASSERT_ENUM(WebApplicationCacheHost::kNoUpdateEvent,
APPCACHE_NO_UPDATE_EVENT); AppCacheEventID::APPCACHE_NO_UPDATE_EVENT);
STATIC_ASSERT_ENUM(WebApplicationCacheHost::kDownloadingEvent, STATIC_ASSERT_ENUM(WebApplicationCacheHost::kDownloadingEvent,
APPCACHE_DOWNLOADING_EVENT); AppCacheEventID::APPCACHE_DOWNLOADING_EVENT);
STATIC_ASSERT_ENUM(WebApplicationCacheHost::kProgressEvent, STATIC_ASSERT_ENUM(WebApplicationCacheHost::kProgressEvent,
APPCACHE_PROGRESS_EVENT); AppCacheEventID::APPCACHE_PROGRESS_EVENT);
STATIC_ASSERT_ENUM(WebApplicationCacheHost::kUpdateReadyEvent, STATIC_ASSERT_ENUM(WebApplicationCacheHost::kUpdateReadyEvent,
APPCACHE_UPDATE_READY_EVENT); AppCacheEventID::APPCACHE_UPDATE_READY_EVENT);
STATIC_ASSERT_ENUM(WebApplicationCacheHost::kCachedEvent, STATIC_ASSERT_ENUM(WebApplicationCacheHost::kCachedEvent,
APPCACHE_CACHED_EVENT); AppCacheEventID::APPCACHE_CACHED_EVENT);
STATIC_ASSERT_ENUM(WebApplicationCacheHost::kObsoleteEvent, STATIC_ASSERT_ENUM(WebApplicationCacheHost::kObsoleteEvent,
APPCACHE_OBSOLETE_EVENT); AppCacheEventID::APPCACHE_OBSOLETE_EVENT);
STATIC_ASSERT_ENUM(WebApplicationCacheHost::kManifestError, STATIC_ASSERT_ENUM(WebApplicationCacheHost::kManifestError,
APPCACHE_MANIFEST_ERROR); AppCacheErrorReason::APPCACHE_MANIFEST_ERROR);
STATIC_ASSERT_ENUM(WebApplicationCacheHost::kSignatureError, STATIC_ASSERT_ENUM(WebApplicationCacheHost::kSignatureError,
APPCACHE_SIGNATURE_ERROR); AppCacheErrorReason::APPCACHE_SIGNATURE_ERROR);
STATIC_ASSERT_ENUM(WebApplicationCacheHost::kResourceError, STATIC_ASSERT_ENUM(WebApplicationCacheHost::kResourceError,
APPCACHE_RESOURCE_ERROR); AppCacheErrorReason::APPCACHE_RESOURCE_ERROR);
STATIC_ASSERT_ENUM(WebApplicationCacheHost::kChangedError, STATIC_ASSERT_ENUM(WebApplicationCacheHost::kChangedError,
APPCACHE_CHANGED_ERROR); AppCacheErrorReason::APPCACHE_CHANGED_ERROR);
STATIC_ASSERT_ENUM(WebApplicationCacheHost::kAbortError, APPCACHE_ABORT_ERROR); STATIC_ASSERT_ENUM(WebApplicationCacheHost::kAbortError,
STATIC_ASSERT_ENUM(WebApplicationCacheHost::kQuotaError, APPCACHE_QUOTA_ERROR); AppCacheErrorReason::APPCACHE_ABORT_ERROR);
STATIC_ASSERT_ENUM(WebApplicationCacheHost::kQuotaError,
AppCacheErrorReason::APPCACHE_QUOTA_ERROR);
STATIC_ASSERT_ENUM(WebApplicationCacheHost::kPolicyError, STATIC_ASSERT_ENUM(WebApplicationCacheHost::kPolicyError,
APPCACHE_POLICY_ERROR); AppCacheErrorReason::APPCACHE_POLICY_ERROR);
STATIC_ASSERT_ENUM(WebApplicationCacheHost::kUnknownError, STATIC_ASSERT_ENUM(WebApplicationCacheHost::kUnknownError,
APPCACHE_UNKNOWN_ERROR); AppCacheErrorReason::APPCACHE_UNKNOWN_ERROR);
STATIC_ASSERT_ENUM(WebConsoleMessage::kLevelVerbose, APPCACHE_LOG_VERBOSE); STATIC_ASSERT_ENUM(WebConsoleMessage::kLevelVerbose, APPCACHE_LOG_VERBOSE);
STATIC_ASSERT_ENUM(WebConsoleMessage::kLevelInfo, APPCACHE_LOG_INFO); STATIC_ASSERT_ENUM(WebConsoleMessage::kLevelInfo, APPCACHE_LOG_INFO);
......
...@@ -62,7 +62,7 @@ WebApplicationCacheHostImpl::WebApplicationCacheHostImpl( ...@@ -62,7 +62,7 @@ WebApplicationCacheHostImpl::WebApplicationCacheHostImpl(
int appcache_host_id) int appcache_host_id)
: client_(client), : client_(client),
backend_(backend), backend_(backend),
status_(APPCACHE_STATUS_UNCACHED), status_(AppCacheStatus::APPCACHE_STATUS_UNCACHED),
is_scheme_supported_(false), is_scheme_supported_(false),
is_get_method_(false), is_get_method_(false),
is_new_master_entry_(MAYBE_NEW_ENTRY), is_new_master_entry_(MAYBE_NEW_ENTRY),
...@@ -99,33 +99,35 @@ void WebApplicationCacheHostImpl::OnStatusChanged( ...@@ -99,33 +99,35 @@ void WebApplicationCacheHostImpl::OnStatusChanged(
void WebApplicationCacheHostImpl::OnEventRaised( void WebApplicationCacheHostImpl::OnEventRaised(
AppCacheEventID event_id) { AppCacheEventID event_id) {
DCHECK(event_id != DCHECK_NE(
APPCACHE_PROGRESS_EVENT); // See OnProgressEventRaised. event_id,
DCHECK(event_id != APPCACHE_ERROR_EVENT); // See OnErrorEventRaised. AppCacheEventID::APPCACHE_PROGRESS_EVENT); // See OnProgressEventRaised.
DCHECK_NE(event_id,
AppCacheEventID::APPCACHE_ERROR_EVENT); // See OnErrorEventRaised.
// Emit logging output prior to calling out to script as we can get // Emit logging output prior to calling out to script as we can get
// deleted within the script event handler. // deleted within the script event handler.
const char kFormatString[] = "Application Cache %s event"; const char kFormatString[] = "Application Cache %s event";
std::string message = base::StringPrintf(kFormatString, std::string message = base::StringPrintf(
kEventNames[event_id]); kFormatString, kEventNames[static_cast<int>(event_id)]);
OnLogMessage(APPCACHE_LOG_INFO, message); OnLogMessage(APPCACHE_LOG_INFO, message);
switch (event_id) { switch (event_id) {
case APPCACHE_CHECKING_EVENT: case AppCacheEventID::APPCACHE_CHECKING_EVENT:
status_ = APPCACHE_STATUS_CHECKING; status_ = AppCacheStatus::APPCACHE_STATUS_CHECKING;
break; break;
case APPCACHE_DOWNLOADING_EVENT: case AppCacheEventID::APPCACHE_DOWNLOADING_EVENT:
status_ = APPCACHE_STATUS_DOWNLOADING; status_ = AppCacheStatus::APPCACHE_STATUS_DOWNLOADING;
break; break;
case APPCACHE_UPDATE_READY_EVENT: case AppCacheEventID::APPCACHE_UPDATE_READY_EVENT:
status_ = APPCACHE_STATUS_UPDATE_READY; status_ = AppCacheStatus::APPCACHE_STATUS_UPDATE_READY;
break; break;
case APPCACHE_CACHED_EVENT: case AppCacheEventID::APPCACHE_CACHED_EVENT:
case APPCACHE_NO_UPDATE_EVENT: case AppCacheEventID::APPCACHE_NO_UPDATE_EVENT:
status_ = APPCACHE_STATUS_IDLE; status_ = AppCacheStatus::APPCACHE_STATUS_IDLE;
break; break;
case APPCACHE_OBSOLETE_EVENT: case AppCacheEventID::APPCACHE_OBSOLETE_EVENT:
status_ = APPCACHE_STATUS_OBSOLETE; status_ = AppCacheStatus::APPCACHE_STATUS_OBSOLETE;
break; break;
default: default:
NOTREACHED(); NOTREACHED();
...@@ -143,7 +145,7 @@ void WebApplicationCacheHostImpl::OnProgressEventRaised( ...@@ -143,7 +145,7 @@ void WebApplicationCacheHostImpl::OnProgressEventRaised(
std::string message = base::StringPrintf(kFormatString, num_complete, std::string message = base::StringPrintf(kFormatString, num_complete,
num_total, url.spec().c_str()); num_total, url.spec().c_str());
OnLogMessage(APPCACHE_LOG_INFO, message); OnLogMessage(APPCACHE_LOG_INFO, message);
status_ = APPCACHE_STATUS_DOWNLOADING; status_ = AppCacheStatus::APPCACHE_STATUS_DOWNLOADING;
client_->NotifyProgressEventListener(url, num_total, num_complete); client_->NotifyProgressEventListener(url, num_total, num_complete);
} }
...@@ -156,11 +158,11 @@ void WebApplicationCacheHostImpl::OnErrorEventRaised( ...@@ -156,11 +158,11 @@ void WebApplicationCacheHostImpl::OnErrorEventRaised(
base::StringPrintf(kFormatString, details.message.c_str()); base::StringPrintf(kFormatString, details.message.c_str());
OnLogMessage(APPCACHE_LOG_ERROR, full_message); OnLogMessage(APPCACHE_LOG_ERROR, full_message);
status_ = cache_info_.is_complete ? APPCACHE_STATUS_IDLE : status_ = cache_info_.is_complete ? AppCacheStatus::APPCACHE_STATUS_IDLE
APPCACHE_STATUS_UNCACHED; : AppCacheStatus::APPCACHE_STATUS_UNCACHED;
if (details.is_cross_origin) { if (details.is_cross_origin) {
// Don't leak detailed information to script for cross-origin resources. // Don't leak detailed information to script for cross-origin resources.
DCHECK_EQ(APPCACHE_RESOURCE_ERROR, details.reason); DCHECK_EQ(AppCacheErrorReason::APPCACHE_RESOURCE_ERROR, details.reason);
client_->NotifyErrorEventListener(static_cast<ErrorReason>(details.reason), client_->NotifyErrorEventListener(static_cast<ErrorReason>(details.reason),
details.url, 0, WebString()); details.url, 0, WebString());
} else { } else {
...@@ -183,7 +185,8 @@ void WebApplicationCacheHostImpl::WillStartMainResourceRequest( ...@@ -183,7 +185,8 @@ void WebApplicationCacheHostImpl::WillStartMainResourceRequest(
const WebApplicationCacheHostImpl* spawning_host_impl = const WebApplicationCacheHostImpl* spawning_host_impl =
static_cast<const WebApplicationCacheHostImpl*>(spawning_host); static_cast<const WebApplicationCacheHostImpl*>(spawning_host);
if (spawning_host_impl && (spawning_host_impl != this) && if (spawning_host_impl && (spawning_host_impl != this) &&
(spawning_host_impl->status_ != APPCACHE_STATUS_UNCACHED)) { (spawning_host_impl->status_ !=
AppCacheStatus::APPCACHE_STATUS_UNCACHED)) {
backend_->SetSpawningHostId(host_id_, spawning_host_impl->host_id()); backend_->SetSpawningHostId(host_id_, spawning_host_impl->host_id());
} }
} }
...@@ -194,8 +197,8 @@ void WebApplicationCacheHostImpl::SelectCacheWithoutManifest() { ...@@ -194,8 +197,8 @@ void WebApplicationCacheHostImpl::SelectCacheWithoutManifest() {
was_select_cache_called_ = true; was_select_cache_called_ = true;
status_ = (document_response_.AppCacheID() == kAppCacheNoCacheId) status_ = (document_response_.AppCacheID() == kAppCacheNoCacheId)
? APPCACHE_STATUS_UNCACHED ? AppCacheStatus::APPCACHE_STATUS_UNCACHED
: APPCACHE_STATUS_CHECKING; : AppCacheStatus::APPCACHE_STATUS_CHECKING;
is_new_master_entry_ = OLD_ENTRY; is_new_master_entry_ = OLD_ENTRY;
backend_->SelectCache(host_id_, document_url_, backend_->SelectCache(host_id_, document_url_,
document_response_.AppCacheID(), GURL()); document_response_.AppCacheID(), GURL());
...@@ -214,10 +217,10 @@ bool WebApplicationCacheHostImpl::SelectCacheWithManifest( ...@@ -214,10 +217,10 @@ bool WebApplicationCacheHostImpl::SelectCacheWithManifest(
if (document_response_.AppCacheID() == kAppCacheNoCacheId) { if (document_response_.AppCacheID() == kAppCacheNoCacheId) {
if (is_scheme_supported_ && is_get_method_ && if (is_scheme_supported_ && is_get_method_ &&
(manifest_gurl.GetOrigin() == document_url_.GetOrigin())) { (manifest_gurl.GetOrigin() == document_url_.GetOrigin())) {
status_ = APPCACHE_STATUS_CHECKING; status_ = AppCacheStatus::APPCACHE_STATUS_CHECKING;
is_new_master_entry_ = NEW_ENTRY; is_new_master_entry_ = NEW_ENTRY;
} else { } else {
status_ = APPCACHE_STATUS_UNCACHED; status_ = AppCacheStatus::APPCACHE_STATUS_UNCACHED;
is_new_master_entry_ = OLD_ENTRY; is_new_master_entry_ = OLD_ENTRY;
manifest_gurl = GURL(); manifest_gurl = GURL();
} }
...@@ -234,11 +237,11 @@ bool WebApplicationCacheHostImpl::SelectCacheWithManifest( ...@@ -234,11 +237,11 @@ bool WebApplicationCacheHostImpl::SelectCacheWithManifest(
if (document_manifest_gurl != manifest_gurl) { if (document_manifest_gurl != manifest_gurl) {
backend_->MarkAsForeignEntry(host_id_, document_url_, backend_->MarkAsForeignEntry(host_id_, document_url_,
document_response_.AppCacheID()); document_response_.AppCacheID());
status_ = APPCACHE_STATUS_UNCACHED; status_ = AppCacheStatus::APPCACHE_STATUS_UNCACHED;
return false; // the navigation will be restarted return false; // the navigation will be restarted
} }
status_ = APPCACHE_STATUS_CHECKING; status_ = AppCacheStatus::APPCACHE_STATUS_CHECKING;
// Its a 'master' entry thats already in the cache. // Its a 'master' entry thats already in the cache.
backend_->SelectCache(host_id_, document_url_, backend_->SelectCache(host_id_, document_url_,
...@@ -281,9 +284,9 @@ WebApplicationCacheHost::Status WebApplicationCacheHostImpl::GetStatus() { ...@@ -281,9 +284,9 @@ WebApplicationCacheHost::Status WebApplicationCacheHostImpl::GetStatus() {
bool WebApplicationCacheHostImpl::StartUpdate() { bool WebApplicationCacheHostImpl::StartUpdate() {
if (!backend_->StartUpdate(host_id_)) if (!backend_->StartUpdate(host_id_))
return false; return false;
if (status_ == APPCACHE_STATUS_IDLE || if (status_ == AppCacheStatus::APPCACHE_STATUS_IDLE ||
status_ == APPCACHE_STATUS_UPDATE_READY) status_ == AppCacheStatus::APPCACHE_STATUS_UPDATE_READY)
status_ = APPCACHE_STATUS_CHECKING; status_ = AppCacheStatus::APPCACHE_STATUS_CHECKING;
else else
status_ = backend_->GetStatus(host_id_); status_ = backend_->GetStatus(host_id_);
return true; return true;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment