• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Copyright (c) 2019, Google Inc.
2 // All rights reserved.
3 //
4 // Redistribution and use in source and binary forms, with or without
5 // modification, are permitted provided that the following conditions are
6 // met:
7 //
8 //     * Redistributions of source code must retain the above copyright
9 // notice, this list of conditions and the following disclaimer.
10 //     * Redistributions in binary form must reproduce the above
11 // copyright notice, this list of conditions and the following disclaimer
12 // in the documentation and/or other materials provided with the
13 // distribution.
14 //     * Neither the name of Google Inc. nor the names of its
15 // contributors may be used to endorse or promote products derived from
16 // this software without specific prior written permission.
17 //
18 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
19 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
20 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
21 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
22 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
23 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
24 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 
30 #ifndef COMMON_WINDOWS_SYMBOL_COLLECTOR_CLIENT_H_
31 #define COMMON_WINDOWS_SYMBOL_COLLECTOR_CLIENT_H_
32 
33 #include <string>
34 
35 namespace google_breakpad {
36 
37   using std::wstring;
38 
39   struct UploadUrlResponse {
40     // URL at which to HTTP PUT symbol file.
41     wstring upload_url;
42     // Unique key used to complete upload of symbol file.
43     wstring upload_key;
44   };
45 
46   enum SymbolStatus {
47     Found,
48     Missing,
49     Unknown
50   };
51 
52   enum CompleteUploadResult {
53     Ok,
54     DuplicateData,
55     Error
56   };
57 
58   // Client to interact with sym-upload-v2 API server via HTTP/REST.
59   class SymbolCollectorClient {
60   public:
61     // Returns a URL at which a symbol file can be HTTP PUT without
62     // authentication, along with an upload key that can be used to
63     // complete the upload process with CompleteUpload.
64     static bool CreateUploadUrl(
65         wstring& api_url,
66         wstring& api_key,
67         UploadUrlResponse *uploadUrlResponse);
68 
69     // Notify the API that symbol file upload is finished and its contents
70     // are ready to be read and/or used for further processing.
71     static CompleteUploadResult CompleteUpload(
72         wstring& api_url,
73         wstring& api_key,
74         const wstring& upload_key,
75         const wstring& debug_file,
76         const wstring& debug_id);
77 
78     // Returns whether or not a symbol file corresponding to the debug_file/
79     // debug_id pair is already present in symbol storage.
80     static SymbolStatus CheckSymbolStatus(
81         wstring& api_url,
82         wstring& api_key,
83         const wstring& debug_file,
84         const wstring& debug_id);
85   };
86 
87 }  // namespace google_breakpad
88 
89 #endif  // COMMON_WINDOWS_SYMBOL_COLLECTOR_CLIENT_H_
90