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

Side by Side Diff: components/nacl/renderer/ppb_nacl_private_impl.cc

Issue 433633003: Pepper: Fix renderer crash on plugin destruction. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: add comment for dmichael Created 6 years, 4 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 "components/nacl/renderer/ppb_nacl_private_impl.h" 5 #include "components/nacl/renderer/ppb_nacl_private_impl.h"
6 6
7 #include <numeric> 7 #include <numeric>
8 #include <string> 8 #include <string>
9 #include <vector> 9 #include <vector>
10 10
(...skipping 1517 matching lines...) Expand 10 before | Expand all | Expand 10 after
1528 DownloadFile(instance, url, 1528 DownloadFile(instance, url,
1529 base::Bind(&DidOpenManifestEntry, out_file_info, callback)); 1529 base::Bind(&DidOpenManifestEntry, out_file_info, callback));
1530 } 1530 }
1531 1531
1532 void SetPNaClStartTime(PP_Instance instance) { 1532 void SetPNaClStartTime(PP_Instance instance) {
1533 NexeLoadManager* load_manager = GetNexeLoadManager(instance); 1533 NexeLoadManager* load_manager = GetNexeLoadManager(instance);
1534 if (load_manager) 1534 if (load_manager)
1535 load_manager->set_pnacl_start_time(base::Time::Now()); 1535 load_manager->set_pnacl_start_time(base::Time::Now());
1536 } 1536 }
1537 1537
1538 // PexeDownloader is responsible for deleting itself when the download
1539 // finishes.
1538 class PexeDownloader : public blink::WebURLLoaderClient { 1540 class PexeDownloader : public blink::WebURLLoaderClient {
1539 public: 1541 public:
1540 PexeDownloader(PP_Instance instance, 1542 PexeDownloader(PP_Instance instance,
1541 scoped_ptr<blink::WebURLLoader> url_loader, 1543 scoped_ptr<blink::WebURLLoader> url_loader,
1542 const std::string& pexe_url, 1544 const std::string& pexe_url,
1543 int32_t pexe_opt_level, 1545 int32_t pexe_opt_level,
1544 const PPP_PexeStreamHandler* stream_handler, 1546 const PPP_PexeStreamHandler* stream_handler,
1545 void* stream_handler_user_data) 1547 void* stream_handler_user_data)
1546 : instance_(instance), 1548 : instance_(instance),
1547 url_loader_(url_loader.Pass()), 1549 url_loader_(url_loader.Pass()),
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
1595 last_modified_time, 1597 last_modified_time,
1596 etag, 1598 etag,
1597 has_no_store_header, 1599 has_no_store_header,
1598 base::Bind(&PexeDownloader::didGetNexeFd, 1600 base::Bind(&PexeDownloader::didGetNexeFd,
1599 weak_factory_.GetWeakPtr())); 1601 weak_factory_.GetWeakPtr()));
1600 } 1602 }
1601 1603
1602 virtual void didGetNexeFd(int32_t pp_error, 1604 virtual void didGetNexeFd(int32_t pp_error,
1603 bool cache_hit, 1605 bool cache_hit,
1604 PP_FileHandle file_handle) { 1606 PP_FileHandle file_handle) {
1607 if (!content::PepperPluginInstance::Get(instance_)) {
1608 delete this;
1609 return;
1610 }
1611
1605 HistogramEnumerate("NaCl.Perf.PNaClCache.IsHit", cache_hit, 2); 1612 HistogramEnumerate("NaCl.Perf.PNaClCache.IsHit", cache_hit, 2);
1606 if (cache_hit) { 1613 if (cache_hit) {
1607 stream_handler_->DidCacheHit(stream_handler_user_data_, file_handle); 1614 stream_handler_->DidCacheHit(stream_handler_user_data_, file_handle);
1608 1615
1609 // We delete the PexeDownloader at this point since we successfully got a 1616 // We delete the PexeDownloader at this point since we successfully got a
1610 // cached, translated nexe. 1617 // cached, translated nexe.
1611 delete this; 1618 delete this;
1612 return; 1619 return;
1613 } 1620 }
1614 stream_handler_->DidCacheMiss(stream_handler_user_data_, 1621 stream_handler_->DidCacheMiss(stream_handler_user_data_,
1615 expected_content_length_); 1622 expected_content_length_);
1616 1623
1617 // No translated nexe was found in the cache, so we should download the 1624 // No translated nexe was found in the cache, so we should download the
1618 // file to start streaming it. 1625 // file to start streaming it.
1619 url_loader_->setDefersLoading(false); 1626 url_loader_->setDefersLoading(false);
1620 } 1627 }
1621 1628
1622 virtual void didReceiveData(blink::WebURLLoader* loader, 1629 virtual void didReceiveData(blink::WebURLLoader* loader,
1623 const char* data, 1630 const char* data,
1624 int data_length, 1631 int data_length,
1625 int encoded_data_length) { 1632 int encoded_data_length) {
1626 // Stream the data we received to the stream callback. 1633 if (content::PepperPluginInstance::Get(instance_)) {
1627 stream_handler_->DidStreamData(stream_handler_user_data_, 1634 // Stream the data we received to the stream callback.
1628 data, 1635 stream_handler_->DidStreamData(stream_handler_user_data_,
1629 data_length); 1636 data,
1637 data_length);
1638 }
1630 } 1639 }
1631 1640
1632 virtual void didFinishLoading(blink::WebURLLoader* loader, 1641 virtual void didFinishLoading(blink::WebURLLoader* loader,
1633 double finish_time, 1642 double finish_time,
1634 int64_t total_encoded_data_length) { 1643 int64_t total_encoded_data_length) {
1635 int32_t result = success_ ? PP_OK : PP_ERROR_FAILED; 1644 int32_t result = success_ ? PP_OK : PP_ERROR_FAILED;
1636 stream_handler_->DidFinishStream(stream_handler_user_data_, result); 1645
1646 if (content::PepperPluginInstance::Get(instance_))
1647 stream_handler_->DidFinishStream(stream_handler_user_data_, result);
1637 delete this; 1648 delete this;
1638 } 1649 }
1639 1650
1640 virtual void didFail(blink::WebURLLoader* loader, 1651 virtual void didFail(blink::WebURLLoader* loader,
1641 const blink::WebURLError& error) { 1652 const blink::WebURLError& error) {
1642 success_ = false; 1653 success_ = false;
1643 } 1654 }
1644 1655
1645 PP_Instance instance_; 1656 PP_Instance instance_;
1646 scoped_ptr<blink::WebURLLoader> url_loader_; 1657 scoped_ptr<blink::WebURLLoader> url_loader_;
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
1733 &StreamPexe 1744 &StreamPexe
1734 }; 1745 };
1735 1746
1736 } // namespace 1747 } // namespace
1737 1748
1738 const PPB_NaCl_Private* GetNaClPrivateInterface() { 1749 const PPB_NaCl_Private* GetNaClPrivateInterface() {
1739 return &nacl_interface; 1750 return &nacl_interface;
1740 } 1751 }
1741 1752
1742 } // namespace nacl 1753 } // namespace nacl
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698