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

Side by Side Diff: content/child/resource_dispatcher.cc

Issue 242103007: NOT FOR REVIEW - prioritize fonts Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 8 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
« no previous file with comments | « content/child/resource_dispatcher.h ('k') | content/content_renderer.gypi » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 // See http://dev.chromium.org/developers/design-documents/multi-process-resourc e-loading 5 // See http://dev.chromium.org/developers/design-documents/multi-process-resourc e-loading
6 6
7 #include "content/child/resource_dispatcher.h" 7 #include "content/child/resource_dispatcher.h"
8 8
9 #include "base/basictypes.h" 9 #include "base/basictypes.h"
10 #include "base/bind.h" 10 #include "base/bind.h"
(...skipping 259 matching lines...) Expand 10 before | Expand all | Expand 10 after
270 weak_factory_(this), 270 weak_factory_(this),
271 delegate_(NULL), 271 delegate_(NULL),
272 io_timestamp_(base::TimeTicks()) { 272 io_timestamp_(base::TimeTicks()) {
273 } 273 }
274 274
275 ResourceDispatcher::~ResourceDispatcher() { 275 ResourceDispatcher::~ResourceDispatcher() {
276 } 276 }
277 277
278 // ResourceDispatcher implementation ------------------------------------------ 278 // ResourceDispatcher implementation ------------------------------------------
279 279
280 bool ResourceDispatcher::IsPendingRequestFontType(const IPC::Message& message) {
281 if (!IsResourceDispatcherMessage(message))
282 return false;
283
284 int request_id;
285
286 PickleIterator iter(message);
287 if (!message.ReadInt(&iter, &request_id)) {
288 NOTREACHED() << "malformed resource message";
289 return false;
290 }
291
292 base::AutoLock lock(font_lock_);
293 return font_requests_.find(request_id) != font_requests_.end();
294 }
295
280 bool ResourceDispatcher::OnMessageReceived(const IPC::Message& message) { 296 bool ResourceDispatcher::OnMessageReceived(const IPC::Message& message) {
281 if (!IsResourceDispatcherMessage(message)) { 297 if (!IsResourceDispatcherMessage(message)) {
282 return false; 298 return false;
283 } 299 }
284 300
285 int request_id; 301 int request_id;
286 302
287 PickleIterator iter(message); 303 PickleIterator iter(message);
288 if (!message.ReadInt(&iter, &request_id)) { 304 if (!message.ReadInt(&iter, &request_id)) {
289 NOTREACHED() << "malformed resource message"; 305 NOTREACHED() << "malformed resource message";
(...skipping 269 matching lines...) Expand 10 before | Expand all | Expand 10 after
559 575
560 int ResourceDispatcher::AddPendingRequest(RequestPeer* callback, 576 int ResourceDispatcher::AddPendingRequest(RequestPeer* callback,
561 ResourceType::Type resource_type, 577 ResourceType::Type resource_type,
562 int origin_pid, 578 int origin_pid,
563 const GURL& frame_origin, 579 const GURL& frame_origin,
564 const GURL& request_url) { 580 const GURL& request_url) {
565 // Compute a unique request_id for this renderer process. 581 // Compute a unique request_id for this renderer process.
566 int id = MakeRequestID(); 582 int id = MakeRequestID();
567 pending_requests_[id] = PendingRequestInfo( 583 pending_requests_[id] = PendingRequestInfo(
568 callback, resource_type, origin_pid, frame_origin, request_url); 584 callback, resource_type, origin_pid, frame_origin, request_url);
585 {
586 if (resource_type == ResourceType::FONT_RESOURCE) {
587 base::AutoLock lock(font_lock_);
588 font_requests_.insert(id);
589 }
590 }
569 return id; 591 return id;
570 } 592 }
571 593
572 bool ResourceDispatcher::RemovePendingRequest(int request_id) { 594 bool ResourceDispatcher::RemovePendingRequest(int request_id) {
573 PendingRequestList::iterator it = pending_requests_.find(request_id); 595 PendingRequestList::iterator it = pending_requests_.find(request_id);
574 if (it == pending_requests_.end()) 596 if (it == pending_requests_.end())
575 return false; 597 return false;
576 598
577 PendingRequestInfo& request_info = it->second; 599 PendingRequestInfo& request_info = it->second;
600
601 {
602 base::AutoLock lock(font_lock_);
603 font_requests_.erase(request_id);
604 }
605
578 ReleaseResourcesInMessageQueue(&request_info.deferred_message_queue); 606 ReleaseResourcesInMessageQueue(&request_info.deferred_message_queue);
579 pending_requests_.erase(it); 607 pending_requests_.erase(it);
580 608
581 return true; 609 return true;
582 } 610 }
583 611
584 void ResourceDispatcher::CancelPendingRequest(int request_id) { 612 void ResourceDispatcher::CancelPendingRequest(int request_id) {
585 PendingRequestList::iterator it = pending_requests_.find(request_id); 613 PendingRequestList::iterator it = pending_requests_.find(request_id);
586 if (it == pending_requests_.end()) { 614 if (it == pending_requests_.end()) {
587 DVLOG(1) << "unknown request"; 615 DVLOG(1) << "unknown request";
(...skipping 217 matching lines...) Expand 10 before | Expand all | Expand 10 after
805 void ResourceDispatcher::ReleaseResourcesInMessageQueue(MessageQueue* queue) { 833 void ResourceDispatcher::ReleaseResourcesInMessageQueue(MessageQueue* queue) {
806 while (!queue->empty()) { 834 while (!queue->empty()) {
807 IPC::Message* message = queue->front(); 835 IPC::Message* message = queue->front();
808 ReleaseResourcesInDataMessage(*message); 836 ReleaseResourcesInDataMessage(*message);
809 queue->pop_front(); 837 queue->pop_front();
810 delete message; 838 delete message;
811 } 839 }
812 } 840 }
813 841
814 } // namespace content 842 } // namespace content
OLDNEW
« no previous file with comments | « content/child/resource_dispatcher.h ('k') | content/content_renderer.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698