OLD | NEW |
---|---|
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 1578 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1589 has_no_store_header = true; | 1589 has_no_store_header = true; |
1590 } | 1590 } |
1591 | 1591 |
1592 GetNexeFd(instance_, | 1592 GetNexeFd(instance_, |
1593 pexe_url_, | 1593 pexe_url_, |
1594 pexe_opt_level_, | 1594 pexe_opt_level_, |
1595 last_modified_time, | 1595 last_modified_time, |
1596 etag, | 1596 etag, |
1597 has_no_store_header, | 1597 has_no_store_header, |
1598 base::Bind(&PexeDownloader::didGetNexeFd, | 1598 base::Bind(&PexeDownloader::didGetNexeFd, |
1599 weak_factory_.GetWeakPtr())); | 1599 weak_factory_.GetWeakPtr())); |
dmichael (off chromium)
2014/08/04 20:58:48
nit: I just realized this could probably be base::
| |
1600 } | 1600 } |
1601 | 1601 |
1602 virtual void didGetNexeFd(int32_t pp_error, | 1602 virtual void didGetNexeFd(int32_t pp_error, |
1603 bool cache_hit, | 1603 bool cache_hit, |
1604 PP_FileHandle file_handle) { | 1604 PP_FileHandle file_handle) { |
1605 if (!content::PepperPluginInstance::Get(instance_)) { | |
1606 delete this; | |
1607 return; | |
1608 } | |
1609 | |
1605 HistogramEnumerate("NaCl.Perf.PNaClCache.IsHit", cache_hit, 2); | 1610 HistogramEnumerate("NaCl.Perf.PNaClCache.IsHit", cache_hit, 2); |
1606 if (cache_hit) { | 1611 if (cache_hit) { |
1607 stream_handler_->DidCacheHit(stream_handler_user_data_, file_handle); | 1612 stream_handler_->DidCacheHit(stream_handler_user_data_, file_handle); |
1608 | 1613 |
1609 // We delete the PexeDownloader at this point since we successfully got a | 1614 // We delete the PexeDownloader at this point since we successfully got a |
1610 // cached, translated nexe. | 1615 // cached, translated nexe. |
1611 delete this; | 1616 delete this; |
1612 return; | 1617 return; |
1613 } | 1618 } |
1614 stream_handler_->DidCacheMiss(stream_handler_user_data_, | 1619 stream_handler_->DidCacheMiss(stream_handler_user_data_, |
1615 expected_content_length_); | 1620 expected_content_length_); |
1616 | 1621 |
1617 // No translated nexe was found in the cache, so we should download the | 1622 // No translated nexe was found in the cache, so we should download the |
1618 // file to start streaming it. | 1623 // file to start streaming it. |
1619 url_loader_->setDefersLoading(false); | 1624 url_loader_->setDefersLoading(false); |
1620 } | 1625 } |
1621 | 1626 |
1622 virtual void didReceiveData(blink::WebURLLoader* loader, | 1627 virtual void didReceiveData(blink::WebURLLoader* loader, |
1623 const char* data, | 1628 const char* data, |
1624 int data_length, | 1629 int data_length, |
1625 int encoded_data_length) { | 1630 int encoded_data_length) { |
1626 // Stream the data we received to the stream callback. | 1631 if (content::PepperPluginInstance::Get(instance_)) { |
1627 stream_handler_->DidStreamData(stream_handler_user_data_, | 1632 // Stream the data we received to the stream callback. |
1628 data, | 1633 stream_handler_->DidStreamData(stream_handler_user_data_, |
1629 data_length); | 1634 data, |
1635 data_length); | |
1636 } | |
1630 } | 1637 } |
1631 | 1638 |
1632 virtual void didFinishLoading(blink::WebURLLoader* loader, | 1639 virtual void didFinishLoading(blink::WebURLLoader* loader, |
1633 double finish_time, | 1640 double finish_time, |
1634 int64_t total_encoded_data_length) { | 1641 int64_t total_encoded_data_length) { |
1635 int32_t result = success_ ? PP_OK : PP_ERROR_FAILED; | 1642 int32_t result = success_ ? PP_OK : PP_ERROR_FAILED; |
1636 stream_handler_->DidFinishStream(stream_handler_user_data_, result); | 1643 |
1644 if (content::PepperPluginInstance::Get(instance_)) | |
1645 stream_handler_->DidFinishStream(stream_handler_user_data_, result); | |
1637 delete this; | 1646 delete this; |
1638 } | 1647 } |
1639 | 1648 |
1640 virtual void didFail(blink::WebURLLoader* loader, | 1649 virtual void didFail(blink::WebURLLoader* loader, |
1641 const blink::WebURLError& error) { | 1650 const blink::WebURLError& error) { |
1642 success_ = false; | 1651 success_ = false; |
1643 } | 1652 } |
1644 | 1653 |
1645 PP_Instance instance_; | 1654 PP_Instance instance_; |
1646 scoped_ptr<blink::WebURLLoader> url_loader_; | 1655 scoped_ptr<blink::WebURLLoader> url_loader_; |
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1733 &StreamPexe | 1742 &StreamPexe |
1734 }; | 1743 }; |
1735 | 1744 |
1736 } // namespace | 1745 } // namespace |
1737 | 1746 |
1738 const PPB_NaCl_Private* GetNaClPrivateInterface() { | 1747 const PPB_NaCl_Private* GetNaClPrivateInterface() { |
1739 return &nacl_interface; | 1748 return &nacl_interface; |
1740 } | 1749 } |
1741 | 1750 |
1742 } // namespace nacl | 1751 } // namespace nacl |
OLD | NEW |