OLD | NEW |
1 /* | 1 /* |
2 Copyright (C) 1998 Lars Knoll (knoll@mpi-hd.mpg.de) | 2 Copyright (C) 1998 Lars Knoll (knoll@mpi-hd.mpg.de) |
3 Copyright (C) 2001 Dirk Mueller (mueller@kde.org) | 3 Copyright (C) 2001 Dirk Mueller (mueller@kde.org) |
4 Copyright (C) 2002 Waldo Bastian (bastian@kde.org) | 4 Copyright (C) 2002 Waldo Bastian (bastian@kde.org) |
5 Copyright (C) 2006 Samuel Weinig (sam.weinig@gmail.com) | 5 Copyright (C) 2006 Samuel Weinig (sam.weinig@gmail.com) |
6 Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc. All | 6 Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc. All |
7 rights reserved. | 7 rights reserved. |
8 | 8 |
9 This library is free software; you can redistribute it and/or | 9 This library is free software; you can redistribute it and/or |
10 modify it under the terms of the GNU Library General Public | 10 modify it under the terms of the GNU Library General Public |
(...skipping 256 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
267 Resource::ResourceCallback& Resource::ResourceCallback::CallbackHandler() { | 267 Resource::ResourceCallback& Resource::ResourceCallback::CallbackHandler() { |
268 DEFINE_STATIC_LOCAL(ResourceCallback, callback_handler, ()); | 268 DEFINE_STATIC_LOCAL(ResourceCallback, callback_handler, ()); |
269 return callback_handler; | 269 return callback_handler; |
270 } | 270 } |
271 | 271 |
272 Resource::ResourceCallback::ResourceCallback() {} | 272 Resource::ResourceCallback::ResourceCallback() {} |
273 | 273 |
274 void Resource::ResourceCallback::Schedule(Resource* resource) { | 274 void Resource::ResourceCallback::Schedule(Resource* resource) { |
275 if (!task_handle_.IsActive()) { | 275 if (!task_handle_.IsActive()) { |
276 // WTF::unretained(this) is safe because a posted task is canceled when | 276 // WTF::unretained(this) is safe because a posted task is canceled when |
277 // |m_taskHandle| is destroyed on the dtor of this ResourceCallback. | 277 // |task_handle_| is destroyed on the dtor of this ResourceCallback. |
278 task_handle_ = | 278 task_handle_ = |
279 Platform::Current() | 279 Platform::Current() |
280 ->CurrentThread() | 280 ->CurrentThread() |
281 ->Scheduler() | 281 ->Scheduler() |
282 ->LoadingTaskRunner() | 282 ->LoadingTaskRunner() |
283 ->PostCancellableTask( | 283 ->PostCancellableTask( |
284 BLINK_FROM_HERE, | 284 BLINK_FROM_HERE, |
285 WTF::Bind(&ResourceCallback::RunTask, WTF::Unretained(this))); | 285 WTF::Bind(&ResourceCallback::RunTask, WTF::Unretained(this))); |
286 } | 286 } |
287 resources_with_pending_clients_.insert(resource); | 287 resources_with_pending_clients_.insert(resource); |
(...skipping 343 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
631 } | 631 } |
632 if (!finished_clients_.IsEmpty()) { | 632 if (!finished_clients_.IsEmpty()) { |
633 builder.Append(", Finished="); | 633 builder.Append(", Finished="); |
634 builder.AppendNumber(finished_clients_.size()); | 634 builder.AppendNumber(finished_clients_.size()); |
635 } | 635 } |
636 builder.Append(')'); | 636 builder.Append(')'); |
637 } | 637 } |
638 if (loader_) { | 638 if (loader_) { |
639 if (!builder.IsEmpty()) | 639 if (!builder.IsEmpty()) |
640 builder.Append(' '); | 640 builder.Append(' '); |
641 builder.Append("m_loader"); | 641 builder.Append("loader_"); |
642 } | 642 } |
643 if (preload_count_) { | 643 if (preload_count_) { |
644 if (!builder.IsEmpty()) | 644 if (!builder.IsEmpty()) |
645 builder.Append(' '); | 645 builder.Append(' '); |
646 builder.Append("m_preloadCount("); | 646 builder.Append("preload_count_("); |
647 builder.AppendNumber(preload_count_); | 647 builder.AppendNumber(preload_count_); |
648 builder.Append(')'); | 648 builder.Append(')'); |
649 } | 649 } |
650 if (GetMemoryCache()->Contains(this)) { | 650 if (GetMemoryCache()->Contains(this)) { |
651 if (!builder.IsEmpty()) | 651 if (!builder.IsEmpty()) |
652 builder.Append(' '); | 652 builder.Append(' '); |
653 builder.Append("in_memory_cache"); | 653 builder.Append("in_memory_cache"); |
654 } | 654 } |
655 return builder.ToString(); | 655 return builder.ToString(); |
656 } | 656 } |
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
801 void Resource::FinishPendingClients() { | 801 void Resource::FinishPendingClients() { |
802 // We're going to notify clients one by one. It is simple if the client does | 802 // We're going to notify clients one by one. It is simple if the client does |
803 // nothing. However there are a couple other things that can happen. | 803 // nothing. However there are a couple other things that can happen. |
804 // | 804 // |
805 // 1. Clients can be added during the loop. Make sure they are not processed. | 805 // 1. Clients can be added during the loop. Make sure they are not processed. |
806 // 2. Clients can be removed during the loop. Make sure they are always | 806 // 2. Clients can be removed during the loop. Make sure they are always |
807 // available to be removed. Also don't call removed clients or add them | 807 // available to be removed. Also don't call removed clients or add them |
808 // back. | 808 // back. |
809 // | 809 // |
810 // Handle case (1) by saving a list of clients to notify. A separate list also | 810 // Handle case (1) by saving a list of clients to notify. A separate list also |
811 // ensure a client is either in m_clients or m_clientsAwaitingCallback. | 811 // ensure a client is either in cliens_ or clients_awaiting_callback_. |
812 HeapVector<Member<ResourceClient>> clients_to_notify; | 812 HeapVector<Member<ResourceClient>> clients_to_notify; |
813 CopyToVector(clients_awaiting_callback_, clients_to_notify); | 813 CopyToVector(clients_awaiting_callback_, clients_to_notify); |
814 | 814 |
815 for (const auto& client : clients_to_notify) { | 815 for (const auto& client : clients_to_notify) { |
816 // Handle case (2) to skip removed clients. | 816 // Handle case (2) to skip removed clients. |
817 if (!clients_awaiting_callback_.erase(client)) | 817 if (!clients_awaiting_callback_.erase(client)) |
818 continue; | 818 continue; |
819 clients_.insert(client); | 819 clients_.insert(client); |
820 | 820 |
821 // When revalidation starts after waiting clients are scheduled and | 821 // When revalidation starts after waiting clients are scheduled and |
822 // before they are added here. In such cases, we just add the clients | 822 // before they are added here. In such cases, we just add the clients |
823 // to |m_clients| without didAddClient(), as in Resource::addClient(). | 823 // to |clients_| without DidAddClient(), as in Resource::AddClient(). |
824 if (!is_revalidating_) | 824 if (!is_revalidating_) |
825 DidAddClient(client); | 825 DidAddClient(client); |
826 } | 826 } |
827 | 827 |
828 // It is still possible for the above loop to finish a new client | 828 // It is still possible for the above loop to finish a new client |
829 // synchronously. If there's no client waiting we should deschedule. | 829 // synchronously. If there's no client waiting we should deschedule. |
830 bool scheduled = ResourceCallback::CallbackHandler().IsScheduled(this); | 830 bool scheduled = ResourceCallback::CallbackHandler().IsScheduled(this); |
831 if (scheduled && clients_awaiting_callback_.IsEmpty()) | 831 if (scheduled && clients_awaiting_callback_.IsEmpty()) |
832 ResourceCallback::CallbackHandler().Cancel(this); | 832 ResourceCallback::CallbackHandler().Cancel(this); |
833 | 833 |
(...skipping 286 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1120 case Resource::kMedia: | 1120 case Resource::kMedia: |
1121 case Resource::kManifest: | 1121 case Resource::kManifest: |
1122 case Resource::kMock: | 1122 case Resource::kMock: |
1123 return false; | 1123 return false; |
1124 } | 1124 } |
1125 NOTREACHED(); | 1125 NOTREACHED(); |
1126 return false; | 1126 return false; |
1127 } | 1127 } |
1128 | 1128 |
1129 } // namespace blink | 1129 } // namespace blink |
OLD | NEW |