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

Side by Side Diff: pdf/out_of_process_instance.cc

Issue 2349753003: Improve linearized pdf load/show time. (Closed)
Patch Set: Fix review issues. Created 4 years, 2 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 "pdf/out_of_process_instance.h" 5 #include "pdf/out_of_process_instance.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include <algorithm> // for min/max() 10 #include <algorithm> // for min/max()
(...skipping 834 matching lines...) Expand 10 before | Expand all | Expand 10 after
845 void OutOfProcessInstance::DidOpen(int32_t result) { 845 void OutOfProcessInstance::DidOpen(int32_t result) {
846 if (result == PP_OK) { 846 if (result == PP_OK) {
847 if (!engine_->HandleDocumentLoad(embed_loader_)) { 847 if (!engine_->HandleDocumentLoad(embed_loader_)) {
848 document_load_state_ = LOAD_STATE_LOADING; 848 document_load_state_ = LOAD_STATE_LOADING;
849 DocumentLoadFailed(); 849 DocumentLoadFailed();
850 } 850 }
851 } else if (result != PP_ERROR_ABORTED) { // Can happen in tests. 851 } else if (result != PP_ERROR_ABORTED) { // Can happen in tests.
852 NOTREACHED(); 852 NOTREACHED();
853 DocumentLoadFailed(); 853 DocumentLoadFailed();
854 } 854 }
855
856 // If it's a progressive load, cancel the stream URL request so that requests
857 // can be made on the original URL.
858 // TODO(raymes): Make this clearer once the in-process plugin is deleted.
859 if (engine_->IsProgressiveLoad()) {
860 pp::VarDictionary message;
861 message.Set(kType, kJSCancelStreamUrlType);
862 PostMessage(message);
863 }
864 } 855 }
865 856
866 void OutOfProcessInstance::DidOpenPreview(int32_t result) { 857 void OutOfProcessInstance::DidOpenPreview(int32_t result) {
867 if (result == PP_OK) { 858 if (result == PP_OK) {
868 preview_client_.reset(new PreviewModeClient(this)); 859 preview_client_.reset(new PreviewModeClient(this));
869 preview_engine_.reset(PDFEngine::Create(preview_client_.get())); 860 preview_engine_.reset(PDFEngine::Create(preview_client_.get()));
870 preview_engine_->HandleDocumentLoad(embed_preview_loader_); 861 preview_engine_->HandleDocumentLoad(embed_preview_loader_);
871 } else { 862 } else {
872 NOTREACHED(); 863 NOTREACHED();
873 } 864 }
(...skipping 604 matching lines...) Expand 10 before | Expand all | Expand 10 after
1478 } 1469 }
1479 1470
1480 bool OutOfProcessInstance::IsPrintPreview() { 1471 bool OutOfProcessInstance::IsPrintPreview() {
1481 return IsPrintPreviewUrl(url_); 1472 return IsPrintPreviewUrl(url_);
1482 } 1473 }
1483 1474
1484 uint32_t OutOfProcessInstance::GetBackgroundColor() { 1475 uint32_t OutOfProcessInstance::GetBackgroundColor() {
1485 return background_color_; 1476 return background_color_;
1486 } 1477 }
1487 1478
1479 void OutOfProcessInstance::CancelBrowserDownload() {
1480 pp::VarDictionary message;
1481 message.Set(kType, kJSCancelStreamUrlType);
1482 PostMessage(message);
1483 }
1484
1488 void OutOfProcessInstance::IsSelectingChanged(bool is_selecting) { 1485 void OutOfProcessInstance::IsSelectingChanged(bool is_selecting) {
1489 pp::VarDictionary message; 1486 pp::VarDictionary message;
1490 message.Set(kType, kJSSetIsSelectingType); 1487 message.Set(kType, kJSSetIsSelectingType);
1491 message.Set(kJSIsSelecting, pp::Var(is_selecting)); 1488 message.Set(kJSIsSelecting, pp::Var(is_selecting));
1492 PostMessage(message); 1489 PostMessage(message);
1493 } 1490 }
1494 1491
1495 void OutOfProcessInstance::ProcessPreviewPageInfo(const std::string& url, 1492 void OutOfProcessInstance::ProcessPreviewPageInfo(const std::string& url,
1496 int dst_page_index) { 1493 int dst_page_index) {
1497 if (!IsPrintPreview()) 1494 if (!IsPrintPreview())
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
1534 const pp::FloatPoint& scroll_offset) { 1531 const pp::FloatPoint& scroll_offset) {
1535 float max_x = document_size_.width() * zoom_ - plugin_dip_size_.width(); 1532 float max_x = document_size_.width() * zoom_ - plugin_dip_size_.width();
1536 float x = std::max(std::min(scroll_offset.x(), max_x), 0.0f); 1533 float x = std::max(std::min(scroll_offset.x(), max_x), 0.0f);
1537 float min_y = -top_toolbar_height_; 1534 float min_y = -top_toolbar_height_;
1538 float max_y = document_size_.height() * zoom_ - plugin_dip_size_.height(); 1535 float max_y = document_size_.height() * zoom_ - plugin_dip_size_.height();
1539 float y = std::max(std::min(scroll_offset.y(), max_y), min_y); 1536 float y = std::max(std::min(scroll_offset.y(), max_y), min_y);
1540 return pp::FloatPoint(x, y); 1537 return pp::FloatPoint(x, y);
1541 } 1538 }
1542 1539
1543 } // namespace chrome_pdf 1540 } // namespace chrome_pdf
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698