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

Side by Side Diff: pdf/out_of_process_instance.cc

Issue 2349753003: Improve linearized pdf load/show time. (Closed)
Patch Set: rebase Created 4 years, 1 month 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 | « pdf/out_of_process_instance.h ('k') | pdf/pdf_engine.h » ('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 #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 837 matching lines...) Expand 10 before | Expand all | Expand 10 after
848 void OutOfProcessInstance::DidOpen(int32_t result) { 848 void OutOfProcessInstance::DidOpen(int32_t result) {
849 if (result == PP_OK) { 849 if (result == PP_OK) {
850 if (!engine_->HandleDocumentLoad(embed_loader_)) { 850 if (!engine_->HandleDocumentLoad(embed_loader_)) {
851 document_load_state_ = LOAD_STATE_LOADING; 851 document_load_state_ = LOAD_STATE_LOADING;
852 DocumentLoadFailed(); 852 DocumentLoadFailed();
853 } 853 }
854 } else if (result != PP_ERROR_ABORTED) { // Can happen in tests. 854 } else if (result != PP_ERROR_ABORTED) { // Can happen in tests.
855 NOTREACHED(); 855 NOTREACHED();
856 DocumentLoadFailed(); 856 DocumentLoadFailed();
857 } 857 }
858
859 // If it's a progressive load, cancel the stream URL request so that requests
860 // can be made on the original URL.
861 // TODO(raymes): Make this clearer once the in-process plugin is deleted.
862 if (engine_->IsProgressiveLoad()) {
863 pp::VarDictionary message;
864 message.Set(kType, kJSCancelStreamUrlType);
865 PostMessage(message);
866 }
867 } 858 }
868 859
869 void OutOfProcessInstance::DidOpenPreview(int32_t result) { 860 void OutOfProcessInstance::DidOpenPreview(int32_t result) {
870 if (result == PP_OK) { 861 if (result == PP_OK) {
871 preview_client_.reset(new PreviewModeClient(this)); 862 preview_client_.reset(new PreviewModeClient(this));
872 preview_engine_.reset(PDFEngine::Create(preview_client_.get())); 863 preview_engine_.reset(PDFEngine::Create(preview_client_.get()));
873 preview_engine_->HandleDocumentLoad(embed_preview_loader_); 864 preview_engine_->HandleDocumentLoad(embed_preview_loader_);
874 } else { 865 } else {
875 NOTREACHED(); 866 NOTREACHED();
876 } 867 }
(...skipping 617 matching lines...) Expand 10 before | Expand all | Expand 10 after
1494 } 1485 }
1495 1486
1496 bool OutOfProcessInstance::IsPrintPreview() { 1487 bool OutOfProcessInstance::IsPrintPreview() {
1497 return IsPrintPreviewUrl(url_); 1488 return IsPrintPreviewUrl(url_);
1498 } 1489 }
1499 1490
1500 uint32_t OutOfProcessInstance::GetBackgroundColor() { 1491 uint32_t OutOfProcessInstance::GetBackgroundColor() {
1501 return background_color_; 1492 return background_color_;
1502 } 1493 }
1503 1494
1495 void OutOfProcessInstance::CancelBrowserDownload() {
1496 pp::VarDictionary message;
1497 message.Set(kType, kJSCancelStreamUrlType);
1498 PostMessage(message);
1499 }
1500
1504 void OutOfProcessInstance::IsSelectingChanged(bool is_selecting) { 1501 void OutOfProcessInstance::IsSelectingChanged(bool is_selecting) {
1505 pp::VarDictionary message; 1502 pp::VarDictionary message;
1506 message.Set(kType, kJSSetIsSelectingType); 1503 message.Set(kType, kJSSetIsSelectingType);
1507 message.Set(kJSIsSelecting, pp::Var(is_selecting)); 1504 message.Set(kJSIsSelecting, pp::Var(is_selecting));
1508 PostMessage(message); 1505 PostMessage(message);
1509 } 1506 }
1510 1507
1511 void OutOfProcessInstance::ProcessPreviewPageInfo(const std::string& url, 1508 void OutOfProcessInstance::ProcessPreviewPageInfo(const std::string& url,
1512 int dst_page_index) { 1509 int dst_page_index) {
1513 if (!IsPrintPreview()) 1510 if (!IsPrintPreview())
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
1550 const pp::FloatPoint& scroll_offset) { 1547 const pp::FloatPoint& scroll_offset) {
1551 float max_x = document_size_.width() * zoom_ - plugin_dip_size_.width(); 1548 float max_x = document_size_.width() * zoom_ - plugin_dip_size_.width();
1552 float x = std::max(std::min(scroll_offset.x(), max_x), 0.0f); 1549 float x = std::max(std::min(scroll_offset.x(), max_x), 0.0f);
1553 float min_y = -top_toolbar_height_; 1550 float min_y = -top_toolbar_height_;
1554 float max_y = document_size_.height() * zoom_ - plugin_dip_size_.height(); 1551 float max_y = document_size_.height() * zoom_ - plugin_dip_size_.height();
1555 float y = std::max(std::min(scroll_offset.y(), max_y), min_y); 1552 float y = std::max(std::min(scroll_offset.y(), max_y), min_y);
1556 return pp::FloatPoint(x, y); 1553 return pp::FloatPoint(x, y);
1557 } 1554 }
1558 1555
1559 } // namespace chrome_pdf 1556 } // namespace chrome_pdf
OLDNEW
« no previous file with comments | « pdf/out_of_process_instance.h ('k') | pdf/pdf_engine.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698