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

Side by Side Diff: pdf/out_of_process_instance.cc

Issue 2349753003: Improve linearized pdf load/show time. (Closed)
Patch Set: remove useless code. Created 4 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 "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 830 matching lines...) Expand 10 before | Expand all | Expand 10 after
841 void OutOfProcessInstance::DidOpen(int32_t result) { 841 void OutOfProcessInstance::DidOpen(int32_t result) {
842 if (result == PP_OK) { 842 if (result == PP_OK) {
843 if (!engine_->HandleDocumentLoad(embed_loader_)) { 843 if (!engine_->HandleDocumentLoad(embed_loader_)) {
844 document_load_state_ = LOAD_STATE_LOADING; 844 document_load_state_ = LOAD_STATE_LOADING;
845 DocumentLoadFailed(); 845 DocumentLoadFailed();
846 } 846 }
847 } else if (result != PP_ERROR_ABORTED) { // Can happen in tests. 847 } else if (result != PP_ERROR_ABORTED) { // Can happen in tests.
848 NOTREACHED(); 848 NOTREACHED();
849 DocumentLoadFailed(); 849 DocumentLoadFailed();
850 } 850 }
851
852 // If it's a progressive load, cancel the stream URL request so that requests
853 // can be made on the original URL.
854 // TODO(raymes): Make this clearer once the in-process plugin is deleted.
855 if (engine_->IsProgressiveLoad()) {
856 pp::VarDictionary message;
857 message.Set(kType, kJSCancelStreamUrlType);
858 PostMessage(message);
859 }
860 } 851 }
861 852
862 void OutOfProcessInstance::DidOpenPreview(int32_t result) { 853 void OutOfProcessInstance::DidOpenPreview(int32_t result) {
863 if (result == PP_OK) { 854 if (result == PP_OK) {
864 preview_client_.reset(new PreviewModeClient(this)); 855 preview_client_.reset(new PreviewModeClient(this));
865 preview_engine_.reset(PDFEngine::Create(preview_client_.get())); 856 preview_engine_.reset(PDFEngine::Create(preview_client_.get()));
866 preview_engine_->HandleDocumentLoad(embed_preview_loader_); 857 preview_engine_->HandleDocumentLoad(embed_preview_loader_);
867 } else { 858 } else {
868 NOTREACHED(); 859 NOTREACHED();
869 } 860 }
(...skipping 601 matching lines...) Expand 10 before | Expand all | Expand 10 after
1471 } 1462 }
1472 1463
1473 bool OutOfProcessInstance::IsPrintPreview() { 1464 bool OutOfProcessInstance::IsPrintPreview() {
1474 return IsPrintPreviewUrl(url_); 1465 return IsPrintPreviewUrl(url_);
1475 } 1466 }
1476 1467
1477 uint32_t OutOfProcessInstance::GetBackgroundColor() { 1468 uint32_t OutOfProcessInstance::GetBackgroundColor() {
1478 return background_color_; 1469 return background_color_;
1479 } 1470 }
1480 1471
1472 void OutOfProcessInstance::CancelBrowserDownload() {
1473 pp::VarDictionary message;
1474 message.Set(kType, kJSCancelStreamUrlType);
1475 PostMessage(message);
1476 }
1477
1481 void OutOfProcessInstance::IsSelectingChanged(bool is_selecting) { 1478 void OutOfProcessInstance::IsSelectingChanged(bool is_selecting) {
1482 pp::VarDictionary message; 1479 pp::VarDictionary message;
1483 message.Set(kType, kJSSetIsSelectingType); 1480 message.Set(kType, kJSSetIsSelectingType);
1484 message.Set(kJSIsSelecting, pp::Var(is_selecting)); 1481 message.Set(kJSIsSelecting, pp::Var(is_selecting));
1485 PostMessage(message); 1482 PostMessage(message);
1486 } 1483 }
1487 1484
1488 void OutOfProcessInstance::ProcessPreviewPageInfo(const std::string& url, 1485 void OutOfProcessInstance::ProcessPreviewPageInfo(const std::string& url,
1489 int dst_page_index) { 1486 int dst_page_index) {
1490 if (!IsPrintPreview()) 1487 if (!IsPrintPreview())
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
1527 const pp::FloatPoint& scroll_offset) { 1524 const pp::FloatPoint& scroll_offset) {
1528 float max_x = document_size_.width() * zoom_ - plugin_dip_size_.width(); 1525 float max_x = document_size_.width() * zoom_ - plugin_dip_size_.width();
1529 float x = std::max(std::min(scroll_offset.x(), max_x), 0.0f); 1526 float x = std::max(std::min(scroll_offset.x(), max_x), 0.0f);
1530 float min_y = -top_toolbar_height_; 1527 float min_y = -top_toolbar_height_;
1531 float max_y = document_size_.height() * zoom_ - plugin_dip_size_.height(); 1528 float max_y = document_size_.height() * zoom_ - plugin_dip_size_.height();
1532 float y = std::max(std::min(scroll_offset.y(), max_y), min_y); 1529 float y = std::max(std::min(scroll_offset.y(), max_y), min_y);
1533 return pp::FloatPoint(x, y); 1530 return pp::FloatPoint(x, y);
1534 } 1531 }
1535 1532
1536 } // namespace chrome_pdf 1533 } // namespace chrome_pdf
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698