OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "content/child/appcache/appcache_frontend_impl.h" | 5 #include "content/child/appcache/appcache_frontend_impl.h" |
6 | 6 |
7 #include "base/logging.h" | 7 #include "base/logging.h" |
8 #include "content/child/appcache/web_application_cache_host_impl.h" | 8 #include "content/child/appcache/web_application_cache_host_impl.h" |
9 #include "third_party/WebKit/public/web/WebConsoleMessage.h" | 9 #include "third_party/WebKit/public/web/WebConsoleMessage.h" |
10 | 10 |
11 using blink::WebApplicationCacheHost; | 11 using blink::WebApplicationCacheHost; |
12 using blink::WebConsoleMessage; | 12 using blink::WebConsoleMessage; |
13 | 13 |
14 namespace content { | 14 namespace content { |
15 | 15 |
16 // Inline helper to keep the lines shorter and unwrapped. | 16 // Inline helper to keep the lines shorter and unwrapped. |
17 inline WebApplicationCacheHostImpl* GetHost(int id) { | 17 inline WebApplicationCacheHostImpl* GetHost(int id) { |
18 return WebApplicationCacheHostImpl::FromId(id); | 18 return WebApplicationCacheHostImpl::FromId(id); |
19 } | 19 } |
20 | 20 |
21 void AppCacheFrontendImpl::OnCacheSelected(int host_id, | 21 void AppCacheFrontendImpl::OnCacheSelected(int host_id, |
22 const appcache::AppCacheInfo& info) { | 22 const AppCacheInfo& info) { |
23 WebApplicationCacheHostImpl* host = GetHost(host_id); | 23 WebApplicationCacheHostImpl* host = GetHost(host_id); |
24 if (host) | 24 if (host) |
25 host->OnCacheSelected(info); | 25 host->OnCacheSelected(info); |
26 } | 26 } |
27 | 27 |
28 void AppCacheFrontendImpl::OnStatusChanged(const std::vector<int>& host_ids, | 28 void AppCacheFrontendImpl::OnStatusChanged(const std::vector<int>& host_ids, |
29 appcache::AppCacheStatus status) { | 29 AppCacheStatus status) { |
30 for (std::vector<int>::const_iterator i = host_ids.begin(); | 30 for (std::vector<int>::const_iterator i = host_ids.begin(); |
31 i != host_ids.end(); ++i) { | 31 i != host_ids.end(); ++i) { |
32 WebApplicationCacheHostImpl* host = GetHost(*i); | 32 WebApplicationCacheHostImpl* host = GetHost(*i); |
33 if (host) | 33 if (host) |
34 host->OnStatusChanged(status); | 34 host->OnStatusChanged(status); |
35 } | 35 } |
36 } | 36 } |
37 | 37 |
38 void AppCacheFrontendImpl::OnEventRaised(const std::vector<int>& host_ids, | 38 void AppCacheFrontendImpl::OnEventRaised(const std::vector<int>& host_ids, |
39 appcache::AppCacheEventID event_id) { | 39 AppCacheEventID event_id) { |
40 DCHECK(event_id != | 40 DCHECK(event_id != |
41 appcache::APPCACHE_PROGRESS_EVENT); // See OnProgressEventRaised. | 41 APPCACHE_PROGRESS_EVENT); // See OnProgressEventRaised. |
42 DCHECK(event_id != appcache::APPCACHE_ERROR_EVENT); // See OnErrorEventRaised. | 42 DCHECK(event_id != APPCACHE_ERROR_EVENT); // See OnErrorEventRaised. |
43 for (std::vector<int>::const_iterator i = host_ids.begin(); | 43 for (std::vector<int>::const_iterator i = host_ids.begin(); |
44 i != host_ids.end(); ++i) { | 44 i != host_ids.end(); ++i) { |
45 WebApplicationCacheHostImpl* host = GetHost(*i); | 45 WebApplicationCacheHostImpl* host = GetHost(*i); |
46 if (host) | 46 if (host) |
47 host->OnEventRaised(event_id); | 47 host->OnEventRaised(event_id); |
48 } | 48 } |
49 } | 49 } |
50 | 50 |
51 void AppCacheFrontendImpl::OnProgressEventRaised( | 51 void AppCacheFrontendImpl::OnProgressEventRaised( |
52 const std::vector<int>& host_ids, | 52 const std::vector<int>& host_ids, |
53 const GURL& url, | 53 const GURL& url, |
54 int num_total, | 54 int num_total, |
55 int num_complete) { | 55 int num_complete) { |
56 for (std::vector<int>::const_iterator i = host_ids.begin(); | 56 for (std::vector<int>::const_iterator i = host_ids.begin(); |
57 i != host_ids.end(); ++i) { | 57 i != host_ids.end(); ++i) { |
58 WebApplicationCacheHostImpl* host = GetHost(*i); | 58 WebApplicationCacheHostImpl* host = GetHost(*i); |
59 if (host) | 59 if (host) |
60 host->OnProgressEventRaised(url, num_total, num_complete); | 60 host->OnProgressEventRaised(url, num_total, num_complete); |
61 } | 61 } |
62 } | 62 } |
63 | 63 |
64 void AppCacheFrontendImpl::OnErrorEventRaised( | 64 void AppCacheFrontendImpl::OnErrorEventRaised( |
65 const std::vector<int>& host_ids, | 65 const std::vector<int>& host_ids, |
66 const appcache::AppCacheErrorDetails& details) { | 66 const AppCacheErrorDetails& details) { |
67 for (std::vector<int>::const_iterator i = host_ids.begin(); | 67 for (std::vector<int>::const_iterator i = host_ids.begin(); |
68 i != host_ids.end(); ++i) { | 68 i != host_ids.end(); ++i) { |
69 WebApplicationCacheHostImpl* host = GetHost(*i); | 69 WebApplicationCacheHostImpl* host = GetHost(*i); |
70 if (host) | 70 if (host) |
71 host->OnErrorEventRaised(details); | 71 host->OnErrorEventRaised(details); |
72 } | 72 } |
73 } | 73 } |
74 | 74 |
75 void AppCacheFrontendImpl::OnLogMessage(int host_id, | 75 void AppCacheFrontendImpl::OnLogMessage(int host_id, |
76 appcache::AppCacheLogLevel log_level, | 76 AppCacheLogLevel log_level, |
77 const std::string& message) { | 77 const std::string& message) { |
78 WebApplicationCacheHostImpl* host = GetHost(host_id); | 78 WebApplicationCacheHostImpl* host = GetHost(host_id); |
79 if (host) | 79 if (host) |
80 host->OnLogMessage(log_level, message); | 80 host->OnLogMessage(log_level, message); |
81 } | 81 } |
82 | 82 |
83 void AppCacheFrontendImpl::OnContentBlocked(int host_id, | 83 void AppCacheFrontendImpl::OnContentBlocked(int host_id, |
84 const GURL& manifest_url) { | 84 const GURL& manifest_url) { |
85 WebApplicationCacheHostImpl* host = GetHost(host_id); | 85 WebApplicationCacheHostImpl* host = GetHost(host_id); |
86 if (host) | 86 if (host) |
87 host->OnContentBlocked(manifest_url); | 87 host->OnContentBlocked(manifest_url); |
88 } | 88 } |
89 | 89 |
90 // Ensure that enum values never get out of sync with the | 90 // Ensure that enum values never get out of sync with the |
91 // ones declared for use within the WebKit api | 91 // ones declared for use within the WebKit api |
92 COMPILE_ASSERT((int)WebApplicationCacheHost::Uncached == | 92 COMPILE_ASSERT((int)WebApplicationCacheHost::Uncached == |
93 (int)appcache::APPCACHE_STATUS_UNCACHED, Uncached); | 93 (int)APPCACHE_STATUS_UNCACHED, Uncached); |
94 COMPILE_ASSERT((int)WebApplicationCacheHost::Idle == | 94 COMPILE_ASSERT((int)WebApplicationCacheHost::Idle == |
95 (int)appcache::APPCACHE_STATUS_IDLE, Idle); | 95 (int)APPCACHE_STATUS_IDLE, Idle); |
96 COMPILE_ASSERT((int)WebApplicationCacheHost::Checking == | 96 COMPILE_ASSERT((int)WebApplicationCacheHost::Checking == |
97 (int)appcache::APPCACHE_STATUS_CHECKING, Checking); | 97 (int)APPCACHE_STATUS_CHECKING, Checking); |
98 COMPILE_ASSERT((int)WebApplicationCacheHost::Downloading == | 98 COMPILE_ASSERT((int)WebApplicationCacheHost::Downloading == |
99 (int)appcache::APPCACHE_STATUS_DOWNLOADING, Downloading); | 99 (int)APPCACHE_STATUS_DOWNLOADING, Downloading); |
100 COMPILE_ASSERT((int)WebApplicationCacheHost::UpdateReady == | 100 COMPILE_ASSERT((int)WebApplicationCacheHost::UpdateReady == |
101 (int)appcache::APPCACHE_STATUS_UPDATE_READY, UpdateReady); | 101 (int)APPCACHE_STATUS_UPDATE_READY, UpdateReady); |
102 COMPILE_ASSERT((int)WebApplicationCacheHost::Obsolete == | 102 COMPILE_ASSERT((int)WebApplicationCacheHost::Obsolete == |
103 (int)appcache::APPCACHE_STATUS_OBSOLETE, Obsolete); | 103 (int)APPCACHE_STATUS_OBSOLETE, Obsolete); |
104 | 104 |
105 COMPILE_ASSERT((int)WebApplicationCacheHost::CheckingEvent == | 105 COMPILE_ASSERT((int)WebApplicationCacheHost::CheckingEvent == |
106 (int)appcache::APPCACHE_CHECKING_EVENT, CheckingEvent); | 106 (int)APPCACHE_CHECKING_EVENT, CheckingEvent); |
107 COMPILE_ASSERT((int)WebApplicationCacheHost::ErrorEvent == | 107 COMPILE_ASSERT((int)WebApplicationCacheHost::ErrorEvent == |
108 (int)appcache::APPCACHE_ERROR_EVENT, ErrorEvent); | 108 (int)APPCACHE_ERROR_EVENT, ErrorEvent); |
109 COMPILE_ASSERT((int)WebApplicationCacheHost::NoUpdateEvent == | 109 COMPILE_ASSERT((int)WebApplicationCacheHost::NoUpdateEvent == |
110 (int)appcache::APPCACHE_NO_UPDATE_EVENT, NoUpdateEvent); | 110 (int)APPCACHE_NO_UPDATE_EVENT, NoUpdateEvent); |
111 COMPILE_ASSERT((int)WebApplicationCacheHost::DownloadingEvent == | 111 COMPILE_ASSERT((int)WebApplicationCacheHost::DownloadingEvent == |
112 (int)appcache::APPCACHE_DOWNLOADING_EVENT, DownloadingEvent); | 112 (int)APPCACHE_DOWNLOADING_EVENT, DownloadingEvent); |
113 COMPILE_ASSERT((int)WebApplicationCacheHost::ProgressEvent == | 113 COMPILE_ASSERT((int)WebApplicationCacheHost::ProgressEvent == |
114 (int)appcache::APPCACHE_PROGRESS_EVENT, ProgressEvent); | 114 (int)APPCACHE_PROGRESS_EVENT, ProgressEvent); |
115 COMPILE_ASSERT((int)WebApplicationCacheHost::UpdateReadyEvent == | 115 COMPILE_ASSERT((int)WebApplicationCacheHost::UpdateReadyEvent == |
116 (int)appcache::APPCACHE_UPDATE_READY_EVENT, UpdateReadyEvent); | 116 (int)APPCACHE_UPDATE_READY_EVENT, UpdateReadyEvent); |
117 COMPILE_ASSERT((int)WebApplicationCacheHost::CachedEvent == | 117 COMPILE_ASSERT((int)WebApplicationCacheHost::CachedEvent == |
118 (int)appcache::APPCACHE_CACHED_EVENT, CachedEvent); | 118 (int)APPCACHE_CACHED_EVENT, CachedEvent); |
119 COMPILE_ASSERT((int)WebApplicationCacheHost::ObsoleteEvent == | 119 COMPILE_ASSERT((int)WebApplicationCacheHost::ObsoleteEvent == |
120 (int)appcache::APPCACHE_OBSOLETE_EVENT, ObsoleteEvent); | 120 (int)APPCACHE_OBSOLETE_EVENT, ObsoleteEvent); |
121 | 121 |
122 COMPILE_ASSERT((int)WebConsoleMessage::LevelDebug == | 122 COMPILE_ASSERT((int)WebConsoleMessage::LevelDebug == |
123 (int)appcache::APPCACHE_LOG_DEBUG, LevelDebug); | 123 (int)APPCACHE_LOG_DEBUG, LevelDebug); |
124 COMPILE_ASSERT((int)WebConsoleMessage::LevelLog == | 124 COMPILE_ASSERT((int)WebConsoleMessage::LevelLog == |
125 (int)appcache::APPCACHE_LOG_INFO, LevelLog); | 125 (int)APPCACHE_LOG_INFO, LevelLog); |
126 COMPILE_ASSERT((int)WebConsoleMessage::LevelWarning == | 126 COMPILE_ASSERT((int)WebConsoleMessage::LevelWarning == |
127 (int)appcache::APPCACHE_LOG_WARNING, LevelWarning); | 127 (int)APPCACHE_LOG_WARNING, LevelWarning); |
128 COMPILE_ASSERT((int)WebConsoleMessage::LevelError == | 128 COMPILE_ASSERT((int)WebConsoleMessage::LevelError == |
129 (int)appcache::APPCACHE_LOG_ERROR, LevelError); | 129 (int)APPCACHE_LOG_ERROR, LevelError); |
130 | 130 |
131 COMPILE_ASSERT((int)WebApplicationCacheHost::ManifestError == | 131 COMPILE_ASSERT((int)WebApplicationCacheHost::ManifestError == |
132 (int)appcache::APPCACHE_MANIFEST_ERROR, | 132 (int)APPCACHE_MANIFEST_ERROR, |
133 ManifestError); | 133 ManifestError); |
134 COMPILE_ASSERT((int)WebApplicationCacheHost::SignatureError == | 134 COMPILE_ASSERT((int)WebApplicationCacheHost::SignatureError == |
135 (int)appcache::APPCACHE_SIGNATURE_ERROR, | 135 (int)APPCACHE_SIGNATURE_ERROR, |
136 SignatureError); | 136 SignatureError); |
137 COMPILE_ASSERT((int)WebApplicationCacheHost::ResourceError == | 137 COMPILE_ASSERT((int)WebApplicationCacheHost::ResourceError == |
138 (int)appcache::APPCACHE_RESOURCE_ERROR, | 138 (int)APPCACHE_RESOURCE_ERROR, |
139 ResourceError); | 139 ResourceError); |
140 COMPILE_ASSERT((int)WebApplicationCacheHost::ChangedError == | 140 COMPILE_ASSERT((int)WebApplicationCacheHost::ChangedError == |
141 (int)appcache::APPCACHE_CHANGED_ERROR, | 141 (int)APPCACHE_CHANGED_ERROR, |
142 ChangedError); | 142 ChangedError); |
143 COMPILE_ASSERT((int)WebApplicationCacheHost::AbortError == | 143 COMPILE_ASSERT((int)WebApplicationCacheHost::AbortError == |
144 (int)appcache::APPCACHE_ABORT_ERROR, | 144 (int)APPCACHE_ABORT_ERROR, |
145 AbortError); | 145 AbortError); |
146 COMPILE_ASSERT((int)WebApplicationCacheHost::QuotaError == | 146 COMPILE_ASSERT((int)WebApplicationCacheHost::QuotaError == |
147 (int)appcache::APPCACHE_QUOTA_ERROR, | 147 (int)APPCACHE_QUOTA_ERROR, |
148 QuotaError); | 148 QuotaError); |
149 COMPILE_ASSERT((int)WebApplicationCacheHost::PolicyError == | 149 COMPILE_ASSERT((int)WebApplicationCacheHost::PolicyError == |
150 (int)appcache::APPCACHE_POLICY_ERROR, | 150 (int)APPCACHE_POLICY_ERROR, |
151 PolicyError); | 151 PolicyError); |
152 COMPILE_ASSERT((int)WebApplicationCacheHost::UnknownError == | 152 COMPILE_ASSERT((int)WebApplicationCacheHost::UnknownError == |
153 (int)appcache::APPCACHE_UNKNOWN_ERROR, | 153 (int)APPCACHE_UNKNOWN_ERROR, |
154 UnknownError); | 154 UnknownError); |
155 | 155 |
156 } // namespace content | 156 } // namespace content |
OLD | NEW |