user_stream_data_source.cc 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. // Copyright 2017 The Crashpad Authors. All rights reserved.
  2. //
  3. // Licensed under the Apache License, Version 2.0 (the "License");
  4. // you may not use this file except in compliance with the License.
  5. // You may obtain a copy of the License at
  6. //
  7. // http://www.apache.org/licenses/LICENSE-2.0
  8. //
  9. // Unless required by applicable law or agreed to in writing, software
  10. // distributed under the License is distributed on an "AS IS" BASIS,
  11. // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12. // See the License for the specific language governing permissions and
  13. // limitations under the License.
  14. #include "handler/user_stream_data_source.h"
  15. #include "base/logging.h"
  16. #include "minidump/minidump_file_writer.h"
  17. #include "minidump/minidump_user_extension_stream_data_source.h"
  18. #include "snapshot/process_snapshot.h"
  19. namespace crashpad {
  20. void AddUserExtensionStreams(
  21. const UserStreamDataSources* user_stream_data_sources,
  22. ProcessSnapshot* process_snapshot,
  23. MinidumpFileWriter* minidump_file_writer) {
  24. if (!user_stream_data_sources)
  25. return;
  26. for (const auto& source : *user_stream_data_sources) {
  27. std::unique_ptr<MinidumpUserExtensionStreamDataSource> data_source(
  28. source->ProduceStreamData(process_snapshot));
  29. if (data_source &&
  30. !minidump_file_writer->AddUserExtensionStream(std::move(data_source))) {
  31. // This should only happen if multiple user stream sources yield the
  32. // same stream type. It's the user's responsibility to make sure
  33. // sources don't collide on the same stream type.
  34. LOG(ERROR) << "AddUserExtensionStream failed";
  35. }
  36. }
  37. }
  38. } // namespace crashpad