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