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