1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
|
// Copyright 2012 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.
#ifndef THIRD_PARTY_BLINK_RENDERER_CORE_LOADER_APPCACHE_APPLICATION_CACHE_HOST_FOR_FRAME_H_
#define THIRD_PARTY_BLINK_RENDERER_CORE_LOADER_APPCACHE_APPLICATION_CACHE_HOST_FOR_FRAME_H_
#include "mojo/public/cpp/bindings/pending_remote.h"
#include "third_party/blink/renderer/core/core_export.h"
#include "third_party/blink/renderer/core/loader/appcache/application_cache_host.h"
namespace blink {
class ApplicationCache;
class DocumentLoader;
class LocalFrame;
class CORE_EXPORT ApplicationCacheHostForFrame : public ApplicationCacheHost {
public:
ApplicationCacheHostForFrame(
DocumentLoader* document_loader,
const BrowserInterfaceBrokerProxy& interface_broker_proxy,
scoped_refptr<base::SingleThreadTaskRunner> task_runner,
const base::UnguessableToken& appcache_host_id);
// ApplicationCacheHost:
void Detach() override;
bool Update();
bool SwapCache();
void SetApplicationCache(ApplicationCache*);
void StopDeferringEvents();
// blink::mojom::AppCacheFrontend:
void LogMessage(mojom::blink::ConsoleMessageLevel log_level,
const String& message) override;
void SetSubresourceFactory(
mojo::PendingRemote<network::mojom::blink::URLLoaderFactory>
url_loader_factory) override;
void WillStartLoadingMainResource(DocumentLoader* loader,
const KURL& url,
const String& method);
virtual void SelectCacheWithoutManifest();
void SelectCacheWithManifest(const KURL& manifest_url);
void DidReceiveResponseForMainResource(const ResourceResponse&);
void Trace(Visitor*) override;
private:
enum IsNewMasterEntry { MAYBE_NEW_ENTRY, NEW_ENTRY, OLD_ENTRY };
struct DeferredEvent {
mojom::AppCacheEventID event_id;
int progress_total;
int progress_done;
mojom::AppCacheErrorReason error_reason;
String error_url;
int error_status;
String error_message;
DeferredEvent(mojom::AppCacheEventID id,
int progress_total,
int progress_done,
mojom::AppCacheErrorReason error_reason,
const String& error_url,
int error_status,
const String& error_message)
: event_id(id),
progress_total(progress_total),
progress_done(progress_done),
error_reason(error_reason),
error_url(error_url),
error_status(error_status),
error_message(error_message) {}
};
void NotifyApplicationCache(mojom::AppCacheEventID,
int progress_total,
int progress_done,
mojom::AppCacheErrorReason,
const String& error_url,
int error_status,
const String& error_message) override;
void DispatchDOMEvent(mojom::AppCacheEventID,
int progress_total,
int progress_done,
mojom::AppCacheErrorReason,
const String& error_url,
int error_status,
const String& error_message);
bool IsApplicationCacheEnabled();
WeakMember<ApplicationCache> dom_application_cache_ = nullptr;
Member<LocalFrame> local_frame_;
Member<DocumentLoader> document_loader_;
bool is_get_method_ = false;
bool was_select_cache_called_ = false;
IsNewMasterEntry is_new_master_entry_ = MAYBE_NEW_ENTRY;
bool is_scheme_supported_ = false;
ResourceResponse document_response_;
KURL document_url_;
KURL original_main_resource_url_; // Used to detect redirection.
// Events are deferred until after document onload.
bool defers_events_ = true;
Vector<DeferredEvent> deferred_events_;
};
} // namespace blink
#endif // THIRD_PARTY_BLINK_RENDERER_CORE_LOADER_APPCACHE_APPLICATION_CACHE_HOST_FOR_FRAME_H_
|