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 270 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
281 (*it)->set_classification(NORMAL_REQUEST); | 281 (*it)->set_classification(NORMAL_REQUEST); |
282 } | 282 } |
283 ClearInFlightRequests(); | 283 ClearInFlightRequests(); |
284 return unowned_requests; | 284 return unowned_requests; |
285 } | 285 } |
286 | 286 |
287 bool is_active() const { return is_visible_ || is_audible_; } | 287 bool is_active() const { return is_visible_ || is_audible_; } |
288 | 288 |
289 bool is_loaded() const { return is_loaded_; } | 289 bool is_loaded() const { return is_loaded_; } |
290 | 290 |
291 bool IsVisible() const { return is_visible_; } | 291 bool is_visible() const { return is_visible_; } |
292 | 292 |
293 void OnAudibilityChanged(bool is_audible) { | 293 void OnAudibilityChanged(bool is_audible) { |
294 if (is_audible == is_audible_) { | 294 if (is_audible == is_audible_) { |
295 return; | 295 return; |
296 } | 296 } |
297 is_audible_ = is_audible; | 297 is_audible_ = is_audible; |
298 UpdateThrottleState(); | 298 UpdateThrottleState(); |
299 } | 299 } |
300 | 300 |
301 void OnVisibilityChanged(bool is_visible) { | 301 void OnVisibilityChanged(bool is_visible) { |
(...skipping 582 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
884 int route_id, | 884 int route_id, |
885 bool is_loaded) { | 885 bool is_loaded) { |
886 Client* client = GetClient(child_id, route_id); | 886 Client* client = GetClient(child_id, route_id); |
887 DCHECK(client); | 887 DCHECK(client); |
888 client->OnLoadingStateChanged(is_loaded); | 888 client->OnLoadingStateChanged(is_loaded); |
889 } | 889 } |
890 | 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->IsVisible(); | 894 return client->is_visible(); |
| 895 } |
| 896 |
| 897 bool ResourceScheduler::IsClientLoadedForTesting(int child_id, int route_id) { |
| 898 Client* client = GetClient(child_id, route_id); |
| 899 DCHECK(client); |
| 900 return client->is_loaded(); |
895 } | 901 } |
896 | 902 |
897 ResourceScheduler::Client* ResourceScheduler::GetClient(int child_id, | 903 ResourceScheduler::Client* ResourceScheduler::GetClient(int child_id, |
898 int route_id) { | 904 int route_id) { |
899 ClientId client_id = MakeClientId(child_id, route_id); | 905 ClientId client_id = MakeClientId(child_id, route_id); |
900 ClientMap::iterator client_it = client_map_.find(client_id); | 906 ClientMap::iterator client_it = client_map_.find(client_id); |
901 if (client_it == client_map_.end()) { | 907 if (client_it == client_map_.end()) { |
902 return NULL; | 908 return NULL; |
903 } | 909 } |
904 return client_it->second; | 910 return client_it->second; |
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1021 client->ReprioritizeRequest( | 1027 client->ReprioritizeRequest( |
1022 request, old_priority_params, new_priority_params); | 1028 request, old_priority_params, new_priority_params); |
1023 } | 1029 } |
1024 | 1030 |
1025 ResourceScheduler::ClientId ResourceScheduler::MakeClientId( | 1031 ResourceScheduler::ClientId ResourceScheduler::MakeClientId( |
1026 int child_id, int route_id) { | 1032 int child_id, int route_id) { |
1027 return (static_cast<ResourceScheduler::ClientId>(child_id) << 32) | route_id; | 1033 return (static_cast<ResourceScheduler::ClientId>(child_id) << 32) | route_id; |
1028 } | 1034 } |
1029 | 1035 |
1030 } // namespace content | 1036 } // namespace content |
OLD | NEW |