Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(76)

Side by Side Diff: content/browser/loader/resource_scheduler.cc

Issue 501703002: Hook up loading signal to ResourceScheduler. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@zhen_visibility
Patch Set: Removed unused testing function. Created 6 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
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 512 matching lines...) Expand 10 before | Expand all | Expand 10 after
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::OnVisibilityChanged(int child_id,
825 int route_id,
826 bool is_visible) {
827 Client* client = GetClient(child_id, route_id);
828 DCHECK(client);
829 client->OnVisibilityChanged(is_visible);
830 }
831
832 void ResourceScheduler::OnLoadingStateChanged(int child_id,
833 int route_id,
834 bool is_loaded) {
835 Client* client = GetClient(child_id, route_id);
836 DCHECK(client);
837 client->OnLoadingStateChanged(is_loaded);
838 }
839
824 void ResourceScheduler::OnNavigate(int child_id, int route_id) { 840 void ResourceScheduler::OnNavigate(int child_id, int route_id) {
825 DCHECK(CalledOnValidThread()); 841 DCHECK(CalledOnValidThread());
826 ClientId client_id = MakeClientId(child_id, route_id); 842 ClientId client_id = MakeClientId(child_id, route_id);
827 843
828 ClientMap::iterator it = client_map_.find(client_id); 844 ClientMap::iterator it = client_map_.find(client_id);
829 if (it == client_map_.end()) { 845 if (it == client_map_.end()) {
830 // The client was likely deleted shortly before we received this IPC. 846 // The client was likely deleted shortly before we received this IPC.
831 return; 847 return;
832 } 848 }
833 849
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
865 } 881 }
866 882
867 void ResourceScheduler::OnAudibilityChanged(int child_id, 883 void ResourceScheduler::OnAudibilityChanged(int child_id,
868 int route_id, 884 int route_id,
869 bool is_audible) { 885 bool is_audible) {
870 Client* client = GetClient(child_id, route_id); 886 Client* client = GetClient(child_id, route_id);
871 DCHECK(client); 887 DCHECK(client);
872 client->OnAudibilityChanged(is_audible); 888 client->OnAudibilityChanged(is_audible);
873 } 889 }
874 890
875 void ResourceScheduler::OnVisibilityChanged(int child_id,
876 int route_id,
877 bool is_visible) {
878 Client* client = GetClient(child_id, route_id);
879 DCHECK(client);
880 client->OnVisibilityChanged(is_visible);
881 }
882
883 void ResourceScheduler::OnLoadingStateChanged(int child_id,
884 int route_id,
885 bool is_loaded) {
886 Client* client = GetClient(child_id, route_id);
887 DCHECK(client);
888 client->OnLoadingStateChanged(is_loaded);
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->IsVisible(); 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);
901 if (client_it == client_map_.end()) { 901 if (client_it == client_map_.end()) {
902 return NULL; 902 return NULL;
903 } 903 }
904 return client_it->second; 904 return client_it->second;
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after
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
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698