OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 <set> | 5 #include <set> |
6 | 6 |
7 #include "content/browser/loader/resource_scheduler.h" | 7 #include "content/browser/loader/resource_scheduler.h" |
8 | 8 |
9 #include "base/stl_util.h" | 9 #include "base/stl_util.h" |
10 #include "content/common/resource_messages.h" | 10 #include "content/common/resource_messages.h" |
(...skipping 803 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
814 RequestSet client_unowned_requests = client->RemoveAllRequests(); | 814 RequestSet client_unowned_requests = client->RemoveAllRequests(); |
815 for (RequestSet::iterator it = client_unowned_requests.begin(); | 815 for (RequestSet::iterator it = client_unowned_requests.begin(); |
816 it != client_unowned_requests.end(); ++it) { | 816 it != client_unowned_requests.end(); ++it) { |
817 unowned_requests_.insert(*it); | 817 unowned_requests_.insert(*it); |
818 } | 818 } |
819 | 819 |
820 delete client; | 820 delete client; |
821 client_map_.erase(it); | 821 client_map_.erase(it); |
822 } | 822 } |
823 | 823 |
| 824 void ResourceScheduler::OnLoadingStateChanged(int child_id, |
| 825 int route_id, |
| 826 bool is_loaded) { |
| 827 Client* client = GetClient(child_id, route_id); |
| 828 DCHECK(client); |
| 829 client->OnLoadingStateChanged(is_loaded); |
| 830 } |
| 831 |
824 void ResourceScheduler::OnVisibilityChanged(int child_id, | 832 void ResourceScheduler::OnVisibilityChanged(int child_id, |
825 int route_id, | 833 int route_id, |
826 bool is_visible) { | 834 bool is_visible) { |
827 Client* client = GetClient(child_id, route_id); | 835 Client* client = GetClient(child_id, route_id); |
828 DCHECK(client); | 836 DCHECK(client); |
829 client->OnVisibilityChanged(is_visible); | 837 client->OnVisibilityChanged(is_visible); |
830 } | 838 } |
831 | 839 |
832 void ResourceScheduler::OnLoadingStateChanged(int child_id, | 840 void ResourceScheduler::OnAudibilityChanged(int child_id, |
833 int route_id, | 841 int route_id, |
834 bool is_loaded) { | 842 bool is_audible) { |
835 Client* client = GetClient(child_id, route_id); | 843 Client* client = GetClient(child_id, route_id); |
836 DCHECK(client); | 844 DCHECK(client); |
837 client->OnLoadingStateChanged(is_loaded); | 845 client->OnAudibilityChanged(is_audible); |
838 } | 846 } |
839 | 847 |
840 void ResourceScheduler::OnNavigate(int child_id, int route_id) { | 848 void ResourceScheduler::OnNavigate(int child_id, int route_id) { |
841 DCHECK(CalledOnValidThread()); | 849 DCHECK(CalledOnValidThread()); |
842 ClientId client_id = MakeClientId(child_id, route_id); | 850 ClientId client_id = MakeClientId(child_id, route_id); |
843 | 851 |
844 ClientMap::iterator it = client_map_.find(client_id); | 852 ClientMap::iterator it = client_map_.find(client_id); |
845 if (it == client_map_.end()) { | 853 if (it == client_map_.end()) { |
846 // The client was likely deleted shortly before we received this IPC. | 854 // The client was likely deleted shortly before we received this IPC. |
847 return; | 855 return; |
(...skipping 25 matching lines...) Expand all Loading... |
873 | 881 |
874 ClientMap::iterator client_it = client_map_.find(client_id); | 882 ClientMap::iterator client_it = client_map_.find(client_id); |
875 if (client_it == client_map_.end()) { | 883 if (client_it == client_map_.end()) { |
876 return; | 884 return; |
877 } | 885 } |
878 | 886 |
879 Client* client = client_it->second; | 887 Client* client = client_it->second; |
880 client->OnReceivedSpdyProxiedHttpResponse(); | 888 client->OnReceivedSpdyProxiedHttpResponse(); |
881 } | 889 } |
882 | 890 |
883 void ResourceScheduler::OnAudibilityChanged(int child_id, | |
884 int route_id, | |
885 bool is_audible) { | |
886 Client* client = GetClient(child_id, route_id); | |
887 DCHECK(client); | |
888 client->OnAudibilityChanged(is_audible); | |
889 } | |
890 | |
891 bool ResourceScheduler::IsClientVisibleForTesting(int child_id, int route_id) { | 891 bool ResourceScheduler::IsClientVisibleForTesting(int child_id, int route_id) { |
892 Client* client = GetClient(child_id, route_id); | 892 Client* client = GetClient(child_id, route_id); |
893 DCHECK(client); | 893 DCHECK(client); |
894 return client->is_visible(); | 894 return client->is_visible(); |
895 } | 895 } |
896 | 896 |
897 ResourceScheduler::Client* ResourceScheduler::GetClient(int child_id, | 897 ResourceScheduler::Client* ResourceScheduler::GetClient(int child_id, |
898 int route_id) { | 898 int route_id) { |
899 ClientId client_id = MakeClientId(child_id, route_id); | 899 ClientId client_id = MakeClientId(child_id, route_id); |
900 ClientMap::iterator client_it = client_map_.find(client_id); | 900 ClientMap::iterator client_it = client_map_.find(client_id); |
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1021 client->ReprioritizeRequest( | 1021 client->ReprioritizeRequest( |
1022 request, old_priority_params, new_priority_params); | 1022 request, old_priority_params, new_priority_params); |
1023 } | 1023 } |
1024 | 1024 |
1025 ResourceScheduler::ClientId ResourceScheduler::MakeClientId( | 1025 ResourceScheduler::ClientId ResourceScheduler::MakeClientId( |
1026 int child_id, int route_id) { | 1026 int child_id, int route_id) { |
1027 return (static_cast<ResourceScheduler::ClientId>(child_id) << 32) | route_id; | 1027 return (static_cast<ResourceScheduler::ClientId>(child_id) << 32) | route_id; |
1028 } | 1028 } |
1029 | 1029 |
1030 } // namespace content | 1030 } // namespace content |
OLD | NEW |