| 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 appcache::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::Status status) { | 29 appcache::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::EventID event_id) { | 39 appcache::AppCacheEventID event_id) { |
| 40 DCHECK(event_id != appcache::PROGRESS_EVENT); // See OnProgressEventRaised. | 40 DCHECK(event_id != appcache::PROGRESS_EVENT); // See OnProgressEventRaised. |
| 41 DCHECK(event_id != appcache::ERROR_EVENT); // See OnErrorEventRaised. | 41 DCHECK(event_id != appcache::ERROR_EVENT); // See OnErrorEventRaised. |
| 42 for (std::vector<int>::const_iterator i = host_ids.begin(); | 42 for (std::vector<int>::const_iterator i = host_ids.begin(); |
| 43 i != host_ids.end(); ++i) { | 43 i != host_ids.end(); ++i) { |
| 44 WebApplicationCacheHostImpl* host = GetHost(*i); | 44 WebApplicationCacheHostImpl* host = GetHost(*i); |
| 45 if (host) | 45 if (host) |
| 46 host->OnEventRaised(event_id); | 46 host->OnEventRaised(event_id); |
| 47 } | 47 } |
| 48 } | 48 } |
| 49 | 49 |
| 50 void AppCacheFrontendImpl::OnProgressEventRaised( | 50 void AppCacheFrontendImpl::OnProgressEventRaised( |
| 51 const std::vector<int>& host_ids, | 51 const std::vector<int>& host_ids, |
| 52 const GURL& url, | 52 const GURL& url, |
| 53 int num_total, | 53 int num_total, |
| 54 int num_complete) { | 54 int num_complete) { |
| 55 for (std::vector<int>::const_iterator i = host_ids.begin(); | 55 for (std::vector<int>::const_iterator i = host_ids.begin(); |
| 56 i != host_ids.end(); ++i) { | 56 i != host_ids.end(); ++i) { |
| 57 WebApplicationCacheHostImpl* host = GetHost(*i); | 57 WebApplicationCacheHostImpl* host = GetHost(*i); |
| 58 if (host) | 58 if (host) |
| 59 host->OnProgressEventRaised(url, num_total, num_complete); | 59 host->OnProgressEventRaised(url, num_total, num_complete); |
| 60 } | 60 } |
| 61 } | 61 } |
| 62 | 62 |
| 63 void AppCacheFrontendImpl::OnErrorEventRaised( | 63 void AppCacheFrontendImpl::OnErrorEventRaised( |
| 64 const std::vector<int>& host_ids, | 64 const std::vector<int>& host_ids, |
| 65 const appcache::ErrorDetails& details) { | 65 const appcache::AppCacheErrorDetails& details) { |
| 66 for (std::vector<int>::const_iterator i = host_ids.begin(); | 66 for (std::vector<int>::const_iterator i = host_ids.begin(); |
| 67 i != host_ids.end(); ++i) { | 67 i != host_ids.end(); ++i) { |
| 68 WebApplicationCacheHostImpl* host = GetHost(*i); | 68 WebApplicationCacheHostImpl* host = GetHost(*i); |
| 69 if (host) | 69 if (host) |
| 70 host->OnErrorEventRaised(details); | 70 host->OnErrorEventRaised(details); |
| 71 } | 71 } |
| 72 } | 72 } |
| 73 | 73 |
| 74 void AppCacheFrontendImpl::OnLogMessage(int host_id, | 74 void AppCacheFrontendImpl::OnLogMessage(int host_id, |
| 75 appcache::LogLevel log_level, | 75 appcache::AppCacheLogLevel log_level, |
| 76 const std::string& message) { | 76 const std::string& message) { |
| 77 WebApplicationCacheHostImpl* host = GetHost(host_id); | 77 WebApplicationCacheHostImpl* host = GetHost(host_id); |
| 78 if (host) | 78 if (host) |
| 79 host->OnLogMessage(log_level, message); | 79 host->OnLogMessage(log_level, message); |
| 80 } | 80 } |
| 81 | 81 |
| 82 void AppCacheFrontendImpl::OnContentBlocked(int host_id, | 82 void AppCacheFrontendImpl::OnContentBlocked(int host_id, |
| 83 const GURL& manifest_url) { | 83 const GURL& manifest_url) { |
| 84 WebApplicationCacheHostImpl* host = GetHost(host_id); | 84 WebApplicationCacheHostImpl* host = GetHost(host_id); |
| 85 if (host) | 85 if (host) |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 146 (int)appcache::QUOTA_ERROR, | 146 (int)appcache::QUOTA_ERROR, |
| 147 QuotaError); | 147 QuotaError); |
| 148 COMPILE_ASSERT((int)WebApplicationCacheHost::PolicyError == | 148 COMPILE_ASSERT((int)WebApplicationCacheHost::PolicyError == |
| 149 (int)appcache::POLICY_ERROR, | 149 (int)appcache::POLICY_ERROR, |
| 150 PolicyError); | 150 PolicyError); |
| 151 COMPILE_ASSERT((int)WebApplicationCacheHost::UnknownError == | 151 COMPILE_ASSERT((int)WebApplicationCacheHost::UnknownError == |
| 152 (int)appcache::UNKNOWN_ERROR, | 152 (int)appcache::UNKNOWN_ERROR, |
| 153 UnknownError); | 153 UnknownError); |
| 154 | 154 |
| 155 } // namespace content | 155 } // namespace content |
| OLD | NEW |