OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 "webkit/renderer/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 "third_party/WebKit/public/web/WebApplicationCacheHost.h" | 9 #include "third_party/WebKit/public/web/WebApplicationCacheHost.h" |
9 #include "third_party/WebKit/public/web/WebConsoleMessage.h" | 10 #include "third_party/WebKit/public/web/WebConsoleMessage.h" |
10 #include "webkit/renderer/appcache/web_application_cache_host_impl.h" | |
11 | 11 |
12 using WebKit::WebApplicationCacheHost; | 12 using WebKit::WebApplicationCacheHost; |
13 using WebKit::WebConsoleMessage; | 13 using WebKit::WebConsoleMessage; |
14 | 14 |
15 namespace appcache { | 15 namespace content { |
16 | 16 |
17 // Inline helper to keep the lines shorter and unwrapped. | 17 // Inline helper to keep the lines shorter and unwrapped. |
18 inline WebApplicationCacheHostImpl* GetHost(int id) { | 18 inline WebApplicationCacheHostImpl* GetHost(int id) { |
19 return WebApplicationCacheHostImpl::FromId(id); | 19 return WebApplicationCacheHostImpl::FromId(id); |
20 } | 20 } |
21 | 21 |
22 void AppCacheFrontendImpl::OnCacheSelected( | 22 void AppCacheFrontendImpl::OnCacheSelected(int host_id, |
23 int host_id, const AppCacheInfo& info) { | 23 const appcache::AppCacheInfo& info) { |
24 WebApplicationCacheHostImpl* host = GetHost(host_id); | 24 WebApplicationCacheHostImpl* host = GetHost(host_id); |
25 if (host) | 25 if (host) |
26 host->OnCacheSelected(info); | 26 host->OnCacheSelected(info); |
27 } | 27 } |
28 | 28 |
29 void AppCacheFrontendImpl::OnStatusChanged(const std::vector<int>& host_ids, | 29 void AppCacheFrontendImpl::OnStatusChanged(const std::vector<int>& host_ids, |
30 Status status) { | 30 appcache::Status status) { |
31 for (std::vector<int>::const_iterator i = host_ids.begin(); | 31 for (std::vector<int>::const_iterator i = host_ids.begin(); |
32 i != host_ids.end(); ++i) { | 32 i != host_ids.end(); ++i) { |
33 WebApplicationCacheHostImpl* host = GetHost(*i); | 33 WebApplicationCacheHostImpl* host = GetHost(*i); |
34 if (host) | 34 if (host) |
35 host->OnStatusChanged(status); | 35 host->OnStatusChanged(status); |
36 } | 36 } |
37 } | 37 } |
38 | 38 |
39 void AppCacheFrontendImpl::OnEventRaised(const std::vector<int>& host_ids, | 39 void AppCacheFrontendImpl::OnEventRaised(const std::vector<int>& host_ids, |
40 EventID event_id) { | 40 appcache::EventID event_id) { |
41 DCHECK(event_id != PROGRESS_EVENT); // See OnProgressEventRaised. | 41 DCHECK(event_id != appcache::PROGRESS_EVENT); // See OnProgressEventRaised. |
42 DCHECK(event_id != 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, int num_total, int num_complete) { | 53 const GURL& url, |
| 54 int num_total, |
| 55 int num_complete) { |
54 for (std::vector<int>::const_iterator i = host_ids.begin(); | 56 for (std::vector<int>::const_iterator i = host_ids.begin(); |
55 i != host_ids.end(); ++i) { | 57 i != host_ids.end(); ++i) { |
56 WebApplicationCacheHostImpl* host = GetHost(*i); | 58 WebApplicationCacheHostImpl* host = GetHost(*i); |
57 if (host) | 59 if (host) |
58 host->OnProgressEventRaised(url, num_total, num_complete); | 60 host->OnProgressEventRaised(url, num_total, num_complete); |
59 } | 61 } |
60 } | 62 } |
61 | 63 |
62 void AppCacheFrontendImpl::OnErrorEventRaised( | 64 void AppCacheFrontendImpl::OnErrorEventRaised(const std::vector<int>& host_ids, |
63 const std::vector<int>& host_ids, | 65 const std::string& message) { |
64 const std::string& message) { | |
65 for (std::vector<int>::const_iterator i = host_ids.begin(); | 66 for (std::vector<int>::const_iterator i = host_ids.begin(); |
66 i != host_ids.end(); ++i) { | 67 i != host_ids.end(); ++i) { |
67 WebApplicationCacheHostImpl* host = GetHost(*i); | 68 WebApplicationCacheHostImpl* host = GetHost(*i); |
68 if (host) | 69 if (host) |
69 host->OnErrorEventRaised(message); | 70 host->OnErrorEventRaised(message); |
70 } | 71 } |
71 } | 72 } |
72 | 73 |
73 void AppCacheFrontendImpl::OnLogMessage(int host_id, LogLevel log_level, | 74 void AppCacheFrontendImpl::OnLogMessage(int host_id, |
| 75 appcache::LogLevel log_level, |
74 const std::string& message) { | 76 const std::string& message) { |
75 WebApplicationCacheHostImpl* host = GetHost(host_id); | 77 WebApplicationCacheHostImpl* host = GetHost(host_id); |
76 if (host) | 78 if (host) |
77 host->OnLogMessage(log_level, message); | 79 host->OnLogMessage(log_level, message); |
78 } | 80 } |
79 | 81 |
80 void AppCacheFrontendImpl::OnContentBlocked(int host_id, | 82 void AppCacheFrontendImpl::OnContentBlocked(int host_id, |
81 const GURL& manifest_url) { | 83 const GURL& manifest_url) { |
82 WebApplicationCacheHostImpl* host = GetHost(host_id); | 84 WebApplicationCacheHostImpl* host = GetHost(host_id); |
83 if (host) | 85 if (host) |
84 host->OnContentBlocked(manifest_url); | 86 host->OnContentBlocked(manifest_url); |
85 } | 87 } |
86 | 88 |
87 // Ensure that enum values never get out of sync with the | 89 // Ensure that enum values never get out of sync with the |
88 // ones declared for use within the WebKit api | 90 // ones declared for use within the WebKit api |
89 COMPILE_ASSERT((int)WebApplicationCacheHost::Uncached == | 91 COMPILE_ASSERT((int)WebApplicationCacheHost::Uncached == |
90 (int)UNCACHED, Uncached); | 92 (int)appcache::UNCACHED, Uncached); |
91 COMPILE_ASSERT((int)WebApplicationCacheHost::Idle == | 93 COMPILE_ASSERT((int)WebApplicationCacheHost::Idle == |
92 (int)IDLE, Idle); | 94 (int)appcache::IDLE, Idle); |
93 COMPILE_ASSERT((int)WebApplicationCacheHost::Checking == | 95 COMPILE_ASSERT((int)WebApplicationCacheHost::Checking == |
94 (int)CHECKING, Checking); | 96 (int)appcache::CHECKING, Checking); |
95 COMPILE_ASSERT((int)WebApplicationCacheHost::Downloading == | 97 COMPILE_ASSERT((int)WebApplicationCacheHost::Downloading == |
96 (int)DOWNLOADING, Downloading); | 98 (int)appcache::DOWNLOADING, Downloading); |
97 COMPILE_ASSERT((int)WebApplicationCacheHost::UpdateReady == | 99 COMPILE_ASSERT((int)WebApplicationCacheHost::UpdateReady == |
98 (int)UPDATE_READY, UpdateReady); | 100 (int)appcache::UPDATE_READY, UpdateReady); |
99 COMPILE_ASSERT((int)WebApplicationCacheHost::Obsolete == | 101 COMPILE_ASSERT((int)WebApplicationCacheHost::Obsolete == |
100 (int)OBSOLETE, Obsolete); | 102 (int)appcache::OBSOLETE, Obsolete); |
101 COMPILE_ASSERT((int)WebApplicationCacheHost::CheckingEvent == | 103 COMPILE_ASSERT((int)WebApplicationCacheHost::CheckingEvent == |
102 (int)CHECKING_EVENT, CheckingEvent); | 104 (int)appcache::CHECKING_EVENT, CheckingEvent); |
103 COMPILE_ASSERT((int)WebApplicationCacheHost::ErrorEvent == | 105 COMPILE_ASSERT((int)WebApplicationCacheHost::ErrorEvent == |
104 (int)ERROR_EVENT, ErrorEvent); | 106 (int)appcache::ERROR_EVENT, ErrorEvent); |
105 COMPILE_ASSERT((int)WebApplicationCacheHost::NoUpdateEvent == | 107 COMPILE_ASSERT((int)WebApplicationCacheHost::NoUpdateEvent == |
106 (int)NO_UPDATE_EVENT, NoUpdateEvent); | 108 (int)appcache::NO_UPDATE_EVENT, NoUpdateEvent); |
107 COMPILE_ASSERT((int)WebApplicationCacheHost::DownloadingEvent == | 109 COMPILE_ASSERT((int)WebApplicationCacheHost::DownloadingEvent == |
108 (int)DOWNLOADING_EVENT, DownloadingEvent); | 110 (int)appcache::DOWNLOADING_EVENT, DownloadingEvent); |
109 COMPILE_ASSERT((int)WebApplicationCacheHost::ProgressEvent == | 111 COMPILE_ASSERT((int)WebApplicationCacheHost::ProgressEvent == |
110 (int)PROGRESS_EVENT, ProgressEvent); | 112 (int)appcache::PROGRESS_EVENT, ProgressEvent); |
111 COMPILE_ASSERT((int)WebApplicationCacheHost::UpdateReadyEvent == | 113 COMPILE_ASSERT((int)WebApplicationCacheHost::UpdateReadyEvent == |
112 (int)UPDATE_READY_EVENT, UpdateReadyEvent); | 114 (int)appcache::UPDATE_READY_EVENT, UpdateReadyEvent); |
113 COMPILE_ASSERT((int)WebApplicationCacheHost::CachedEvent == | 115 COMPILE_ASSERT((int)WebApplicationCacheHost::CachedEvent == |
114 (int)CACHED_EVENT, CachedEvent); | 116 (int)appcache::CACHED_EVENT, CachedEvent); |
115 COMPILE_ASSERT((int)WebApplicationCacheHost::ObsoleteEvent == | 117 COMPILE_ASSERT((int)WebApplicationCacheHost::ObsoleteEvent == |
116 (int)OBSOLETE_EVENT, ObsoleteEvent); | 118 (int)appcache::OBSOLETE_EVENT, ObsoleteEvent); |
117 COMPILE_ASSERT((int)WebConsoleMessage::LevelDebug == | 119 COMPILE_ASSERT((int)WebConsoleMessage::LevelDebug == |
118 (int)LOG_DEBUG, LevelDebug); | 120 (int)appcache::LOG_DEBUG, LevelDebug); |
119 COMPILE_ASSERT((int)WebConsoleMessage::LevelLog == | 121 COMPILE_ASSERT((int)WebConsoleMessage::LevelLog == |
120 (int)LOG_INFO, LevelLog); | 122 (int)appcache::LOG_INFO, LevelLog); |
121 COMPILE_ASSERT((int)WebConsoleMessage::LevelWarning == | 123 COMPILE_ASSERT((int)WebConsoleMessage::LevelWarning == |
122 (int)LOG_WARNING, LevelWarning); | 124 (int)appcache::LOG_WARNING, LevelWarning); |
123 COMPILE_ASSERT((int)WebConsoleMessage::LevelError == | 125 COMPILE_ASSERT((int)WebConsoleMessage::LevelError == |
124 (int)LOG_ERROR, LevelError); | 126 (int)appcache::LOG_ERROR, LevelError); |
125 | 127 |
126 } // namespace appcache | 128 } // namespace content |
OLD | NEW |