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

Side by Side Diff: chrome/browser/extensions/api/media_galleries/media_galleries_api.cc

Issue 2570903002: Media Galleries: Fix render-process-gone case in GetMetadata call (Closed)
Patch Set: Created 4 years 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 | « 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 (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 // Implements the Chrome Extensions Media Galleries API. 5 // Implements the Chrome Extensions Media Galleries API.
6 6
7 #include "chrome/browser/extensions/api/media_galleries/media_galleries_api.h" 7 #include "chrome/browser/extensions/api/media_galleries/media_galleries_api.h"
8 8
9 #include <stddef.h> 9 #include <stddef.h>
10 10
(...skipping 734 matching lines...) Expand 10 before | Expand all | Expand 10 after
745 new base::DictionaryValue); 745 new base::DictionaryValue);
746 attached_image->Set(kBlobUUIDKey, new base::StringValue( 746 attached_image->Set(kBlobUUIDKey, new base::StringValue(
747 current_blob->GetUUID())); 747 current_blob->GetUUID()));
748 attached_image->Set(kTypeKey, new base::StringValue( 748 attached_image->Set(kTypeKey, new base::StringValue(
749 current_image->type)); 749 current_image->type));
750 attached_image->Set(kSizeKey, new base::FundamentalValue( 750 attached_image->Set(kSizeKey, new base::FundamentalValue(
751 base::checked_cast<int>(current_image->data.size()))); 751 base::checked_cast<int>(current_image->data.size())));
752 attached_images_list->Append(std::move(attached_image)); 752 attached_images_list->Append(std::move(attached_image));
753 753
754 blob_uuids->push_back(current_blob->GetUUID()); 754 blob_uuids->push_back(current_blob->GetUUID());
755
756 content::RenderProcessHost* render_process_host =
757 render_frame_host()->GetProcess();
758 if (!render_process_host) {
759 SendResponse(false);
760 return;
761 }
762
755 extensions::BlobHolder* holder = 763 extensions::BlobHolder* holder =
756 extensions::BlobHolder::FromRenderProcessHost( 764 extensions::BlobHolder::FromRenderProcessHost(render_process_host);
757 render_frame_host()->GetProcess());
758 holder->HoldBlobReference(std::move(current_blob)); 765 holder->HoldBlobReference(std::move(current_blob));
759 766
760 // Construct the next Blob if necessary. 767 // Construct the next Blob if necessary.
761 if (blob_uuids->size() < attached_images->size()) { 768 if (blob_uuids->size() < attached_images->size()) {
762 metadata::AttachedImage* next_image = 769 metadata::AttachedImage* next_image =
763 &(*attached_images)[blob_uuids->size()]; 770 &(*attached_images)[blob_uuids->size()];
764 content::BrowserContext::CreateMemoryBackedBlob( 771 content::BrowserContext::CreateMemoryBackedBlob(
765 GetProfile(), 772 GetProfile(),
766 next_image->data.c_str(), 773 next_image->data.c_str(),
767 next_image->data.size(), 774 next_image->data.size(),
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after
901 SendResponse(false); 908 SendResponse(false);
902 return; 909 return;
903 } 910 }
904 911
905 gallery_watch_manager()->RemoveWatch( 912 gallery_watch_manager()->RemoveWatch(
906 GetProfile(), extension_id(), gallery_pref_id); 913 GetProfile(), extension_id(), gallery_pref_id);
907 SendResponse(true); 914 SendResponse(true);
908 } 915 }
909 916
910 } // namespace extensions 917 } // namespace extensions
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